private async Task AddTagSpansAsync( TaggerContext <NavigableHighlightTag> context, Solution solution, DocumentHighlights documentHighlights) { var cancellationToken = context.CancellationToken; var document = documentHighlights.Document; var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); var textSnapshot = text.FindCorrespondingEditorTextSnapshot(); if (textSnapshot == null) { // There is no longer an editor snapshot for this document, so we can't care about the // results. return; } foreach (var span in documentHighlights.HighlightSpans) { var tag = GetTag(span); context.AddTag(new TagSpan <NavigableHighlightTag>( textSnapshot.GetSpan(Span.FromBounds(span.TextSpan.Start, span.TextSpan.End)), tag)); } }
private static async Task AddTagSpansAsync( TaggerContext <NavigableHighlightTag> context, DocumentHighlights documentHighlights) { var cancellationToken = context.CancellationToken; var document = documentHighlights.Document; var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); var textSnapshot = text.FindCorrespondingEditorTextSnapshot(); if (textSnapshot == null) { // There is no longer an editor snapshot for this document, so we can't care about the // results. return; } try { foreach (var span in documentHighlights.HighlightSpans) { var tag = GetTag(span); context.AddTag(new TagSpan <NavigableHighlightTag>( textSnapshot.GetSpan(Span.FromBounds(span.TextSpan.Start, span.TextSpan.End)), tag)); } } catch (Exception e) when(FatalError.ReportAndCatchUnlessCanceled(e)) { // report NFW and continue. // also, rather than return partial results, return nothing context.ClearTags(); } }
private static void AddTagSpans( TaggerContext <NavigableHighlightTag> context, DocumentHighlights documentHighlights, CancellationToken cancellationToken) { var document = documentHighlights.Document; var textSnapshot = context.SpansToTag.FirstOrDefault(s => s.Document == document).SnapshotSpan.Snapshot; if (textSnapshot == null) { // There is no longer an editor snapshot for this document, so we can't care about the // results. return; } try { foreach (var span in documentHighlights.HighlightSpans) { var tag = GetTag(span); context.AddTag(new TagSpan <NavigableHighlightTag>( textSnapshot.GetSpan(Span.FromBounds(span.TextSpan.Start, span.TextSpan.End)), tag)); } } catch (Exception e) when(FatalError.ReportAndCatchUnlessCanceled(e, cancellationToken, ErrorSeverity.General)) { // report NFW and continue. // also, rather than return partial results, return nothing context.ClearTags(); } }
private bool AreSameDocumentHightlights(DocumentHighlights x, DocumentHighlights y) { if (x.Document != y.Document) { return(false); } if (x.HighlightSpans.Length != y.HighlightSpans.Length) { return(false); } for (int i = 0; i < x.HighlightSpans.Length; ++i) { if (!AreSameHighlightSpans(x.HighlightSpans[i], y.HighlightSpans[i])) { return(false); } } return(true); }
private void AddTagSpans( TaggerContext <NavigableHighlightTag> context, DocumentHighlights documentHighlights) { var cancellationToken = context.CancellationToken; var document = documentHighlights.Document; var text = document.SourceText; var textSnapshot = text.FindCorrespondingEditorTextSnapshot(); if (textSnapshot == null) { // There is no longer an editor snapshot for this document, so we can't care about the // results. return; } foreach (var span in documentHighlights.HighlightSpans) { var tag = GetTag(span); context.AddTag(new TagSpan <NavigableHighlightTag>( textSnapshot.GetSpan(Span.FromBounds(span.TextSpan.Start, span.TextSpan.End)), tag)); } }
private async Task AddTagSpansAsync( Solution solution, List <ITagSpan <AbstractNavigatableReferenceHighlightingTag> > tags, DocumentHighlights documentHighlights, CancellationToken cancellationToken) { var document = documentHighlights.Document; var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); var textSnapshot = text.FindCorrespondingEditorTextSnapshot(); if (textSnapshot == null) { // There is no longer an editor snapshot for this document, so we can't care about the // results. return; } foreach (var span in documentHighlights.HighlightSpans) { var tag = span.IsDefinition ? (AbstractNavigatableReferenceHighlightingTag)DefinitionHighlightTag.Instance : ReferenceHighlightTag.Instance; tags.Add(new TagSpan <AbstractNavigatableReferenceHighlightingTag>( textSnapshot.GetSpan(Span.FromBounds(span.TextSpan.Start, span.TextSpan.End)), tag)); } }