/// <summary>
        /// Purge any TagSpans that intersect in any way with the text changes, then update all spans
        /// </summary>
        public void PurgeAndUpdate(INormalizedTextChangeCollection textChanges, ITextSnapshot textSnapshot)
        {
            Span = Span.Translated(SpanTrackingMode.EdgeExclusive, textSnapshot);

            var fullChangeSpan = new Span(textChanges.First().NewSpan.Start, textChanges.Last().NewSpan.End);

            // Purge ALL TagSpans from any statements that intersect with these text changes
            if (Span.IntersectsWith(fullChangeSpan))
            {
                // Now check more incrementally
                if (textChanges.Any(t => Span.IntersectsWith(t.NewSpan)))
                {
                    TagSpans.Clear();
                }
            }

            /*for (var i = TagSpans.Count - 1; i >= 0; i--)
             * {
             *  var tagSpan = TagSpans[i];
             *  tagSpan.Translate(textSnapshot);
             *
             *  if (tagSpan.Span.IntersectsWith(fullChangeSpan))
             *  {
             *      // Now check more incrementally
             *      if (textChanges.Any(t => tagSpan.Span.IntersectsWith(t.NewSpan)))
             *      {
             *          // Remove this tagspan!
             *          TagSpans.RemoveAt(i);
             *      }
             *  }
             * }*/
        }
예제 #2
0
        public IEnumerable <TagSpan <IGLSLTag> > GetOverlapping(INormalizedTextChangeCollection textChanges, ITextSnapshot textSnapshot)
        {
            var fullSpan = new Span(textChanges.First().NewSpan.Start, textChanges.Last().NewSpan.End);

            foreach (var tagSpan in _tagSpans)
            {
                var translatedSpan = tagSpan.Span.TranslateTo(textSnapshot, SpanTrackingMode.EdgeExclusive);

                if (translatedSpan.IntersectsWith(fullSpan))
                {
                    // Now check more incrementally
                    foreach (var textChange in textChanges)
                    {
                        if (translatedSpan.IntersectsWith(textChange.NewSpan))
                        {
                            yield return(new TagSpan <IGLSLTag>(translatedSpan, tagSpan.Tag));

                            break;
                        }
                    }
                }
            }
        }