From 2b370e3eacc72e4085189f55be2168584322badc Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 20 Jun 2018 00:04:06 -0500 Subject: [PATCH] Remove code that is no longer used following simplifications to ConvertToTagTrees --- .../Tagging/Utilities/TagSpanIntervalTree.cs | 28 ----- ...ousTaggerProvider.TagSource_ProduceTags.cs | 106 ------------------ 2 files changed, 134 deletions(-) diff --git a/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs b/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs index d1f3c17731a..484f05487c3 100644 --- a/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs +++ b/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs @@ -59,34 +59,6 @@ public IList> GetIntersectingSpans(SnapshotSpan snapshotSpan) return result ?? SpecializedCollections.EmptyList>(); } - public void GetNonIntersectingSpans(SnapshotSpan snapshotSpan, List> beforeSpans, List> afterSpans) - { - var snapshot = snapshotSpan.Snapshot; - Contract.Requires(snapshot.TextBuffer == _textBuffer); - - var introspector = new IntervalIntrospector(snapshot); - - var beforeSpan = new SnapshotSpan(snapshot, 0, snapshotSpan.Start); - AddNonIntersectingSpans(beforeSpan, introspector, beforeSpans); - - var afterSpan = new SnapshotSpan(snapshot, snapshotSpan.End, snapshot.Length - snapshotSpan.End); - AddNonIntersectingSpans(afterSpan, introspector, afterSpans); - } - - private void AddNonIntersectingSpans( - SnapshotSpan span, IntervalIntrospector introspector, List> spans) - { - var snapshot = span.Snapshot; - foreach (var tagNode in _tree.GetIntervalsThatIntersectWith(span.Start, span.Length, introspector)) - { - var tagNodeSpan = tagNode.Span.GetSpan(snapshot); - if (span.Contains(tagNodeSpan)) - { - spans.Add(new TagSpan(tagNodeSpan, tagNode.Tag)); - } - } - } - public IEnumerable> GetSpans(ITextSnapshot snapshot) { return _tree.Select(tn => new TagSpan(tn.Span.GetSpan(snapshot), tn.Tag)); diff --git a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs index 52c21a55844..4f974790741 100644 --- a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs +++ b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs @@ -451,112 +451,6 @@ private IEnumerable> GetNonIntersectingTagSpans(IEnumerable> ConvertToTagTree( - ImmutableDictionary> oldTagTrees, - ILookup> newTagsByBuffer, - SnapshotSpan spanTagged) - { - var allBuffers = oldTagTrees.Keys.Concat(newTagsByBuffer.Select(g => g.Key)) - .Concat(spanTagged.Snapshot.TextBuffer).Distinct(); - - var newTagTrees = ImmutableDictionary>.Empty; - foreach (var buffer in allBuffers) - { - var newTagTree = ComputeNewTagTree(spanTagged, oldTagTrees, buffer, newTagsByBuffer[buffer]); - if (newTagTree != null) - { - newTagTrees = newTagTrees.Add(buffer, newTagTree); - } - } - - return newTagTrees; - } - - /// - /// This is the same as , - /// just optimized for the case where we were tagging a single snapshot span. - /// - private TagSpanIntervalTree ComputeNewTagTree( - SnapshotSpan spanToInvalidate, - ImmutableDictionary> oldTagTrees, - ITextBuffer textBuffer, - IEnumerable> newTags) - { - oldTagTrees.TryGetValue(textBuffer, out var oldTagTree); - - if (oldTagTree == null) - { - if (newTags.IsEmpty()) - { - // We have no new tags, and no old tags either. No need to store anything - // for this buffer. - return null; - } - - // If we don't have any old tags then we just need to return the new tags. - return new TagSpanIntervalTree(textBuffer, _dataSource.SpanTrackingMode, newTags); - } - - // If we're examining a text buffer other than the one we tagged. - if (textBuffer != spanToInvalidate.Snapshot.TextBuffer) - { - // If we have no new tags produced for it, we can just use the old tags for it. - if (newTags.IsEmpty()) - { - return oldTagTree; - } - - // Otherwise, merge the old and new tags. - var finalTags = oldTagTree.GetSpans(newTags.First().Span.Snapshot).Concat(newTags); - return new TagSpanIntervalTree(textBuffer, _dataSource.SpanTrackingMode, finalTags); - } - else - { - // We're examining the buffer we tagged. If we tagged just a portion in the middle - // then produce the new set of tags by taking the old set before the retagged portion, - // then the new tags, then the old tags after the retagged portion. This keeps the - // tags mostly sorted, which helps with producing an accurate diff. - - // These lists only live as long as this method. So it's fine for us to do whatever - // we want with them (including mutating them) inside this body. - var beforeTagsToKeep = new List>(); - var afterTagsToKeep = new List>(); - GetTagsToKeep(oldTagTrees, spanToInvalidate, beforeTagsToKeep, afterTagsToKeep); - - // Then union those with the new tags to produce the final tag tree. - var finalTags = beforeTagsToKeep; - finalTags.AddRange(newTags); - finalTags.AddRange(afterTagsToKeep); - - return new TagSpanIntervalTree(textBuffer, _dataSource.SpanTrackingMode, finalTags); - } - } - - /// - /// Returns all that tags that fully precede 'spanToInvalidate' and all the tags that - /// fully follow it. All the tag spans are normalized to the snapshot passed in through - /// 'spanToInvalidate'. - /// - private void GetTagsToKeep( - ImmutableDictionary> oldTagTrees, - SnapshotSpan spanTagged, - List> beforeTags, - List> afterTags) - { - var fullRefresh = spanTagged.Length == spanTagged.Snapshot.Length; - if (fullRefresh) - { - return; - } - // we actually have span to invalidate from old tree - if (!oldTagTrees.TryGetValue(spanTagged.Snapshot.TextBuffer, out var treeForBuffer)) - { - return; - } - - treeForBuffer.GetNonIntersectingSpans(spanTagged, beforeTags, afterTags); - } - private async Task RecomputeTagsAsync( object oldState, SnapshotPoint? caretPosition, -- GitLab