コード例 #1
0
            public IEnumerable <ITagSpan <TTag> > GetTags(NormalizedSnapshotSpanCollection spans)
            {
                if (_buffer.Properties.TryGetProperty(_key, out NormalizedSnapshotSpanCollection matchingSpans))
                {
                    var intersection = NormalizedSnapshotSpanCollection.Intersection(matchingSpans, spans);

                    return(intersection.Select(s => new TagSpan <TTag>(s, _tagInstance)));
                }

                return(SpecializedCollections.EmptyEnumerable <ITagSpan <TTag> >());
            }
コード例 #2
0
        public IEnumerable <ITagSpan <CommentTagsToken> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0)
            {
                yield break;
            }

            spans = NormalizedSnapshotSpanCollection.Intersection(spans, this._comments);

            foreach (var span in spans)
            {
                var line = span.GetText();

                var tagPositions = Utils.GetCommentTags(line);

                foreach (var tag in tagPositions)
                {
                    switch (tag.Type)
                    {
                    case CommentTagsType.Todo:
                        yield return(new TagSpan <CommentTagsToken>(
                                         new SnapshotSpan(span.Snapshot, new Span(tag.Start + span.Start.Position, tag.Length)), this._todo));

                        break;

                    case CommentTagsType.Note:
                        yield return(new TagSpan <CommentTagsToken>
                                         (new SnapshotSpan(span.Snapshot, new Span(tag.Start + span.Start.Position, tag.Length)), this._note));

                        break;

                    case CommentTagsType.Debug:
                        yield return(new TagSpan <CommentTagsToken>(
                                         new SnapshotSpan(span.Snapshot, new Span(tag.Start + span.Start.Position, tag.Length)), this._debug));

                        break;

                    case CommentTagsType.Fixme:
                        yield return(new TagSpan <CommentTagsToken>(
                                         new SnapshotSpan(span.Snapshot, new Span(tag.Start + span.Start.Position, tag.Length)), this._fixme));

                        break;

                    case CommentTagsType.Fixed:
                        yield return(new TagSpan <CommentTagsToken>(
                                         new SnapshotSpan(span.Snapshot, new Span(tag.Start + span.Start.Position, tag.Length)), this._fixed));

                        break;
                    }
                }
            }
        }
コード例 #3
0
    public IEnumerable <ITagSpan <ClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans)
    {
        if (spans == null || spans.Count == 0 || m_CurrentSpans.Count == 0)
        {
            yield break;
        }
        ITextSnapshot snapshot = m_CurrentSpans[0].Snapshot;

        spans = new NormalizedSnapshotSpanCollection(spans.Select(s => s.TranslateTo(snapshot, SpanTrackingMode.EdgeExclusive)));
        foreach (var span in NormalizedSnapshotSpanCollection.Intersection(m_CurrentSpans, spans))
        {
            yield return(new TagSpan <ClassificationTag>(span, new ClassificationTag(m_Type)));
        }
    }
コード例 #4
0
        void UpdateAfterChange(NormalizedSnapshotSpanCollection changedSpans)
        {
            // It's possible that we've been informed of an update (via BatchedTagsChanged or otherwise) that no longer maps to the
            // edit buffer.  As a result of this, there aren't any changed spans for us to consider, so we can return immediately.
            if (changedSpans.Count == 0)
            {
                return;
            }

            var currentCollapsed = GetCollapsedRegionsInternal(changedSpans, exposedRegionsOnly: false);

            if (currentCollapsed.Count > 0)
            {
                // When getting tags, we'll try to be as minimal as possible, since
                // this edit could be large and/or multi-part.  We'll only examine
                // the intersection of the given changed spans and the collapsed
                // regions.
                // NOTE: We could try to be even smarter and only use the child-most regions
                // that we've collected, but it's a bit hard to determine which ones they
                // are at this point (they are the nodes that have 0 children that intersect
                // the changed spans, not just nodes that have 0 children).

                var snapshot     = changedSpans[0].Snapshot;
                var spansToCheck = NormalizedSnapshotSpanCollection.Intersection(
                    changedSpans,
                    new NormalizedSnapshotSpanCollection(
                        currentCollapsed.Select(c => c.Extent.GetSpan(snapshot))));

                var newCollapsibles = CollapsiblesFromTags(tagAggregator.GetTags(spansToCheck)).Keys;

                IEnumerable <ICollapsed> removed;

                MergeRegions(currentCollapsed, newCollapsibles, out removed);

                List <ICollapsible> expandedRegions = new List <ICollapsible>();

                foreach (var removedRegion in removed)
                {
                    var expandedRegion = this.ExpandInternal(removedRegion);

                    expandedRegions.Add(expandedRegion);
                }

                if (expandedRegions.Count > 0)
                {
                    // Send out the regions expanded event with the flag informing
                    // listeners that these regions are being removed.
                    var expandedEvent = RegionsExpanded;
                    if (expandedEvent != null)
                    {
                        expandedEvent(this, new RegionsExpandedEventArgs(expandedRegions, removalPending: true));
                    }
                }
            }

            // Send out the general "outlining has changed" event
            var handler = RegionsChanged;

            if (handler != null)
            {
                handler(this, new RegionsChangedEventArgs(new SnapshotSpan(changedSpans[0].Start, changedSpans[changedSpans.Count - 1].End)));
            }
        }