public SignatureHelpCurrentParameterTaggerEx(ITextBuffer buffer, ClassificationTag signatureHelpDocumentationClassificationTag, ClassificationTag signatureHelpParameterClassificationTag, ClassificationTag signatureHelpParameterDocumentationClassificationTag) { this.buffer = buffer ?? throw new ArgumentNullException(nameof(buffer)); this.signatureHelpDocumentationClassificationTag = signatureHelpDocumentationClassificationTag ?? throw new ArgumentNullException(nameof(signatureHelpDocumentationClassificationTag)); this.signatureHelpParameterClassificationTag = signatureHelpParameterClassificationTag ?? throw new ArgumentNullException(nameof(signatureHelpParameterClassificationTag)); this.signatureHelpParameterDocumentationClassificationTag = signatureHelpParameterDocumentationClassificationTag ?? throw new ArgumentNullException(nameof(signatureHelpParameterDocumentationClassificationTag)); }
private ITagSpan <IClassificationTag> CreateClassificationTagSpan(TextSpan span, SyntaxNode node, IClassificationType classificationType) { var snapshotSpan = new SnapshotSpan(_snapshot, span.Start, span.Length); var classificationTag = new ClassificationTag(classificationType); return(new TagSpan <ClassificationTag>(snapshotSpan, classificationTag)); }
SignatureHelpCurrentParameterTaggerProvider(IClassificationTypeRegistryService classificationTypeRegistryService) { signatureHelpDocumentationClassificationTag = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.SignatureHelpDocumentation)); signatureHelpCurrentParameterClassificationTag = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.SignatureHelpCurrentParameter)); signatureHelpParameterClassificationTag = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.SignatureHelpParameter)); signatureHelpParameterDocumentationClassificationTag = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.SignatureHelpParameterDocumentation)); }
public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans) { var syntaxTreeAndSnapshot = ParserService.SyntaxTreeAndSnapshot; if (syntaxTreeAndSnapshot == null) { yield break; } foreach (var span in spans) { var extent = TextExtent.FromBounds(span.Start.Position, span.End.Position); var result = SyntaxClassifier.Classify(syntaxTreeAndSnapshot.SyntaxTree.Root, extent); foreach (var classifiedExtent in result) { _classificationMap.TryGetValue(classifiedExtent.Classification, out var ct); if (ct == null) { continue; } var tokenSpan = new SnapshotSpan(syntaxTreeAndSnapshot.Snapshot, new Span(classifiedExtent.Extent.Start, classifiedExtent.Extent.Length)); var tagSpan = tokenSpan.TranslateTo(span.Snapshot, SpanTrackingMode.EdgeExclusive); var tag = new ClassificationTag(ct); yield return(new TagSpan <IClassificationTag>(tagSpan, tag)); } } }
public Color this[ClassificationTag tag] { get { int idx = (int)tag; return(_colors[idx].Color); } }
protected override ITagSpan <IClassificationTag> CreateTagSpan(ITextSnapshot snapshot, TextSpan rawTag) { var snapshotSpan = new SnapshotSpan(snapshot, rawTag.Start, rawTag.Length); var classification = _classificationService.Unnecessary; var tag = new ClassificationTag(classification); return(new TagSpan <IClassificationTag>(snapshotSpan, tag)); }
/// <summary> /// Builds and setup a new instance of ClassifiedToken. /// </summary> /// <param name="text">The text in this token.</param> /// <param name="tag">The smState tag.</param> /// <param name="indexStart">Starting startingPosition of the string from the beginning of the text.</param> /// <param name="lineIndex">The line startingPosition.</param> public ConcreteToken(string text, ClassificationTag tag, int indexStart, int lineIndex) { _text = text; _tag = tag; _indexStart = indexStart; _lineIndex = lineIndex; return; }
protected override ITagSpan <IClassificationTag> CreateTagSpan(ITextSnapshot snapshot, SyntaxClassificationSpan rawTag) { var span = rawTag.Span; var snapshotSpan = new SnapshotSpan(snapshot, span.Start, span.Length); var type = GetClassificationType(rawTag.Classification); var tag = new ClassificationTag(type); return(new TagSpan <IClassificationTag>(snapshotSpan, tag)); }
public static void InitTags(IClassificationTypeRegistryService service) { if (inited) { return; } InitColors(); CTag = new ClassificationTag(service.GetClassificationType("CType")); LuaFrameworkTag = new ClassificationTag(service.GetClassificationType("LuaFrameworkType")); if (UserColors != null && UserColors.Count > 0) { UserTags = new List <ClassificationTag>(UserColors.Count); int count = UserColors.Count; if (count > 15) { count = 15; } for (int i = 0; i < count; i++) { UserTags.Add(new ClassificationTag(service.GetClassificationType(string.Format("UserKeyword{0}", i)))); } } OtherTags = new Dictionary <Irony.Parsing.TokenType, ClassificationTag>(); OtherTags[Irony.Parsing.TokenType.Text] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Character)); OtherTags[Irony.Parsing.TokenType.Keyword] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Keyword)); OtherTags[Irony.Parsing.TokenType.Identifier] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Identifier)); OtherTags[Irony.Parsing.TokenType.String] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.String)); OtherTags[Irony.Parsing.TokenType.Literal] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Number)); OtherTags[Irony.Parsing.TokenType.Operator] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Operator)); //OtherTags[Irony.Parsing.TokenType.LineComment] = new ClassificationTag(service.GetClassificationType( PredefinedClassificationTypeNames.Comment)); OtherTags[Irony.Parsing.TokenType.Comment] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Comment)); if (FunctionColor != default(Color)) { LuaFunctionTag = new ClassificationTag(service.GetClassificationType("LuaFunction")); } else { LuaFunctionTag = OtherTags[Irony.Parsing.TokenType.Identifier]; } if (TableColor != default(Color)) { LuaTableTag = new ClassificationTag(service.GetClassificationType("LuaTable")); } else { LuaTableTag = OtherTags[Irony.Parsing.TokenType.Identifier]; } inited = true; }
internal OneSClassifier(IClassificationTypeRegistryService registry, ITextBuffer buffer) { this.m_registry = registry; this.classificationType = registry.GetClassificationType("OneSClassifier"); this._buffer = buffer; this._outerParenTag = this.MakeTag("OneSError"); this.snapshot = buffer.CurrentSnapshot; this.regions = new List <OneSClassifier.Region>(); BufferIdleEventUtil.AddBufferIdleEventListener(this._buffer, new EventHandler(this.ReParse)); }
public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans) { var context = buffer.TryGetSignatureHelpClassifierContext(); Debug.Assert(context != null); if (context == null || context.Session.IsDismissed) { yield break; } if (context.Type == SignatureHelpClassifierContextTypes.ParameterName) { var paramContext = (ParameterNameSignatureHelpClassifierContext)context; var parameter = paramContext.Parameter as Parameter; if (parameter?.Name != null) { var snapshot = buffer.CurrentSnapshot; var span = new Span(paramContext.NameOffset, parameter.Name.Length); Debug.Assert(span.End <= snapshot.Length); if (span.End > snapshot.Length) { yield break; } var tag = new ClassificationTag(themeClassificationTypeService.GetClassificationType(TextColor.Parameter)); yield return(new TagSpan <IClassificationTag>(new SnapshotSpan(snapshot, span), tag)); } } else if (context.Type == SignatureHelpClassifierContextTypes.ParameterDocumentation) { var paramContext = (ParameterDocumentationSignatureHelpClassifierContext)context; var parameter = paramContext.Parameter as Parameter; if (parameter != null) { var snapshot = buffer.CurrentSnapshot; var snapshotLength = snapshot.Length; int pos = 0; foreach (var taggedText in parameter.DocumentationTaggedText) { var span = new Span(pos, taggedText.Text.Length); Debug.Assert(span.End <= snapshotLength); if (span.End > snapshotLength) { yield break; } var color = TextTagsHelper.ToTextColor(taggedText.Tag); var tag = new ClassificationTag(themeClassificationTypeService.GetClassificationType(color)); yield return(new TagSpan <IClassificationTag>(new SnapshotSpan(snapshot, span), tag)); pos = span.End; } Debug.Assert(pos == parameter.Documentation.Length); } } }
static void InitHeaderClassificationTypes() { var r = ServicesHelper.Instance.ClassificationTypeRegistry; _HeaderClassificationTypes[1] = new ClassificationTag(r.GetClassificationType(Constants.MarkdownHeading1)); _HeaderClassificationTypes[2] = new ClassificationTag(r.GetClassificationType(Constants.MarkdownHeading2)); _HeaderClassificationTypes[3] = new ClassificationTag(r.GetClassificationType(Constants.MarkdownHeading3)); _HeaderClassificationTypes[4] = new ClassificationTag(r.GetClassificationType(Constants.MarkdownHeading4)); _HeaderClassificationTypes[5] = new ClassificationTag(r.GetClassificationType(Constants.MarkdownHeading5)); _HeaderClassificationTypes[6] = new ClassificationTag(r.GetClassificationType(Constants.MarkdownHeading6)); }
internal FormattingTags(IClassificationTypeRegistryService registry) { this.SyntaxKeyword = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.KeyWord.Key)); this.SyntaxOperator = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Operator.Key)); this.SyntaxNumber = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Number.Key)); this.SyntaxPunctuation = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Punctuation.Key)); this.SyntaxComment = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Syntax.Comment.Key)); this.Preprocessor = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Preprocessor.Key)); this.PreprocessorText = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Preprocessor.Text.Key)); this.Type = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Key)); this.TypeModule = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Module.Key)); this.TypeClass = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Class.Key)); //this.TypeClassAttribute = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Class.Attribute.Key)); this.TypeStructure = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Structure.Key)); this.TypeInterface = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Interface.Key)); this.TypeDelegate = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Delegate.Key)); this.TypeGeneric = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Generic.Key)); this.TypeDynamic = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Type.Dynamic.Key)); this.Enum = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Enum.Key)); this.EnumMember = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Enum.Member.Key)); this.String = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.Key)); this.StringToken = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.Token.Key)); this.StringSingleQuote = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.SingleQuotes.Key)); this.StringInterpolated = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.String.Interpolated.Key)); this.Variable = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Variable.Key)); //this.VariableMutated = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Variable.Mutated.Key)); this.Param = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Param.Key)); //this.ParamMutated = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Param.Mutated.Key)); this.Method = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Key)); this.MethodConstructor = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Constructor.Key)); this.MethodStatic = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Static.Key)); this.MethodVirtual = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Virtual.Key)); this.MethodExtension = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.Extension.Key)); this.MethodUserDefinedOperator = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.UserDefinedOperator.Key)); this.MethodInterfaceImplementation = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Method.InterfaceImplementation.Key)); this.Identifier = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Key)); this.IdentifierNamespace = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Namespace.Key)); this.IdentifierAttribute = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Attribute.Key)); this.IdentifierConst = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Constant.Key)); this.IdentifierField = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Field.Key)); this.IdentifierProperty = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Property.Key)); this.IdentifierPropertyInterfaceImplementation = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Property.InterfaceImplementation.Key)); this.IdentifierEvent = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Event.Key)); this.IdentifierLabel = new ClassificationTag(registry.GetClassificationType(FormatDefinitions.Identifier.Label.Key)); }
private void CreateTag(SyntaxToken token, IClassificationType classificationType) { if (token == null || !token.Span.IsInRootFile) { return; } var snapshotSpan = new SnapshotSpan(_snapshot, token.Span.Start, token.Span.Length); var tag = new ClassificationTag(classificationType); var tagSpan = new TagSpan <IClassificationTag>(snapshotSpan, tag); _results.Add(tagSpan); }
XmlTaggerClassificationTypes(IClassificationTypeRegistryService classificationTypeRegistryService) { Attribute = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlAttribute)); AttributeQuotes = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlAttributeQuotes)); AttributeValue = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlAttributeValue)); AttributeValueXaml = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlAttributeValue)); CDataSection = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlCDataSection)); Comment = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlComment)); Delimiter = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlDelimiter)); Keyword = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlKeyword)); Name = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlName)); ProcessingInstruction = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlProcessingInstruction)); Text = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlText)); }
XmlTaggerClassificationTypes(IClassificationTypeRegistryService classificationTypeRegistryService) { Attribute = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlAttribute)); AttributeQuotes = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlAttributeQuotes)); AttributeValue = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlAttributeValue)); CDataSection = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlCDataSection)); Comment = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlComment)); Delimiter = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlDelimiter)); Keyword = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlKeyword)); Name = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlName)); ProcessingInstruction = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlProcessingInstruction)); Text = new ClassificationTag(classificationTypeRegistryService.GetClassificationType(ThemeClassificationTypeNames.XmlText)); }
public static void InitTags(IClassificationTypeRegistryService service) { if (inited) return; InitColors(); if (UserColors != null && UserColors.Count > 0) { UserTags = new List<ClassificationTag>(UserColors.Count); int count = UserColors.Count; if (count > 15) count = 15; for (int i = 0; i < count; i++) { UserTags.Add(new ClassificationTag(service.GetClassificationType(string.Format("UserKeyword{0}", i)))); } } OtherTags = new Dictionary<Irony.Parsing.TokenType, ClassificationTag>(); OtherTags[Irony.Parsing.TokenType.Text] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Character)); OtherTags[Irony.Parsing.TokenType.Keyword] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Keyword)); OtherTags[Irony.Parsing.TokenType.Identifier] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Identifier)); OtherTags[Irony.Parsing.TokenType.String] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.String)); OtherTags[Irony.Parsing.TokenType.Literal] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Number)); OtherTags[Irony.Parsing.TokenType.Operator] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Operator)); OtherTags[Irony.Parsing.TokenType.Comment] = new ClassificationTag(service.GetClassificationType(PredefinedClassificationTypeNames.Comment)); if (FunctionColor != default(Color)) { LuaFunctionTag = new ClassificationTag(service.GetClassificationType("LuaFunction")); } else { LuaFunctionTag = OtherTags[Irony.Parsing.TokenType.Identifier]; } if (TableColor != default(Color)) { LuaTableTag = new ClassificationTag(service.GetClassificationType("LuaTable")); } else { LuaTableTag = OtherTags[Irony.Parsing.TokenType.Identifier]; } inited = true; }
private void AddTags(List <KeyValuePair <ITrackingSpan, IClassificationTag> > intermediateContainer, ITextSnapshot sourceSnapshot, ITextSnapshot currentSnapshot, List <IToken> tokens, IClassificationType classificationType) { IClassificationTag tag = new ClassificationTag(classificationType); foreach (IToken token in tokens) { int startIndex = token.StartIndex; int stopIndex = token.StopIndex; if (startIndex < 0 || stopIndex < 0 || (startIndex > stopIndex + 1)) { continue; } ITrackingSpan trackingRegion = sourceSnapshot.CreateTrackingSpan(Span.FromBounds(startIndex, stopIndex + 1), SpanTrackingMode.EdgePositive); intermediateContainer.Add(new KeyValuePair <ITrackingSpan, IClassificationTag>(trackingRegion, tag)); } }
public SignatureHelpCurrentParameterTagger(ISignatureHelpSession session, ITextBuffer buffer, ClassificationTag signatureHelpCurrentParameterClassificationTag) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } if (signatureHelpCurrentParameterClassificationTag == null) { throw new ArgumentNullException(nameof(signatureHelpCurrentParameterClassificationTag)); } this.session = session; this.buffer = buffer; this.signatureHelpCurrentParameterClassificationTag = signatureHelpCurrentParameterClassificationTag; }
private void MapValues(ClassificationCategory target, ClassificationCategory source) { target.Name = source.Name; target.ClassificationCategoryTypeId = source.ClassificationCategoryTypeId; target.RangeMax = source.RangeMax; target.RangeMin = source.RangeMin; target.Tags = target.Tags ?? new List <ClassificationTag>(); // Remove tags that are not in source for (int i = target.Tags.Count - 1; i >= 0; i--) { var tag = target.Tags[i]; if (!source.Tags.Where(t => t.Id == tag.Id).Any()) { target.Tags.RemoveAt(i); } } // Map Tags foreach (ClassificationTag sourceTag in source.Tags) { ClassificationTag targetTag = target.Tags.Where(t => !string.IsNullOrWhiteSpace(sourceTag.Id) && t.Id == sourceTag.Id).SingleOrDefault(); if (targetTag == null) { targetTag = _categoryService.CreateNewTag(); target.Tags.Add(targetTag); } else { targetTag.ModifiedDate = DateTime.UtcNow; } targetTag.Name = sourceTag.Name; } target.Tags.Sort(); }
public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans) { var signature = session.SelectedSignature as Signature; if (signature == null) { yield break; } var usePrettyPrintedContent = buffer.GetUsePrettyPrintedContent(); var snapshot = buffer.CurrentSnapshot; var snapshotLength = snapshot.Length; bool lenOk = usePrettyPrintedContent ? snapshotLength == signature.PrettyPrintedContent.Length : snapshotLength == signature.Content.Length; Debug.Assert(lenOk); if (!lenOk) { yield break; } int pos = 0; var taggedTextColl = usePrettyPrintedContent ? signature.PrettyPrintedContentTaggedText : signature.ContentTaggedText; foreach (var taggedText in taggedTextColl) { var span = new Span(pos, taggedText.Text.Length); Debug.Assert(span.End <= snapshotLength); if (span.End > snapshotLength) { yield break; } var color = TextTagsHelper.ToTextColor(taggedText.Tag); var tag = new ClassificationTag(themeClassificationTypeService.GetClassificationType(color)); yield return(new TagSpan <IClassificationTag>(new SnapshotSpan(snapshot, span), tag)); pos = span.End; } Debug.Assert(usePrettyPrintedContent ? pos == signature.PrettyPrintedContent.Length : pos == signature.Content.Length); }
internal override bool TryGetNewTags( WorkspaceDocument <ITextBuffer> document, ITextSnapshot textSnapshot, out ImmutableArray <ITagSpan <IClassificationTag> > tags) { var tokensBuilder = ImmutableArray.CreateBuilder <ITagSpan <IClassificationTag> >(); foreach (var token in document.GetFileTokens()) { // TODO: per token. var classificationType = this.classificationTypeRegistry.GetClassificationType(token.Type.ToClassificationTypeName()); var tag = new ClassificationTag(classificationType); tokensBuilder.Add( new TagSpan <IClassificationTag>(new SnapshotSpan( textSnapshot, Span.FromBounds(Math.Max(0, token.Pos - 1), token.End)), tag)); } tags = tokensBuilder.ToImmutable(); return(true); }
private ITagSpan<IClassificationTag> CreateClassificationTagSpan(LocatedNode node, IClassificationType classificationType) { var snapshotSpan = new SnapshotSpan(_snapshot, node.Span.Start, node.Span.Length); var classificationTag = new ClassificationTag(classificationType); return new TagSpan<ClassificationTag>(snapshotSpan, classificationTag); }
public void Setup(string text, ClassificationTag tag) { _text = text; _tag = tag; }
internal static void Update(ISymbol symbol, ClassificationTag classificationType) { _Bookmarks[new BookmarkedSymbol(symbol)] = classificationType; }
void AddTag(int startIndex, int length, ClassificationTag tag) { var sspan = new SnapshotSpan(_file.TextSnapshot, new Span(startIndex, length)); _results.Add(new TagSpan <ClassificationTag>(sspan, tag)); }
static ITagSpan <IClassificationTag> CreateClassificationSpan(ITextSnapshot snapshotSpan, TextSpan span, ClassificationTag tag) { return(new TagSpan <IClassificationTag>(new SnapshotSpan(snapshotSpan, span.Start, span.Length), tag)); }
public Pen GetPen(ClassificationTag tag) { return (_colors[(int)tag].Pen); }
public TestClassifier(TestClassifierProvider provider) { _keyword = new ClassificationTag(provider.ClassificationTypeRegistryService.GetClassificationType("keyword")); }
public Brush GetBrush(ClassificationTag tag) { return (_colors[(int)tag].Brush); }
public Pen GetPen(ClassificationTag tag) { return(_colors[(int)tag].Pen); }
/// <summary> /// Tests whether or not the given lineIndex and tag are compatible with /// the ones in the current Token. /// </summary> /// <param name="lineIndex">A line startingPosition.</param> /// <param name="tag">A smState tag.</param> /// <returns>A boolean that says whether these data are compatible.</returns> public bool CanMerge(int lineIndex, ClassificationTag tag) { return (_tag == tag && _lineIndex == lineIndex); }
private void CreateTag(SyntaxToken token, IClassificationType classificationType) { if (token == null || !token.Span.IsInRootFile) return; var snapshotSpan = new SnapshotSpan(_snapshot, token.Span.Start, token.Span.Length); var tag = new ClassificationTag(classificationType); var tagSpan = new TagSpan<IClassificationTag>(snapshotSpan, tag); _results.Add(tagSpan); }
public RegexTag(Regex pattern, ClassificationTag tag, bool isPredominant = false) { this.Pattern = pattern; this.Tag = tag; this.IsPredominant = isPredominant; }
/// <summary> /// Tests whether or not the given lineIndex and tag are compatible with /// the ones in the current Token. /// </summary> /// <param name="lineIndex">A line startingPosition.</param> /// <param name="tag">A smState tag.</param> /// <returns>A boolean that says whether these data are compatible.</returns> public bool CanMerge(int lineIndex, ClassificationTag tag) { return(_tag == tag && _lineIndex == lineIndex); }
protected virtual TaggedContentSpan TagComments(SnapshotSpan snapshotSpan, IMappingTagSpan <IClassificationTag> tagSpan) { // find spans that the language service has already classified as comments ... if (IsComment(tagSpan.Tag.ClassificationType) == false) { return(null); } var text = snapshotSpan.GetText(); //NOTE: markup comment span does not include comment start token var endOfCommentStartToken = GetCommentStartIndex(text); if (endOfCommentStartToken < 0) { return(null); } var tl = text.Length; var commentStart = endOfCommentStartToken; while (commentStart < tl) { if (Char.IsWhiteSpace(text[commentStart])) { ++commentStart; } else { break; } } var contentEnd = GetCommentEndIndex(text); ClassificationTag ctag = null; CommentLabel label = null; var contentStart = 0; foreach (var item in Config.Instance.Labels) { var c = commentStart + item.LabelLength; if (c >= tl || text.IndexOf(item.Label, commentStart, item.Comparison) != commentStart) { continue; } var followingChar = text[c]; if (item.AllowPunctuationDelimiter && Char.IsPunctuation(followingChar)) { c++; } else if (!Char.IsWhiteSpace(followingChar)) { continue; } if (label == null || label.LabelLength < item.LabelLength) { ctag = __CommentClassifications[(int)item.StyleID]; label = item; contentStart = c; } } if (contentStart == 0 || ctag == null) { return(null); } // ignore whitespaces in content while (contentStart < tl) { if (Char.IsWhiteSpace(text[contentStart])) { ++contentStart; } else { break; } } while (contentEnd > contentStart) { if (Char.IsWhiteSpace(text[contentEnd - 1])) { --contentEnd; } else { break; } } return(label.StyleApplication == CommentStyleApplication.Tag ? new TaggedContentSpan(snapshotSpan.Snapshot, ctag, snapshotSpan.Start + commentStart, label.LabelLength, contentStart - commentStart, contentEnd - contentStart) : label.StyleApplication == CommentStyleApplication.Content ? new TaggedContentSpan(snapshotSpan.Snapshot, ctag, snapshotSpan.Start + contentStart, contentEnd - contentStart, 0, contentEnd - contentStart) : new TaggedContentSpan(snapshotSpan.Snapshot, ctag, snapshotSpan.Start + commentStart, contentEnd - commentStart, contentStart - commentStart, contentEnd - contentStart)); }
public RegexTag(string pattern, ClassificationTag tag, bool isPredominant = false) : this(new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled), tag, isPredominant) { }
public Brush GetBrush(ClassificationTag tag) { return(_colors[(int)tag].Brush); }
public Color this[ClassificationTag tag] { get { int idx = (int)tag; return (_colors[idx].Color); } }
protected virtual IEnumerable <ITagSpan <IClassificationTag> > GetTags(SnapshotSpan span, ClassificationTag tag) { yield return(new TagSpan <IClassificationTag>(span, tag)); }