public RobotsTxtSyntacticParser(IClassificationTypeRegistryService registry)
 {
     _commentType = registry.GetClassificationType(PredefinedClassificationTypeNames.Comment);
     _delimiterType = registry.GetClassificationType("RobotsTxt/Delimiter");
     _recordNameType = registry.GetClassificationType("RobotsTxt/RecordName");
     _recordValueType = registry.GetClassificationType("RobotsTxt/RecordValue");
 }
Esempio n. 2
0
 public static ClassificationSpan ToClassificationSpan(this TextSpan span, ITextSnapshot snapshot, IClassificationType classificationType)
 {
     return new ClassificationSpan(
       new SnapshotSpan(snapshot,  span.Start, span.Length),
       classificationType
       );
 }
 internal VendorClassifier(IClassificationTypeRegistryService registry, ITextBuffer buffer)
 {
     _registry = registry;
     _buffer = buffer;
     _decClassification = _registry.GetClassificationType(ClassificationTypes._declaration);
     _valClassification = _registry.GetClassificationType(ClassificationTypes._value);
 }
		internal static void FillClassificationGap(List<ClassificationSpan> classifications, Span? lastClassificationSpan, Span newClassificationSpan, ITextSnapshot currentSnapshot, IClassificationType classificationType)
		{
			if (lastClassificationSpan.HasValue && newClassificationSpan.Start > lastClassificationSpan.Value.Start + lastClassificationSpan.Value.Length)
			{
				classifications.Add(new ClassificationSpan(new SnapshotSpan(currentSnapshot, lastClassificationSpan.Value.Start + lastClassificationSpan.Value.Length, newClassificationSpan.Start - (lastClassificationSpan.Value.Start + lastClassificationSpan.Value.Length)), classificationType));
			}
		}
 internal SqlClassifier(ITagAggregator<NaturalTextTag> tagger, IClassificationTypeRegistryService classificationRegistry)
 {
     this.tagger = tagger;
     keywordType = classificationRegistry.GetClassificationType("sql-keyword");
     functionType = classificationRegistry.GetClassificationType("sql-function");
     variableType = classificationRegistry.GetClassificationType("sql-variable");
 }
 public MarkdownClassifier(IClassificationTypeRegistryService registry)
 {
     _bold = registry.GetClassificationType(MarkdownClassificationTypes.MarkdownBold);
     _italic = registry.GetClassificationType(MarkdownClassificationTypes.MarkdownItalic);
     _header = registry.GetClassificationType(MarkdownClassificationTypes.MarkdownHeader);
     _code = registry.GetClassificationType(MarkdownClassificationTypes.MarkdownCode);
 }
        public CurrentColumnAdornment(
            IWpfTextView view, IClassificationFormatMap formatMap,
            IClassificationType formatType, IVsfSettings settings)
        {
            this.view = view;
              this.formatMap = formatMap;
              this.formatType = formatType;
              this.settings = settings;
              this.columnRect = new Rectangle();
              layer = view.GetAdornmentLayer(Constants.COLUMN_HIGHLIGHT);

              view.Caret.PositionChanged += OnCaretPositionChanged;
              view.ViewportWidthChanged += OnViewportChanged;
              view.ViewportHeightChanged += OnViewportChanged;
              view.LayoutChanged += OnViewLayoutChanged;
              view.TextViewModel.EditBuffer.PostChanged += OnBufferPostChanged;
              view.Closed += OnViewClosed;
              view.Options.OptionChanged += OnSettingsChanged;

              this.settings.SettingsChanged += OnSettingsChanged;
              formatMap.ClassificationFormatMappingChanged +=
             OnClassificationFormatMappingChanged;

              CreateDrawingObjects();
        }
 public DockerfileClassifier(IClassificationTypeRegistryService registry)
 {
     _keyword = registry.GetClassificationType(PredefinedClassificationTypeNames.Keyword);
     _comment = registry.GetClassificationType(PredefinedClassificationTypeNames.Comment);
     _string = registry.GetClassificationType(PredefinedClassificationTypeNames.String);
     _symbol = registry.GetClassificationType(DockerfileClassificationTypes.Keyword);
 }
 private void AddClassification(IClassificationType classificationType, int startIndex, int length)
 {
     CurrentFileBlockBuilder.ClassificationSpans.Add(
         new ClassificationSpan(
             new SnapshotSpan(textSnapshot, new Span(startIndex, length)),
             classificationType));
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DothtmlClassifier"/> class.
 /// </summary>
 public DothtmlClassifier(IClassificationTypeRegistryService registry, ITextBuffer buffer)
 {
     tokenizer = new DothtmlTokenizer();
     this.buffer = buffer;
     bindingBrace = registry.GetClassificationType(DothtmlClassificationTypes.BindingBrace);
     bindingContent = registry.GetClassificationType(DothtmlClassificationTypes.BindingContent);
 }
Esempio n. 11
0
 public static ITagSpan<IClassificationTag> ToTagSpan(this TextSpan span, ITextSnapshot snapshot, IClassificationType classificationType)
 {
     return new TagSpan<IClassificationTag>(
       new SnapshotSpan(snapshot, span.Start, span.Length),
       new ClassificationTag(classificationType)
       );
 }
		internal WacomTranslationDatabaseHighlighter(IClassificationTypeRegistryService registry)
		{
			_keyType = registry.GetClassificationType("wacom.tdb.key");
			_valType = registry.GetClassificationType("wacom.tdb.value");
			_sepType = registry.GetClassificationType("wacom.tdb.separator");
			_errType = registry.GetClassificationType("wacom.tdb.error");
		}
Esempio n. 13
0
 public UsageClassifier(IClassificationTypeRegistryService classificationRegistry, ITextBuffer textBuffer)
 {
     _highlightOne = classificationRegistry.GetClassificationType(ClassificationTypes.HighlightOneName);
       _highlightTwo = classificationRegistry.GetClassificationType(ClassificationTypes.HighlightTwoName);
       _textBuffer = textBuffer;
       _textBuffer.Changed += (_, args) => UpdateUsageHighlighting(Enumerable.Empty<GotoInfo>());
 }
Esempio n. 14
0
 internal VccClassifier(IClassificationTypeRegistryService registry)
 {
   this.keywordType = registry.GetClassificationType(VccClassificationTypeDefinitions.KeywordType);
   this.specType= registry.GetClassificationType(VccClassificationTypeDefinitions.SpecType);
   this.dimmedKeywordType = registry.GetClassificationType(VccClassificationTypeDefinitions.DimmedKeywordType);
   this.dimmedSpecType = registry.GetClassificationType(VccClassificationTypeDefinitions.DimmedSpecType);
   VSPackagePackage.Instance.OptionPage.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OptionPage_PropertyChanged);
 }
