Пример #1
0
        public IEnumerable <ITagSpan <TTag> > GetTags(NormalizedSnapshotSpanCollection requestedSpans)
        {
            if (requestedSpans.Count == 0)
            {
                return(SpecializedCollections.EmptyEnumerable <ITagSpan <TTag> >());
            }

            var buffer = requestedSpans.First().Snapshot.TextBuffer;
            var tags   = _tagSource.GetTagIntervalTreeForBuffer(buffer);

            if (tags == null)
            {
                return(SpecializedCollections.EmptyEnumerable <ITagSpan <TTag> >());
            }

            var result = GetTags(requestedSpans, tags);

            DebugVerifyTags(requestedSpans, result);

            return(result);
        }
Пример #2
0
        public IEnumerable <ITagSpan <TTag> > GetTags(NormalizedSnapshotSpanCollection requestedSpans)
        {
            if (requestedSpans.Count == 0)
            {
                return(SpecializedCollections.EmptyEnumerable <ITagSpan <TTag> >());
            }

            var buffer = requestedSpans.First().Snapshot.TextBuffer;
            var tags   = _tagSource.GetTagIntervalTreeForBuffer(buffer);

            if (tags == null)
            {
                return(SpecializedCollections.EmptyEnumerable <ITagSpan <TTag> >());
            }

            // Special case the case where there is only one requested span.  In that case, we don't
            // need to allocate any intermediate collections
            return(requestedSpans.Count == 1
                ? tags.GetIntersectingSpans(requestedSpans[0])
                : requestedSpans.Count < MaxNumberOfRequestedSpans
                    ? GetTagsForSmallNumberOfSpans(requestedSpans, tags)
                    : GetTagsForLargeNumberOfSpans(requestedSpans, tags));
        }