public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { ITextSnapshot snapshot = _buffer.CurrentSnapshot; ITrackingPoint triggerPoint = session.GetTriggerPoint(_buffer); SnapshotPoint point = triggerPoint.GetPoint(snapshot); SyntaxTree syntax = snapshot.GetSyntaxTree(); RobotsTxtDocumentSyntax root = syntax.Root as RobotsTxtDocumentSyntax; applicableToSpan = null; // find section RobotsTxtLineSyntax line = root.Records .SelectMany(r => r.Lines) .FirstOrDefault(s => s.NameToken.Span.Span.Contains(point)); if (line != null) { IClassificationFormatMap formatMap = _classificationFormatMapService.GetClassificationFormatMap(session.TextView); string fieldName = line.NameToken.Value; // get glyph var glyph = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic); var classificationType = _classificationRegistry.GetClassificationType("RobotsTxt/RecordName"); var format = formatMap.GetTextProperties(classificationType); // construct content ISemanticModel model = syntax.GetSemanticModel(); var field = model.GetFieldSymbol(line); var content = new QuickInfoContent { Glyph = glyph, Signature = new Run(field.Name) { Foreground = format.ForegroundBrush }, Documentation = RobotsTxtDocumentation.GetDocumentation(field), }; // add to session quickInfoContent.Add( new ContentPresenter { Content = content, ContentTemplate = Template, } ); applicableToSpan = snapshot.CreateTrackingSpan(line.NameToken.Span.Span, SpanTrackingMode.EdgeInclusive); return; } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) { ITextSnapshot snapshot = _buffer.CurrentSnapshot; ITrackingPoint triggerPoint = session.GetTriggerPoint(_buffer); SnapshotPoint point = triggerPoint.GetPoint(snapshot); SyntaxTree syntax = snapshot.GetSyntaxTree(); RobotsTxtDocumentSyntax root = syntax.Root as RobotsTxtDocumentSyntax; applicableToSpan = null; // find section RobotsTxtLineSyntax line = root.Records .SelectMany(r => r.Lines) .FirstOrDefault(s => s.NameToken.Span.Span.Contains(point)); if (line != null) { IClassificationFormatMap formatMap = _classificationFormatMapService.GetClassificationFormatMap(session.TextView); string fieldName = line.NameToken.Value; // get glyph var glyph = _glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic); var classificationType = _classificationRegistry.GetClassificationType("RobotsTxt/RecordName"); var format = formatMap.GetTextProperties(classificationType); // construct content ISemanticModel model = syntax.GetSemanticModel(); var field = model.GetFieldSymbol(line); var content = new QuickInfoContent { Glyph = glyph, Signature = new Run(field.Name) { Foreground = format.ForegroundBrush }, Documentation = RobotsTxtDocumentation.GetDocumentation(field), }; // add to session quickInfoContent.Add( new ContentPresenter { Content = content, ContentTemplate = Template, } ); applicableToSpan = snapshot.CreateTrackingSpan(line.NameToken.Span.Span, SpanTrackingMode.EdgeInclusive); return; } }