Esempio n. 15
0
        internal HSPClassifier(IClassificationTypeRegistryService registry)
        {
            _validType = registry.GetClassificationType("HSPClassifierValidFormat");
            _normalType = registry.GetClassificationType("HSPClassifierNormalFormat");

            _commentoutType = registry.GetClassificationType("HSPClassifierCommentOutFormat");
            _keywordType = registry.GetClassificationType("HSPClassifierKeywordFormat");
        }
 internal StorEvilClassifier(IClassificationTypeRegistryService registry)
 {
     _pending = registry.GetClassificationType("StorEvil.VS2010.Pending");
     _comment = registry.GetClassificationType("StorEvil.VS2010.Comment");
     _interpreted = registry.GetClassificationType("StorEvil.VS2010.Interpreted");
     _scenarioStart = registry.GetClassificationType("StorEvil.VS2010.ScenarioStart");
     _table = registry.GetClassificationType("StorEvil.VS2010.Table");
 }
Esempio n. 17
0
        private void AddClassification(LocatedNode node, IClassificationType classificationType)
        {
            if (classificationType == null)
                throw new ArgumentNullException(nameof(classificationType));

            if (node.SourceRange.Length > 0 && node.Span.IsInRootFile)
                _results.Add(CreateClassificationTagSpan(node, classificationType));
        }
Esempio n. 18
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="syntaxRoot">Syntax root</param>
		/// <param name="semanticModel">Semantic model</param>
		/// <param name="workspace">Workspace</param>
		/// <param name="roslynClassificationTypes">Classification types</param>
		/// <param name="defaultClassificationType">Default classification type if a token can't be classified or null to not use anything</param>
		/// <param name="cancellationToken">Cancellation token</param>
		public RoslynClassifier(SyntaxNode syntaxRoot, SemanticModel semanticModel, Workspace workspace, RoslynClassificationTypes roslynClassificationTypes, IClassificationType defaultClassificationType, CancellationToken cancellationToken) {
			this.syntaxRoot = syntaxRoot;
			this.semanticModel = semanticModel;
			this.workspace = workspace;
			this.roslynClassificationTypes = roslynClassificationTypes;
			this.defaultClassificationType = defaultClassificationType;
			this.cancellationToken = cancellationToken;
		}
Esempio n. 19
0
		BreakpointMarker(IBreakpointService breakpointService, IGlyphTextMarkerService glyphTextMarkerService, IClassificationTypeRegistryService classificationTypeRegistryService, ILCodeBreakpointGlyphTextMarkerHandler ilCodeBreakpointGlyphTextMarkerHandler) {
			this.glyphTextMarkerService = glyphTextMarkerService;
			classificationTypeEnabledBreakpoint = classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.BreakpointStatement);
			toMethodMarkers = new Dictionary<ILCodeBreakpoint, IGlyphTextMethodMarker>();
			this.ilCodeBreakpointGlyphTextMarkerHandler = ilCodeBreakpointGlyphTextMarkerHandler;
			breakpointService.BreakpointsAdded += BreakpointService_BreakpointsAdded;
			breakpointService.BreakpointsRemoved += BreakpointService_BreakpointsRemoved;
		}
Esempio n. 20
0
 public WebVttClassifier(IClassificationTypeRegistryService registry)
 {
     _markup = registry.GetClassificationType(WebVttClassificationTypes.Markup);
     _name = registry.GetClassificationType(WebVttClassificationTypes.Name);
     _statement = registry.GetClassificationType(WebVttClassificationTypes.Statement);
     _time = registry.GetClassificationType(WebVttClassificationTypes.Time);
     _comment = registry.GetClassificationType(PredefinedClassificationTypeNames.Comment);
 }
