public void MoveReference(bool forward) { // Check these references first because if the caret is at a Get declaration (VB), then there's // no code references to it, but there's a 'Get' and 'End Get' in these refs that should be used. var spanRefData = SpanDataCollectionUtilities.GetCurrentSpanReference(spanReferenceCollection, TextView); if (spanRefData?.Data.Reference != null) { foreach (var newSpanData in GetReferenceInfosFrom(spanReferenceCollection, spanRefData.Value.Span.Start, forward)) { if (object.Equals(newSpanData.Data.Reference, spanRefData.Value.Data.Reference)) { MoveCaretToSpan(newSpanData.Span); break; } } return; } var spanData = GetCurrentReferenceInfo(); if (spanData != null) { foreach (var newSpanData in GetReferenceInfosFrom(spanData.Value.Span.Start, forward)) { if (SpanDataReferenceInfoExtensions.CompareReferences(newSpanData.Data, spanData.Value.Data)) { MoveCaretToSpan(newSpanData.Span); break; } } return; } }
static bool IsSameReference(SpanData <ReferenceInfo>?a, SpanData <ReferenceInfo>?b) { if (a == null && b == null) { return(true); } if (a == null || b == null) { return(false); } return(SpanDataReferenceInfoExtensions.CompareReferences(a.Value.Data, b.Value.Data)); }
public IEnumerable <ITagSpan <ITextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (documentViewer == null) { yield break; } if (documentViewer.TextView.IsClosed) { yield break; } Debug.Assert(documentViewerReferenceEnablerProviders != null); Debug.Assert(documentViewerReferenceEnablers != null); // It's not common for both references to be non-null but it does happen if it's VB and the reference // is at eg. a Get keyword. For that reason, check for span refs first or we won't see the definition // highlight because it's hidden behind another span reference. if (currentSpanReference != null) { if (spans.Count == 0) { yield break; } var snapshot = spans[0].Snapshot; var theRef = currentSpanReference.Value; foreach (var span in spans) { foreach (var spanData in spanReferenceCollection.Find(span.Span)) { if (spanData.Span.End > snapshot.Length) { continue; } if (!IsEnabled(spanData.Data.Id)) { continue; } if (spanData.Data.Reference == null) { continue; } if (!object.Equals(spanData.Data.Reference, theRef.Data.Reference)) { continue; } yield return(new TagSpan <ITextMarkerTag>(new SnapshotSpan(snapshot, spanData.Span), HighlightedReferenceTag)); } } } if (currentReference != null) { if (spans.Count == 0) { yield break; } var snapshot = spans[0].Snapshot; var theRef = currentReference.Value; foreach (var span in spans) { foreach (var spanData in documentViewer.Content.ReferenceCollection.Find(span.Span)) { Debug.Assert(spanData.Span.End <= snapshot.Length); if (spanData.Span.End > snapshot.Length) { continue; } var tag = TryGetTextMarkerTag(spanData); if (tag == null) { continue; } if (!SpanDataReferenceInfoExtensions.CompareReferences(spanData.Data, theRef.Data)) { continue; } yield return(new TagSpan <ITextMarkerTag>(new SnapshotSpan(snapshot, spanData.Span), tag)); } } } }
SpanData <ReferenceInfo>?FindReferenceInfo(SpanData <ReferenceInfo> spanData) { foreach (var other in currentContent.Content.ReferenceCollection) { if (other.Data.IsLocal == spanData.Data.IsLocal && other.Data.IsDefinition == spanData.Data.IsDefinition && SpanDataReferenceInfoExtensions.CompareReferences(other.Data, spanData.Data)) { return(other); } } return(null); }
SpanData <ReferenceInfo>?FindDefinition(SpanData <ReferenceInfo> spanData) { if (spanData.Data.IsDefinition) { return(spanData); } return(currentContent.Content.ReferenceCollection.FirstOrNull(other => other.Data.IsDefinition && SpanDataReferenceInfoExtensions.CompareReferences(other.Data, spanData.Data))); }