當前位置: 首頁>>代碼示例>>C#>>正文


C# Package.ParseRequest類代碼示例

本文整理匯總了C#中Microsoft.VisualStudio.Package.ParseRequest的典型用法代碼示例。如果您正苦於以下問題:C# ParseRequest類的具體用法?C# ParseRequest怎麽用?C# ParseRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ParseRequest類屬於Microsoft.VisualStudio.Package命名空間,在下文中一共展示了ParseRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParseSource

		}//OnIdle
		
		public override AuthoringScope ParseSource( ParseRequest req )
		{
			var dirty = (req.DirtySpan.iStartLine != req.DirtySpan.iEndLine) || (req.DirtySpan.iStartIndex != req.DirtySpan.iEndIndex);
			BeeSource src = null;
			if( (dirty || (req.Reason == ParseReason.None)) || (req.Reason == ParseReason.Check) )
			{
				src = ((BeeSource)GetSource( req.FileName ));
				try
				{
				}
				catch( ParseError err )
				{
					req.Sink.AddError( req.FileName, err.Message, new TextSpan() {
						iStartLine = err.Lnum,
						iStartIndex = err.At,
						iEndLine = err.Lnum,
						iEndIndex = err.End
					}, Severity.Fatal );
				}
				catch
				{
				}
			}
			return new BeeScope( src );
		}//ParseSource
開發者ID:firda-cze,項目名稱:bee,代碼行數:27,代碼來源:service.cs

示例2: ParseSource

        public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource(ParseRequest req)
        {
            Babel.Source source = (Babel.Source)this.GetSource(req.FileName);
            bool yyparseResult = false;

            // req.DirtySpan seems to be set even though no changes have occurred
            // source.IsDirty also behaves strangely
            // might be possible to use source.ChangeCount to sync instead

            if (req.DirtySpan.iStartIndex != req.DirtySpan.iEndIndex
                || req.DirtySpan.iStartLine != req.DirtySpan.iEndLine) {
                ErrorHandler handler = new ErrorHandler();
                Scanner scanner = new Scanner(); // string interface
                Parser parser = new Parser();  // use noarg constructor
                parser.scanner = scanner;
                scanner.Handler = handler;
                parser.SetHandler(handler);
                scanner.SetSource(req.Text, 0);

                parser.MBWInit(req);
                yyparseResult = parser.Parse();

                // store the parse results
                // source.ParseResult = aast;
                source.ParseResult = null;
                source.Braces = parser.Braces;

                // for the time being, just pull errors back from the error handler
                if (handler.ErrNum > 0) {
                    foreach (Babel.Parser.Error error in handler.SortedErrorList()) {
                        TextSpan span = new TextSpan();
                        span.iStartLine = span.iEndLine = error.line - 1;
                        span.iStartIndex = error.column;
                        span.iEndIndex = error.column + error.length;
                        req.Sink.AddError(req.FileName, error.message, span, Severity.Error);
                    }
                }
            }
            switch (req.Reason) {
                case ParseReason.Check:
                case ParseReason.HighlightBraces:
                case ParseReason.MatchBraces:
                case ParseReason.MemberSelectAndHighlightBraces:
                    // send matches to sink
                    // this should (probably?) be filtered on req.Line / col
                    if (source.Braces != null) {
                        foreach (TextSpan[] brace in source.Braces) {
                            if (brace.Length == 2)
                                req.Sink.MatchPair(brace[0], brace[1], 1);
                            else if (brace.Length >= 3)
                                req.Sink.MatchTriple(brace[0], brace[1], brace[2], 1);
                        }
                    }
                    break;
                default:
                    break;
            }

            return new AuthoringScope(req.Text);
        }
開發者ID:einaregilsson,項目名稱:Process-Language-Runtime,代碼行數:60,代碼來源:CCSLanguage.cs

示例3: ParseRequestWrapper

 public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource
     (ParseRequest request)
 {
     var wrapper = new ParseRequestWrapper(request);
     wrapper.Scanning();
     return new AuthoringScopeWrapper();
 }
開發者ID:hahoyer,項目名稱:reni.cs,代碼行數:7,代碼來源:ReniService.cs

示例4: BooScope

 public BooScope(CompiledProject compiledProject, BooSource source, ParseRequest parseRequest, ParseRequestProcessor parseRequestProcessor)
 {
     this.source = source;
     declarations = new DeclarationFinder(compiledProject, source, parseRequest.FileName);
     this.parseRequest = parseRequest;
     this.parseRequestProcessor = parseRequestProcessor;
 }
開發者ID:jagregory,項目名稱:boolangstudio,代碼行數:7,代碼來源:BooScope.cs

