Exemplo n.º 1
0
        private void Tokenize(ITextSnapshot currentSnapshot,
                              string spanText,
                              int startPosition,
                              out Ast generatedAst,
                              out Token[] generatedTokens,
                              out List <ClassificationInfo> tokenSpans,
                              out List <TagInformation <ErrorTag> > errorTags,
                              out Dictionary <int, int> startBraces,
                              out Dictionary <int, int> endBraces,
                              out List <TagInformation <IOutliningRegionTag> > regions)
        {
            Log.Debug("Parsing input.");
            ParseError[] errors;
            generatedAst = Parser.ParseInput(spanText, out generatedTokens, out errors);

            Log.Debug("Classifying tokens.");
            tokenSpans = _classifierService.ClassifyTokens(generatedTokens, startPosition).ToList();

            Log.Debug("Tagging error spans.");
            // Trigger the out-proc error parsing only when there are errors from the in-proc parser
            if (errors.Length != 0)
            {
                var errorsParsedFromOutProc = PowerShellToolsPackage.IntelliSenseService.GetParseErrors(spanText);
                errorTags = _errorTagService.TagErrorSpans(currentSnapshot, startPosition, errorsParsedFromOutProc).ToList();
            }
            else
            {
                errorTags = _errorTagService.TagErrorSpans(currentSnapshot, startPosition, errors).ToList();
            }

            Log.Debug("Matching braces and regions.");
            _regionAndBraceMatchingService.GetRegionsAndBraceMatchingInformation(spanText, startPosition, generatedTokens, out startBraces, out endBraces, out regions);
        }
Exemplo n.º 2
0
        private void Tokenize(ITrackingSpan spanToTokenize, string spanText)
        {
            Log.Debug("Parsing input.");
            ParseError[] errors;
            _generatedAst = Parser.ParseInput(spanText, out _generatedTokens, out errors);

            var position = spanToTokenize.GetStartPoint(Buffer.CurrentSnapshot).Position;
            var array    = _generatedTokens;

            Log.Debug("Classifying tokens.");
            _tokenSpans = _classifierService.ClassifyTokens(array, position);

            Log.Debug("Tagging error spans.");
            _errorTags = _errorTagService.TagErrorSpans(Buffer, position, errors).ToList();

            Log.Debug("Matching braces and regions.");
            _regionAndBraceMatchingService.GetRegionsAndBraceMatchingInformation(spanText, position, _generatedTokens, out _startBraces, out _endBraces, out _regions);
        }