Esempio n. 21
0
        private void AddClassification(SyntaxNode node, IClassificationType classificationType)
        {
            if (classificationType == null)
                throw new ArgumentNullException(nameof(classificationType));

            if (node.Span.Length > 0)
                _results.Add(CreateClassificationTagSpan(node, classificationType));
        }
 public static ClassificationMatchResult Create(IClassificationType type, int index, int length)
 {
     return new ClassificationMatchResult
     {
         Type = type,
         Index = index,
         Length = length
     };
 }
 public TemplateClassificationTaggerTest()
 {
     this.registry = new FakeClassificationTypeRegistryService();
     this.codeBlockClassification = this.registry.CreateClassificationType("TextTemplate.CodeBlock", new IClassificationType[0]);
     this.delimiterClassification = this.registry.CreateClassificationType("TextTemplate.Delimiter", new IClassificationType[0]);
     this.directiveNameClassification = this.registry.CreateClassificationType("TextTemplate.DirectiveName", new IClassificationType[0]);
     this.attributeNameClassification = this.registry.CreateClassificationType("TextTemplate.AttributeName", new IClassificationType[0]);
     this.attributeValueClassification = this.registry.CreateClassificationType("TextTemplate.AttributeValue", new IClassificationType[0]);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RobotsTxtClassifier"/> class.
        /// </summary>
        /// <param name="registry">Classification registry.</param>
        public RobotsTxtClassifier(ITextBuffer buffer, ISyntacticParser syntacticParser, IClassificationTypeRegistryService registry)
        {
            buffer.Properties.AddProperty(typeof(ISyntacticParser), syntacticParser);

            _commentType = registry.GetClassificationType(PredefinedClassificationTypeNames.Comment);
            _delimiterType = registry.GetClassificationType("RobotsTxt/Delimiter");
            _propertyNameType = registry.GetClassificationType("RobotsTxt/PropertyName");
            _propertyValueType = registry.GetClassificationType("RobotsTxt/PropertyValue");
        }
 internal ChromiumStyleClassifier(
   IClassificationTypeRegistryService classificationRegistry,
   IEnumerable<ITextLineChecker> checkers,
   IConfigurationFileLocator configurationFileLocator) {
   _classificationType = classificationRegistry.GetClassificationType(ChromiumStyleClassifierConstants.Name);
   _checkers = checkers;
   _configurationFileLocator = configurationFileLocator;
   _disabledCheckers = new Lazy<IList<string>>(ReadDisableCheckers);
 }
 internal EditorClassifierMaxMinLenRow(ITextBuffer bufferToClassify, IClassificationTypeRegistryService registry)
 {
     buffer = bufferToClassify;
     _classificationTypeVeryLong = registry.GetClassificationType("VeryLongStr");
     _classificationTypeLong = registry.GetClassificationType("LongStr"); ;
     _classificationTypeNormal = registry.GetClassificationType("NormStr"); ;
     _classificationTypeSmall = registry.GetClassificationType("SmallStr"); ;
     _classificationTypeVerySmall = registry.GetClassificationType("VerySmallStr"); ;
 }
Esempio n. 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VisualCobra"/> class.
        /// </summary>
        /// <param name="registry">The registry.</param>
        internal VisualCobra(IClassificationTypeRegistryService registry)
        {
            CommentCache = new Dictionary<ITextSnapshot, IList<Span>>();

            _cobraKeywordClassificationType = registry.GetClassificationType("CobraKeyword");
            _cobraCommentClassificationType = registry.GetClassificationType("CobraComment");
            _cobraStringClassificationType = registry.GetClassificationType("CobraString");
            _cobraClassClassificationType = registry.GetClassificationType("CobraClass");
            _cobraIndentErrorClassificationType = registry.GetClassificationType("CobraIndentError");
        }
Esempio n. 28
0
 internal XSharpTagger(IClassificationTypeRegistryService registry)
 {
     xsharpIdentifierType = registry.GetClassificationType(ColorizerConstants.XSharpIdentifierFormat);
     xsharpBraceOpenType = registry.GetClassificationType(ColorizerConstants.XSharpBraceOpenFormat);
     xsharpBraceCloseType = registry.GetClassificationType(ColorizerConstants.XSharpBraceCloseFormat);
     xsharpRegionStartType = registry.GetClassificationType(ColorizerConstants.XSharpRegionStartFormat);
     xsharpRegionStopType = registry.GetClassificationType(ColorizerConstants.XSharpRegionStopFormat);
     //
     tags = new List<ITagSpan<IClassificationTag>>();
 }
Esempio n. 29
0
        public IClassificationType GetClassification(IClassificationTypeRegistryService registry)
        {
            if (!IsResolved)
            {
                ClassificationType = registry.GetClassificationType(Name);
                IsResolved = true;
            }

            return ClassificationType;
        }
        void ClearForeground(IClassificationType classification)
        {
            var properties = formatMap.GetTextProperties(classification);

            // If this is already cleared out, skip it
            if (properties.ForegroundBrushEmpty)
                return;

            formatMap.SetTextProperties(classification, properties.ClearForegroundBrush());
        }
Esempio n. 31
0
 public ClassificationInfo(Lazy <EditorFormatDefinition, IClassificationFormatMetadata> lazy, IClassificationType classificationType)
 {
     Lazy = lazy;
     ClassificationType = classificationType;
 }
Esempio n. 32
0
 internal DirectoryTaggerSource(ITextBuffer textBuffer, IClassificationType classificationType)
 {
     _textBuffer        = textBuffer;
     _classificationTag = new ClassificationTag(classificationType);
 }
Esempio n. 33
0
 OpenFromGACTextClassifierProvider(IThemeClassificationTypeService themeClassificationTypeService)
 {
     this.gacMatchHighlightClassificationType = themeClassificationTypeService.GetClassificationType(TextColor.GacMatchHighlight);
 }
Esempio n. 34
0
 internal AsmDocUnderlineTagger(ITextView textView, IClassificationType classificationType)
 {
     this.textView_           = textView ?? throw new ArgumentNullException(nameof(textView));
     this.classificationType_ = classificationType ?? throw new ArgumentNullException(nameof(classificationType));
     this.underlineSpan_      = null;
 }
Esempio n. 35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GfnClassifier"/> class.
 /// </summary>
 /// <param name="registry">Classification registry.</param>
 internal GfnClassifier(IClassificationTypeRegistryService registry)
 {
     this.classificationType = registry.GetClassificationType("GfnClassifier");
 }
Esempio n. 36
0
 public CurrentStatementForegroundTaggerProvider(IClassificationTypeRegistryService classificationTypeRegistryService)
 {
     this.classificationTypeRegistryService = classificationTypeRegistryService;
     this.classificationType = classificationTypeRegistryService.GetClassificationType(ClassificationTypes.CurrentStatementForegroundTypeName);
     this.tag = new ClassificationTag(classificationType);
 }
Esempio n. 37
0
        public IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            ITextSnapshot snapshot = span.Snapshot;

            List <ClassificationSpan> spans = new List <ClassificationSpan>();

            if (snapshot.Length == 0)
            {
                return(spans);
            }

            var allText = span.GetText();

            int startno = span.Start.GetContainingLine().LineNumber;
            int endno   = (span.End - 1).GetContainingLine().LineNumber;

            for (int i = startno; i <= endno; i++)
            {
                ITextSnapshotLine line = snapshot.GetLineFromLineNumber(i);
                if (line.Length == 0)
                {
                    continue;
                }
                string text = line.Snapshot.GetText(new SnapshotSpan(line.Start, line.Length));

                int c1 = 0, c2, c3;
                IClassificationType fgType = _classificationTypeRegistry.GetClassificationType("output.term.color15");
                IClassificationType bgType = null;            // _classificationTypeRegistry.GetClassificationType("output.term.bgcolor00");

                c1 = text.IndexOf("\u001b[");                 // '\x001b'
                if (c1 >= 0)
                {
handleMarker:
                    c3 = text.IndexOf("m", c1);
                    if (c3 < 0)
                    {
                        // invalid or unexpected escape sequence
                        continue;
                    }

                    string[] escapeCodes = text.Substring(c1 + 2, c3 - c1 - 2).Split(';');
                    int      l           = escapeCodes.Length;
                    if (string.IsNullOrEmpty(escapeCodes[l - 1]))
                    {
                        l--;
                    }

                    for (int ii = 0; ii < l; ii++)
                    {
                        int v;
                        if (int.TryParse(escapeCodes[ii], out v))
                        {
                            // ansi colors
                            if ((v >= 30 && v <= 37) || (v >= 40 && v <= 47))
                            {
                                bool bright = false;
                                if (ii + 1 < l)
                                {
                                    int v2;
                                    if (int.TryParse(escapeCodes[ii + 1], out v2))
                                    {
                                        if (v2 == 1)
                                        {
                                            bright = true; ii++;
                                        }
                                        else if (v2 != 0)
                                        {
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                if (v >= 30 && v <= 37)
                                {
                                    if (!bright)
                                    {
                                        fgType = _classificationTypeRegistry.GetClassificationType("output.term.color" + (v - 30).ToString("00"));
                                    }
                                    else
                                    {
                                        fgType = _classificationTypeRegistry.GetClassificationType("output.term.color" + (0x08 + (v - 30)).ToString("00"));
                                    }
                                }
                                if (v >= 40 && v <= 47)
                                {
                                    if (!bright)
                                    {
                                        bgType = _classificationTypeRegistry.GetClassificationType("output.term.bgcolor" + (v - 40).ToString("00"));
                                    }
                                    else
                                    {
                                        bgType = _classificationTypeRegistry.GetClassificationType("output.term.bgcolor" + (0x08 + (v - 40)).ToString("00"));
                                    }
                                }
                            }
                            else if (v >= 90 && v <= 97)
                            {
                                fgType = _classificationTypeRegistry.GetClassificationType("output.term.color" + (0x08 + (v - 90)).ToString("00"));
                            }
                            else if (v >= 100 && v <= 107)
                            {
                                bgType = _classificationTypeRegistry.GetClassificationType("output.term.bgcolor" + (0x08 + (v - 100)).ToString("00"));
                            }
                            else if (v == 38 || v == 48)
                            {
                                if (ii + 1 < l)
                                {
                                    int v2;
                                    if (int.TryParse(escapeCodes[ii + 1], out v2))
                                    {
                                        if (v2 == 2)
                                        {
                                            // rgb
                                            if (ii + 4 < l)
                                            {
                                                int r, g, b;
                                                if (!int.TryParse(escapeCodes[ii + 2], out r) || !int.TryParse(escapeCodes[ii + 3], out g) || !int.TryParse(escapeCodes[ii + 4], out b))
                                                {
                                                    break;
                                                }
                                                // TODO: handle rgb code
                                                ii += 4;
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }
                                        else if (v2 == 5)
                                        {
                                            // 256 color mode
                                            if (ii + 2 < l)
                                            {
                                                int code;
                                                if (!int.TryParse(escapeCodes[ii + 2], out code))
                                                {
                                                    break;
                                                }
                                                if (v == 38)
                                                {
                                                    fgType = _classificationTypeRegistry.GetClassificationType("output.term.color" + code.ToString("00"));
                                                }
                                                if (v == 48)
                                                {
                                                    bgType = _classificationTypeRegistry.GetClassificationType("output.term.bgcolor" + code.ToString("00"));
                                                }
                                                ii += 2;
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    c3++;                     // include 'm' character
                    var tCode = _classificationTypeRegistry.GetClassificationType("output.term.colorcode");
                    spans.Add(new ClassificationSpan(new SnapshotSpan(line.Extent.Start + c1, c3 - c1), tCode));

                    c2 = text.IndexOf("\u001b[", c3);
                    if (c2 >= 0)
                    {
                        if (c2 - c3 >= 0)
                        {
                            spans.Add(new ClassificationSpan(new SnapshotSpan(line.Extent.Start + c3, c2 - c3), fgType));
                            if (bgType != null)
                            {
                                spans.Add(new ClassificationSpan(new SnapshotSpan(line.Extent.Start + c3, c2 - c3), bgType));
                            }
                        }
                        c1 = c2;
                        goto handleMarker;
                    }
                    else if (text.Length - c3 > 0)
                    {
                        spans.Add(new ClassificationSpan(new SnapshotSpan(line.Extent.Start + c3, text.Length - c3), fgType));
                        if (bgType != null)
                        {
                            spans.Add(new ClassificationSpan(new SnapshotSpan(line.Extent.Start + c3, text.Length - c3), bgType));
                        }
                    }
                    //spans.Add(new ClassificationSpan(line.Extent, t));
                }
            }

            return(spans);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EditorClassifier1"/> class.
 /// </summary>
 /// <param name="registry">Classification registry.</param>
 internal EditorClassifier1(IClassificationTypeRegistryService registry)
 {
     this.classificationType = registry.GetClassificationType("EditorClassifier1");
 }
Esempio n. 39
0
        private void AddToken(IClassificationType type, int start, int length)
        {
            var token = new JadeToken(JadeTokenType.None, type, start, length);

            this.Tokens.Add(token);
        }
Esempio n. 40
0
        protected override void ReParseImpl()
        {
            Stopwatch timer = Stopwatch.StartNew();

            // lex the entire document to get the set of identifiers we'll need to classify
            ITextSnapshot     snapshot     = TextBuffer.CurrentSnapshot;
            var               input        = new SnapshotCharStream(snapshot, new Span(0, snapshot.Length));
            JavaUnicodeStream inputWrapper = new JavaUnicodeStream(input);
            var               lexer        = new Java2Lexer(inputWrapper);
            var               tokens       = new CommonTokenStream(lexer);

            tokens.Fill();

            List <IToken> nameKeywords = new List <IToken>();
            List <IToken> declColons   = new List <IToken>();

            List <IToken> identifiers = new List <IToken>();

            HashSet <IToken> definitions = new HashSet <IToken>(TokenIndexEqualityComparer.Default);
            HashSet <IToken> references  = new HashSet <IToken>(TokenIndexEqualityComparer.Default);

            GetLl2SymbolSets();

            while (tokens.LA(1) != CharStreamConstants.EndOfFile)
            {
                // covered by the double-sided check
                if (_definitionOnlySourceSet.Contains(tokens.LA(1)))
                {
                    if (tokens.LA(2) == Java2Lexer.IDENTIFIER)
                    {
                        definitions.Add(tokens.LT(2));
                    }
                }
                else if (_referenceOnlySourceSet.Contains(tokens.LA(1)))
                {
                    if (tokens.LA(2) == Java2Lexer.IDENTIFIER)
                    {
                        references.Add(tokens.LT(2));
                    }
                }

                if (_definitionOnlyFollowSet.Contains(tokens.LA(1)))
                {
                    IToken previous = tokens.LT(-1);
                    if (previous != null && previous.Type == Java2Lexer.IDENTIFIER)
                    {
                        definitions.Add(previous);
                    }
                }
                else if (_referenceOnlyFollowSet.Contains(tokens.LA(1)))
                {
                    IToken previous = tokens.LT(-1);
                    if (previous != null && previous.Type == Java2Lexer.IDENTIFIER)
                    {
                        references.Add(previous);
                    }
                }

                if (tokens.LA(2) == Java2Lexer.IDENTIFIER)
                {
                    IntervalSet bothWaysFollowDefinition;
                    IntervalSet bothWaysFollowReference;
                    _definitionContextSet1.TryGetValue(tokens.LA(1), out bothWaysFollowDefinition);
                    _referenceContextSet1.TryGetValue(tokens.LA(1), out bothWaysFollowReference);
                    bool couldBeDef = bothWaysFollowDefinition != null && bothWaysFollowDefinition.Contains(tokens.LA(3));
                    bool couldBeRef = bothWaysFollowReference != null && bothWaysFollowReference.Contains(tokens.LA(3));

                    if (couldBeDef && !couldBeRef)
                    {
                        definitions.Add(tokens.LT(2));
                    }
                    else if (couldBeRef && !couldBeDef)
                    {
                        references.Add(tokens.LT(2));
                    }
                }

                if (tokens.LA(3) == Java2Lexer.IDENTIFIER && _definitionSourceSet.Contains(tokens.LA(2)))
                {
                    IntervalSet sourceDefinition2;
                    IntervalSet sourceReference2;
                    _definitionSourceSet2.TryGetValue(tokens.LA(2), out sourceDefinition2);
                    _referenceSourceSet2.TryGetValue(tokens.LA(2), out sourceReference2);
                    bool couldBeDef = sourceDefinition2 != null && sourceDefinition2.Contains(tokens.LA(1));
                    bool couldBeRef = sourceReference2 != null && sourceReference2.Contains(tokens.LA(1));

                    if (couldBeDef && !couldBeRef)
                    {
                        definitions.Add(tokens.LT(3));
                    }
                    else if (couldBeRef && !couldBeDef)
                    {
                        references.Add(tokens.LT(3));
                    }
                }

                if (_definitionFollowSet.Contains(tokens.LA(1)))
                {
                    declColons.Add(tokens.LT(1));
                }

                if (tokens.LA(1) == Java2Lexer.IDENTIFIER)
                {
                    identifiers.Add(tokens.LT(1));
                }

                tokens.Consume();
            }

            foreach (var token in declColons)
            {
                tokens.Seek(token.TokenIndex);
                tokens.Consume();

                IToken potentialDeclaration = tokens.LT(-2);
                if (potentialDeclaration.Type != Java2Lexer.IDENTIFIER || definitions.Contains(potentialDeclaration) || references.Contains(potentialDeclaration))
                {
                    continue;
                }

                bool agree = false;
                NetworkInterpreter interpreter = CreateVarDeclarationNetworkInterpreter(tokens, token.Type);
                while (interpreter.TryStepBackward())
                {
                    if (interpreter.Contexts.Count == 0 || interpreter.Contexts.Count > 400)
                    {
                        break;
                    }

                    if (interpreter.Contexts.All(context => context.BoundedStart))
                    {
                        break;
                    }

                    interpreter.Contexts.RemoveAll(i => !IsConsistentWithPreviousResult(i, true, definitions, references));

                    agree = AllAgree(interpreter.Contexts, potentialDeclaration.TokenIndex);
                    if (agree)
                    {
                        break;
                    }
                }

                interpreter.CombineBoundedStartContexts();

                if (!agree)
                {
                    while (interpreter.TryStepForward())
                    {
                        if (interpreter.Contexts.Count == 0 || interpreter.Contexts.Count > 400)
                        {
                            break;
                        }

                        if (interpreter.Contexts.All(context => context.BoundedEnd))
                        {
                            break;
                        }

                        interpreter.Contexts.RemoveAll(i => !IsConsistentWithPreviousResult(i, false, definitions, references));

                        agree = AllAgree(interpreter.Contexts, potentialDeclaration.TokenIndex);
                        if (agree)
                        {
                            break;
                        }
                    }

                    interpreter.CombineBoundedEndContexts();
                }

                foreach (var context in interpreter.Contexts)
                {
                    foreach (var transition in context.Transitions)
                    {
                        if (!transition.Symbol.HasValue)
                        {
                            continue;
                        }

                        switch (transition.Symbol)
                        {
                        case Java2Lexer.IDENTIFIER:
                            //case Java2Lexer.KW_THIS:
                            RuleBinding rule = interpreter.Network.StateRules[transition.Transition.TargetState.Id];
                            if (rule.Name == JavaAtnBuilder.RuleNames.SymbolReferenceIdentifier)
                            {
                                references.Add(tokens.Get(transition.TokenIndex.Value));
                            }
                            else if (rule.Name == JavaAtnBuilder.RuleNames.SymbolDefinitionIdentifier)
                            {
                                definitions.Add(tokens.Get(transition.TokenIndex.Value));
                            }
                            break;

                        default:
                            continue;
                        }
                    }
                }
            }

            // tokens which are in both the 'definitions' and 'references' sets are actually unknown.
            HashSet <IToken> unknownIdentifiers = new HashSet <IToken>(definitions, TokenIndexEqualityComparer.Default);

            unknownIdentifiers.IntersectWith(references);
            definitions.ExceptWith(unknownIdentifiers);

#if true // set to true to mark all unknown identifiers as references (requires complete analysis of definitions)
            references = new HashSet <IToken>(identifiers, TokenIndexEqualityComparer.Default);
            references.ExceptWith(definitions);
            references.ExceptWith(unknownIdentifiers);
#else
            references.ExceptWith(unknownIdentifiers);

            // the full set of unknown identifiers are any that aren't explicitly classified as a definition or a reference
            unknownIdentifiers = new HashSet <IToken>(identifiers, TokenIndexEqualityComparer.Default);
            unknownIdentifiers.ExceptWith(definitions);
            unknownIdentifiers.ExceptWith(references);
#endif

            List <ITagSpan <IClassificationTag> > tags = new List <ITagSpan <IClassificationTag> >();

            IClassificationType definitionClassificationType = _classificationTypeRegistryService.GetClassificationType(JavaSymbolTaggerClassificationTypeNames.Definition);
            tags.AddRange(ClassifyTokens(snapshot, definitions, new ClassificationTag(definitionClassificationType)));

            IClassificationType referenceClassificationType = _classificationTypeRegistryService.GetClassificationType(JavaSymbolTaggerClassificationTypeNames.Reference);
            tags.AddRange(ClassifyTokens(snapshot, references, new ClassificationTag(referenceClassificationType)));

            IClassificationType unknownClassificationType = _classificationTypeRegistryService.GetClassificationType(JavaSymbolTaggerClassificationTypeNames.UnknownIdentifier);
            tags.AddRange(ClassifyTokens(snapshot, unknownIdentifiers, new ClassificationTag(unknownClassificationType)));

            _tags = tags;

            timer.Stop();

            IOutputWindowPane pane = OutputWindowService.TryGetPane(PredefinedOutputWindowPanes.TvlIntellisense);
            if (pane != null)
            {
                pane.WriteLine(string.Format("Finished classifying {0} identifiers in {1}ms: {2} definitions, {3} references, {4} unknown", identifiers.Count, timer.ElapsedMilliseconds, definitions.Count, references.Count, unknownIdentifiers.Count));
            }

            OnTagsChanged(new SnapshotSpanEventArgs(new SnapshotSpan(snapshot, new Span(0, snapshot.Length))));
        }
Esempio n. 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogLineColorer"/> class.
 /// </summary>
 /// <param name="registry">Classification registry.</param>
 internal LogLineColorer(IClassificationTypeRegistryService registry)
 {
     this.classificationType = registry.GetClassificationType("LogLineColorer");
 }
Esempio n. 42
0
 public void SetExplicitTextProperties(IClassificationType classificationType, TextFormattingRunProperties properties) => throw new NotImplementedException();                               //TODO:
 public void SwapPriorities(IClassificationType firstType, IClassificationType secondType) => throw new NotImplementedException();                                                           //TODO:
 private ClassificationSpan Classification(ITextSnapshot snapshot, Span span, IClassificationType classificationType)
 {
     return(new ClassificationSpan(new SnapshotSpan(snapshot, span), classificationType));
 }
        private void ColorizeKeywordLine(string keyword, GherkinBufferSpan headerSpan, IClassificationType classificationType)
        {
            RegisterKeyword(keyword, headerSpan);
            //colorize the rest
            var textSpan = new GherkinBufferSpan(
                headerSpan.StartPosition.ShiftByCharacters(keyword.Length),
                headerSpan.EndPosition);

            if (textSpan.StartPosition < textSpan.EndPosition)
            {
                ColorizeSpan(textSpan, classificationType);
            }
        }
Esempio n. 45
0
 public JadeToken(JadeTokenType type, IClassificationType classification, int start, int length)
     : base(type, start, length)
 {
     this.Classification = classification;
 }
 public OpenDocumentListTextClassifier(IClassificationType documentListMatchHighlightClassificationType) => this.documentListMatchHighlightClassificationType = documentListMatchHighlightClassificationType ?? throw new ArgumentNullException(nameof(documentListMatchHighlightClassificationType));
 /// <summary>
 /// Initializes a new instance of the <see cref="XmlDocCommentHighPriorityClassifier"/> class.
 /// </summary>
 /// <param name="registry">Classification registry.</param>
 internal XmlDocCommentHighPriorityClassifier(IClassificationTypeRegistryService registry)
 {
     this.classificationType = registry.GetClassificationType("XmlDocCommentHighPriorityClassifier");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EmplaceClassifier"/> class.
 /// </summary>
 /// <param name="registry">Classification registry.</param>
 internal EmplaceClassifier(IClassificationTypeRegistryService registry)
 {
     this.classificationType = registry.GetClassificationType("EmplaceClassifier");
 }
Esempio n. 49
0
 internal UnderlineClassifier(ITextView textView, IClassificationType classificationType)
 {
     _textView           = textView;
     _classificationType = classificationType;
     _underlineSpan      = null;
 }
Esempio n. 50
0
 IGlyphTextMethodMarker IGlyphTextMarkerService.AddMarker(ModuleTokenId tokenId, uint ilOffset, ImageReference?glyphImage, string markerTypeName, string selectedMarkerTypeName, IClassificationType classificationType, int zIndex, object tag, IGlyphTextMarkerHandler handler, Func <ITextView, bool> textViewFilter) =>
 AddMarker(tokenId.Module, tokenId.Token, ilOffset, glyphImage, markerTypeName, selectedMarkerTypeName, classificationType, zIndex, tag, handler, textViewFilter);
Esempio n. 51
0
 public void Write(IClassificationType classificationType, string text) => Add(classificationType, text);
Esempio n. 52
0
        IGlyphTextDotNetTokenMarker AddMarker(ModuleId module, uint token, ImageReference?glyphImage, string markerTypeName, string selectedMarkerTypeName, IClassificationType classificationType, int zIndex, object tag, IGlyphTextMarkerHandler handler, Func <ITextView, bool> textViewFilter)
        {
            var marker = new GlyphTextDotNetTokenMarker(module, token, glyphImage, markerTypeName, selectedMarkerTypeName, classificationType, zIndex, tag, handler, textViewFilter);

            glyphTextMarkers.Add(marker);
            MarkerAdded?.Invoke(this, new GlyphTextMarkerAddedEventArgs(marker));
            return(marker);
        }
Esempio n. 53
0
 void Initialize_UI(Lazy <IClassificationTypeRegistryService> classificationTypeRegistryService)
 {
     classificationTypeCurrentStatement = classificationTypeRegistryService.Value.GetClassificationType(ThemeClassificationTypeNames.CurrentStatement);
     classificationTypeCallReturn       = classificationTypeRegistryService.Value.GetClassificationType(ThemeClassificationTypeNames.CallReturn);
 }
Esempio n. 54
0
        public IGlyphTextMarker AddMarker(GlyphTextMarkerLocationInfo location, ImageReference?glyphImage, string markerTypeName, string selectedMarkerTypeName, IClassificationType classificationType, int zIndex, object tag, IGlyphTextMarkerHandler handler, Func <ITextView, bool> textViewFilter)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }
            switch (location)
            {
            case DotNetMethodBodyGlyphTextMarkerLocationInfo bodyLoc:
                return(AddMarker(bodyLoc.Module, bodyLoc.Token, bodyLoc.ILOffset, glyphImage, markerTypeName, selectedMarkerTypeName, classificationType, zIndex, tag, handler, textViewFilter));

            case DotNetTokenGlyphTextMarkerLocationInfo tokenLoc:
                return(AddMarker(tokenLoc.Module, tokenLoc.Token, glyphImage, markerTypeName, selectedMarkerTypeName, classificationType, zIndex, tag, handler, textViewFilter));

            default:
                throw new InvalidOperationException();
            }
        }
 public CompletionClassifier(IThemeClassificationTypeService themeClassificationTypeService)
 {
     this.themeClassificationTypeService = themeClassificationTypeService ?? throw new ArgumentNullException(nameof(themeClassificationTypeService));
     punctuationClassificationType       = themeClassificationTypeService.GetClassificationType(TextColor.Punctuation);
 }
Esempio n. 56
0
 public GlyphTextDotNetTokenMarker(ModuleId module, uint token, ImageReference?glyphImage, string markerTypeName, string selectedMarkerTypeName, IClassificationType classificationType, int zIndex, object tag, IGlyphTextMarkerHandler handler, Func <ITextView, bool> textViewFilter)
 {
     Module = module;
     Token  = token;
     GlyphImageReference    = glyphImage == null || glyphImage.Value.IsDefault ? null : glyphImage;
     MarkerTypeName         = markerTypeName;
     SelectedMarkerTypeName = selectedMarkerTypeName;
     ClassificationType     = classificationType;
     ZIndex         = zIndex;
     Tag            = tag;
     Handler        = handler ?? NullGlyphTextMarkerHandler.Instance;
     TextViewFilter = textViewFilter ?? defaultTextViewFilter;
 }
Esempio n. 57
0
 public int Compare(IClassificationType x, IClassificationType y) => GetOrder(y) - GetOrder(x);
Esempio n. 58
0
        /// <summary>
        /// This method scans the given SnapshotSpan for potential matches for this classification.
        /// In this instance, it classifies everything and returns each span as a new ClassificationSpan.
        /// </summary>
        /// <param name="trackingSpan">The span currently being classified</param>
        /// <returns>A list of ClassificationSpans that represent spans identified to be of this classification</returns>
        public IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            var classifications = new List <ClassificationSpan>();

            var text = span.GetText();

            var commentIndex = text.IndexOf('#');

            if (commentIndex >= 0)
            {
                classifications.Add(
                    new ClassificationSpan(
                        new SnapshotSpan(
                            span.Snapshot,
                            new Span(span.Start + commentIndex, span.Length - commentIndex)
                            ),
                        _comment
                        )
                    );

                text = text.Substring(0, commentIndex);
            }

            var match = Regex.Match(text, @"^( *(\t+))+");

            if (match.Success)
            {
                foreach (Capture capture in match.Groups[2].Captures)
                {
                    classifications.Add(
                        new ClassificationSpan(
                            new SnapshotSpan(
                                span.Snapshot,
                                new Span(span.Start + capture.Index, capture.Length)
                                ),
                            _tab
                            )
                        );
                }
            }

            try
            {
                var scanner = new Scanner(new StringReader(text));

                Type previousTokenType = null;
                while (scanner.MoveNext())
                {
                    IClassificationType classificationType = null;

                    var currentTokenType = scanner.Current.GetType();
                    var tokenLength      = scanner.Current.End.Index - scanner.Current.Start.Index;

                    if (currentTokenType == typeof(Anchor))
                    {
                        classificationType = _anchor;
                    }
                    else if (currentTokenType == typeof(AnchorAlias))
                    {
                        classificationType = _alias;
                    }
                    else if (currentTokenType == typeof(Scalar))
                    {
                        if (previousTokenType == typeof(Key))
                        {
                            classificationType = _key;
                        }
                        else
                        {
                            // Decode the scalar
                            var scalarToken = (Scalar)scanner.Current;
                            var scalar      = new Core.Yaml.Events.Scalar(scalarToken.Value);
                            switch (schema.GetDefaultTag(scalar))
                            {
                            case JsonSchema.BoolShortTag:
                                classificationType = _bool;
                                break;

                            case JsonSchema.FloatShortTag:
                            case JsonSchema.IntShortTag:
                                classificationType = _number;
                                break;

                            case SchemaBase.StrShortTag:
                                classificationType = scalarToken.Style == ScalarStyle.DoubleQuoted || scalarToken.Style == ScalarStyle.SingleQuoted ? _string : _value;
                                break;

                            default:
                                classificationType = _value;
                                break;
                            }
                        }
                    }
                    else if (currentTokenType == typeof(Tag))
                    {
                        classificationType = _tag;
                    }
                    else if (currentTokenType == typeof(TagDirective))
                    {
                        classificationType = _directive;
                    }
                    else if (currentTokenType == typeof(VersionDirective))
                    {
                        classificationType = _directive;
                    }
                    else if (tokenLength > 0)
                    {
                        classificationType = _symbol;
                    }

                    previousTokenType = currentTokenType;

                    if (classificationType != null && tokenLength > 0)
                    {
                        classifications.Add(
                            new ClassificationSpan(
                                new SnapshotSpan(
                                    span.Snapshot,
                                    new Span(span.Start + scanner.Current.Start.Index, tokenLength)
                                    ),
                                classificationType
                                )
                            );
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Exception in AssetObjectEditor " + ex);
            }

            return(classifications);
        }
Esempio n. 59
0
        public ITagSpan <RainbowTag> ToSpan(ITextSnapshot snapshot, IClassificationType type)
        {
            var span = new SnapshotSpan(snapshot, Position, 1);

            return(new TagSpan <RainbowTag>(span, new RainbowTag(type)));
        }
Esempio n. 60
0
        /// <summary>
        /// This method scans the given SnapshotSpan for potential matches for this classification.
        /// In this instance, it classifies everything and returns each span as a new ClassificationSpan.
        /// </summary>
        /// <param name="trackingSpan">The span currently being classified</param>
        /// <returns>A list of ClassificationSpans that represent spans identified to be of this classification</returns>
        public IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            var classifications = new List <ClassificationSpan>();

            var text = span.GetText();

            var commentIndex = text.IndexOf('#');

            if (commentIndex >= 0)
            {
                classifications.Add(
                    new ClassificationSpan(
                        new SnapshotSpan(
                            span.Snapshot,
                            new Span(span.Start + commentIndex, span.Length - commentIndex)
                            ),
                        _comment
                        )
                    );

                text = text.Substring(0, commentIndex);
            }

            var match = Regex.Match(text, @"^( *(\t+))+");

            if (match.Success)
            {
                foreach (Capture capture in match.Groups[2].Captures)
                {
                    classifications.Add(
                        new ClassificationSpan(
                            new SnapshotSpan(
                                span.Snapshot,
                                new Span(span.Start + capture.Index, capture.Length)
                                ),
                            _tab
                            )
                        );
                }
            }

            try
            {
                var scanner = new Scanner(new StringReader(text));

                Type previousTokenType = null;
                while (scanner.MoveNext())
                {
                    IClassificationType classificationType = null;

                    var currentTokenType = scanner.Current.GetType();
                    var tokenLength      = scanner.Current.End.Index - scanner.Current.Start.Index;

                    if (currentTokenType == typeof(Anchor))
                    {
                        classificationType = _anchor;
                    }
                    else if (currentTokenType == typeof(AnchorAlias))
                    {
                        classificationType = _alias;
                    }
                    else if (currentTokenType == typeof(Scalar))
                    {
                        classificationType = previousTokenType == typeof(Key) ? _key : _value;
                    }
                    else if (currentTokenType == typeof(Tag))
                    {
                        classificationType = _tag;
                    }
                    else if (currentTokenType == typeof(TagDirective))
                    {
                        classificationType = _directive;
                    }
                    else if (currentTokenType == typeof(VersionDirective))
                    {
                        classificationType = _directive;
                    }
                    else if (tokenLength > 0)
                    {
                        classificationType = _symbol;
                    }

                    previousTokenType = currentTokenType;

                    if (classificationType != null)
                    {
                        classifications.Add(
                            new ClassificationSpan(
                                new SnapshotSpan(
                                    span.Snapshot,
                                    new Span(span.Start + scanner.Current.Start.Index, tokenLength)
                                    ),
                                classificationType
                                )
                            );
                    }
                }
            }
            catch
            {
            }

            return(classifications);
        }