示例5: NSAuthoringScope

 public NSAuthoringScope(ParseRequest req, string dirtyFile, string project)
     : base()
 {
     m_sink = req.Sink;
     m_projectfile = project;
     m_dirtyname = dirtyFile;
     m_filename = req.FileName;
 }
開發者ID:jianboqi,項目名稱:NimStudio,代碼行數:8,代碼來源:NSAuthoringScope.cs

示例6: ParseSource

        public override AuthoringScope ParseSource(ParseRequest req)
        {
            SassParser parser = new SassParser();
            Source source = (Source)this.GetSource(req.FileName);

            if (req.Sink.BraceMatching)
            {
                if (req.Reason == ParseReason.MatchBraces)
                {
                    foreach (TextSpan[] brace in parser.Braces)
                    {
                        req.Sink.MatchPair(brace[0], brace[1], 1);
                    }
                }
            }
            return new SassParserAuthoringScope();
        }
開發者ID:solostyle,項目名稱:sassToolForVisualStudio,代碼行數:17,代碼來源:SassLanguageService.cs

示例7: ParseSource

        public override AuthoringScope ParseSource(ParseRequest req)
        {
            if (req == null)
            {
                return null;
            }

            var scope = new CQLAuthoringScope();
            req.Scope = scope;

            if (req.Reason == ParseReason.Check)
            {
            }

            if (m_scanner != null && req.Reason == ParseReason.MemberSelect || req.Reason == ParseReason.MemberSelectAndHighlightBraces && req.TokenInfo != null)
            {
                var token = m_scanner.GetToken(req.TokenInfo.Token);

                if (token != null)
                {
                    if (token.Type == 4) // [
                    {
                        scope.AddDeclaration(new CQLDeclaration("Encounter", 0, "An encounter with the patient"));
                        scope.AddDeclaration(new CQLDeclaration("Procedure", 0, "A procedure"));
                        scope.AddDeclaration(new CQLDeclaration("Medication", 0, "A medication"));
                    }

                    if (token.Type == 3) // ,
                    {
                        scope.AddDeclaration(new CQLDeclaration("Performed", 0, "An action performed"));
                        scope.AddDeclaration(new CQLDeclaration("Proposed", 0, "An action performed"));
                        scope.AddDeclaration(new CQLDeclaration("Ordered", 0, "An action performed"));
                    }

                    if (token.Type == 5) // :
                    {
                        scope.AddDeclaration(new CQLDeclaration("\"Inpatient\"", 0, "Inpatient encounter"));
                        scope.AddDeclaration(new CQLDeclaration("\"Outpatient\"", 0, "Outpatient encounter"));
                        scope.AddDeclaration(new CQLDeclaration("\"Face-to-face Interaction\"", 0, "Face-to-face interaction"));
                    }
                }
            }

            return scope;
        }
開發者ID:krondor,項目名稱:clinical_quality_language,代碼行數:45,代碼來源:CQLLanguageService.cs

示例8: CreateScopeTest

        public void CreateScopeTest()
        {
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(null));

            ParseRequest request = new ParseRequest(false);

            request.Reason = ParseReason.None;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.MemberSelect;
            Assert.IsNotNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.HighlightBraces;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.MemberSelectAndHighlightBraces;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.MatchBraces;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.Check;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.CompleteWord;
            Assert.IsNotNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.DisplayMemberList;
            Assert.IsNotNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.QuickInfo;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.MethodTip;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.Autos;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.CodeSpan;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));

            request.Reason = ParseReason.Goto;
            Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
        }
開發者ID:ufosky-server,項目名稱:MultiversePlatform,代碼行數:45,代碼來源:AuthoringScopeTest.cs

示例9: ParseSource

 public override AuthoringScope ParseSource(ParseRequest req)
 {
     XSharpAuthoringScope scope = new XSharpAuthoringScope();
     if (req.Reason == ParseReason.Check ||
         req.Reason == ParseReason.None)
     {
         // Parse the entire source as given in req.Text. Store results in the XSharpAuthoringScope object.
     }
     else if (req.Reason == ParseReason.DisplayMemberList)
     {
         // Parse the line specified in req.Line for the two tokens just before req.Col to get the identifier and the member connector symbol. 
         // Find members of the identifer in the parse tree and store the list of members in the Declarations class.
     }
     else if (req.Reason == ParseReason.MethodTip)
     {
         // Parse the line specified in req.Line for the token just before req.Col to obtain the name of the method. 
         // Find all method signatures with the same name in the existing parse tree and store the list of signatures in the Methods class.
     }
     // continue for the rest of the supported ParseReason values.
     return scope;
 }
開發者ID:X-Sharp,項目名稱:XSharpPublic,代碼行數:21,代碼來源:XSharpLanguageService.cs

