Exemple #1
0
        public override bool Equals(object obj)
        {
            Collapsible other = obj as Collapsible;

            if (other != null)
            {
                return(Tag.Equals(other.Tag) &&
                       Extent.Equals(other.Extent) &&
                       IsCollapsed == other.IsCollapsed);
            }

            return(false);
        }
Exemple #2
0
        private SortedList <Collapsible, object> CollapsiblesFromTags(IEnumerable <IMappingTagSpan <IOutliningRegionTag> > tagSpans)
        {
            ITextSnapshot current = this.editBuffer.CurrentSnapshot;

            SortedList <Collapsible, object> collapsibles
                = new SortedList <Collapsible, object>(new CollapsibleSorter(editBuffer));

            foreach (var tagSpan in tagSpans)
            {
                var spans = tagSpan.Span.GetSpans(current);

                // We only accept this tag if it hasn't been split into multiple spans and if
                // it hasn't had pieces cut out of it from projection.  Also, refuse 0-length
                // tags, as they wouldn't be hiding anything.
                if (spans.Count == 1 &&
                    spans[0].Length > 0 &&
                    spans[0].Length == tagSpan.Span.GetSpans(tagSpan.Span.AnchorBuffer)[0].Length)
                {
                    ITrackingSpan trackingSpan = current.CreateTrackingSpan(spans[0], SpanTrackingMode.EdgeExclusive);
                    var           collapsible  = new Collapsible(trackingSpan, tagSpan.Tag);
                    if (collapsibles.ContainsKey(collapsible))
                    {
                        // TODO: Notify providers somehow.
                        //       Or rewrite so that such things are legal.
                        Debug.WriteLine("IGNORING TAG " + spans[0] + " due to span conflict");
                    }
                    else
                    {
                        collapsibles.Add(collapsible, null);
                    }
                }
                else
                {
                    Debug.WriteLine("IGNORING TAG " + tagSpan.Span.GetSpans(editBuffer) + " because it was split or shortened by projection");
                }
            }

            return(collapsibles);
        }
        private SortedList <Collapsible, object> CollapsiblesFromTags(IEnumerable <IMappingTagSpan <IOutliningRegionTag> > tagSpans)
        {
            ITextSnapshot current = this.editBuffer.CurrentSnapshot;

            SortedList <Collapsible, object> collapsibles
                = new SortedList <Collapsible, object>(new CollapsibleSorter(editBuffer));

            foreach (var tagSpan in tagSpans)
            {
                // Attempt to map this tag up to the top level buffer in a contiguous fashion,
                // rejecting it if either the start or end fails to map.
                if (TryContiguousMapToSnapshot(tagSpan, current, out var mappedSpan) &&
                    (mappedSpan.Length > 0))
                {
                    ITrackingSpan trackingSpan = current.CreateTrackingSpan(mappedSpan, SpanTrackingMode.EdgeExclusive);
                    var           collapsible  = new Collapsible(trackingSpan, tagSpan.Tag);
                    if (collapsibles.ContainsKey(collapsible))
                    {
                        // TODO: Notify providers somehow.
                        //       Or rewrite so that such things are legal.
#if false
                        Debug.WriteLine("IGNORING TAG " + mappedSpan + " due to span conflict");
#endif
                    }
                    else
                    {
                        collapsibles.Add(collapsible, null);
                    }
                }
                else
                {
#if false
                    Debug.WriteLine("IGNORING TAG " + tagSpan.Span.GetSpans(editBuffer) + " because its start or endpoint failed to map");
#endif
                }
            }

            return(collapsibles);
        }