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)));
 }
        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;
                        }
                        if (spanData.Data.IsHidden)
                        {
                            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);
 }