示例10: ParseSource

        public override AuthoringScope ParseSource(ParseRequest req)
        {
            Core.FStarParser parser = new Core.FStarParser();
            var result = new TestAuthoringScope();
            var tokens = new List<TokenInfo>();
            if (req.Sink.BraceMatching || ParseReason.MatchBraces == req.Reason || ParseReason.HighlightBraces == req.Reason)
            {
                var scanner = GetScanner(null);
                scanner.SetSource(req.Text, 0);
                var line = 0;
                var col = 0;
                req.View.GetCaretPos(out line, out col);
                (scanner as VisualFStar.Core.FStarScanner).MatchPair(req.Sink, req.Text, line, col);

            }
            else parser.Parse(req);
            if (ParseReason.Check == req.Reason)
            {
                Console.WriteLine("!!!!");
            }
            return result;
        }
開發者ID:YaccConstructor,項目名稱:VisualFStar,代碼行數:22,代碼來源:FStarLanguageService.cs

示例11: TriggerParse

 /// <summary>
 /// Triggers the parse.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="yyresult">if set to <c>true</c> [yyresult].</param>
 /// <returns></returns>
 private static LuaParser TriggerParse(ParseRequest request, out bool yyresult)
 {
     LuaParser parser = CreateParser(request);
     yyresult = parser.Parse();
     return parser;
 }
開發者ID:jda808,項目名稱:NPL,代碼行數:12,代碼來源:LanguageService.cs

示例12: GetLastWord

        /// <summary>
        /// Gets the last word.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        private static string GetLastWord(ParseRequest request)
        {
            string line;
            request.View.GetTextStream(request.Line, 0, request.Line, request.TokenInfo.EndIndex, out line);

            if (line != null)
            {
                // Find the delimiter before the last word
                int lastDelimiterIndex = line.LastIndexOfAny(lastWordDelimiters);

                // Get the last word before the caret
                return lastDelimiterIndex != -1 ? line.Substring(lastDelimiterIndex + 1) : line;
            }

            return String.Empty;
        }
開發者ID:jda808,項目名稱:NPL,代碼行數:21,代碼來源:LanguageService.cs

示例13: CreateParser

        /// <summary>
        /// Creates the parser.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        private static LuaParser CreateParser(ParseRequest request)
        {
            // Create ErrorHandler for scanner
            var handler = new ParaEngine.Tools.Lua.Parser.ErrorHandler();

            // Create scanner and parser
            LuaScanner scanner = new ParaEngine.Tools.Lua.Lexer.Scanner();
            LuaParser parser = new LuaParser();

            // Set the error handler for the scanner
            scanner.Handler = handler;

            // Associate the scanner with the parser
            parser.scanner = scanner;

            // Initialize with the request (can be null)
            parser.Request = request;

            // If the parser is created for a request, automatically set the source from the request
            if (request != null)
                scanner.SetSource(request.Text, 0);

            // Return the parser
            return parser;
        }
開發者ID:jda808,項目名稱:NPL,代碼行數:30,代碼來源:LanguageService.cs

示例14: ParseSource

        /// <summary>
        /// Processes a Parse request.
        /// </summary>
        /// <param name="request">The request to process.</param>
        /// <returns>An AuthoringScope containing the declarations and other information.</returns>
        public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource(ParseRequest request)
        {
            Trace.WriteLine(request.Reason);
            authoringScope.Clear();

            if (request.ShouldParse())
            {
                // Make sure we are processing hidden regions
                request.Sink.ProcessHiddenRegions = true;

                // Create a parser for the request, and execute parsing...
                bool successfulParse;
                LuaParser parser = TriggerParse(request, out successfulParse);
                InitializeFileCodeModel(parser.Chunk);

                if (successfulParse)
                {
                    RefreshDeclarationsForRequest(request, parser, true);
                }

                if (request.NeedsDeclarations())
                {
                    AddDeclarationProvidersToScope(request);

                    if (request.NeedsQualifiedName())
                    {
                        authoringScope.SetQualifiedName(GetLastWord(request));
                    }
                }
            }
            else
            {
                if(request.Reason == ParseReason.QuickInfo)
                {
                    // TODO: mouse over a text to display some info.
                }
            }

            // Return authoring scope
            return authoringScope;
        }
開發者ID:jda808,項目名稱:NPL,代碼行數:46,代碼來源:LanguageService.cs

示例15: HandleParseResponse

    internal void HandleParseResponse(ParseRequest req) {

      try {
        ReportErrors(req.Sink.Errors);
      } catch (Exception e) {
        CCITracing.Trace("HandleParseResponse exception: " + e.Message);
      }

    }
開發者ID:hesam,項目名稱:SketchSharp,代碼行數:9,代碼來源:Source.cs


注:本文中的Microsoft.VisualStudio.Package.ParseRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。