Exemplo n.º 1
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan)
        {
            // Map the trigger point down to our buffer.
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(_mSubjectBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                applicableToSpan = null;
                return;
            }

            ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot;

            //look for occurrences of our QuickInfo words in the span
            ITextStructureNavigator navigator = _mProvider.NavigatorService.GetTextStructureNavigator(_mSubjectBuffer);



            TextExtent extent = navigator.GetExtentOfWord(subjectTriggerPoint.Value);

            if (extent.IsSignificant)
            {
                var tt1 = navigator.GetSpanOfNextSibling(extent.Span);
                var tt2 = navigator.GetSpanOfFirstChild(extent.Span);
                var tt3 = navigator.GetSpanOfPreviousSibling(extent.Span);
                var tt4 = navigator.GetSpanOfEnclosing(extent.Span);
                var t1  = tt1.GetText();
                var t2  = tt2.GetText();
                var t3  = tt3.GetText();
            }

            string searchText = extent.Span.GetText();

            foreach (string key in _mDictionary.Keys)
            {
                int foundIndex = searchText.IndexOf(key, StringComparison.CurrentCultureIgnoreCase);
                if (foundIndex > -1)
                {
                    applicableToSpan = currentSnapshot.CreateTrackingSpan
                                       (
                        //querySpan.Start.Add(foundIndex).Position, 9, SpanTrackingMode.EdgeInclusive
                        extent.Span.Start + foundIndex, key.Length, SpanTrackingMode.EdgeInclusive
                                       );

                    string value;
                    _mDictionary.TryGetValue(key, out value);
                    qiContent.Add(value ?? "");

                    return;
                }
            }

            applicableToSpan = null;
        }
        public static int?GetSubwordBoundary(this ITextStructureNavigator navigator, SnapshotPoint point, bool forward)
        {
            var wordSpan = navigator.GetExtentOfWord(point).Span;

            wordSpan = new SnapshotSpan(navigator.GetSpanOfPreviousSibling(wordSpan).Start,
                                        navigator.GetSpanOfNextSibling(wordSpan).End);
            if (wordSpan.Length == 0)
            {
                return(null);
            }

            int          step = forward ? 1 : -1;
            SnapshotSpan wordSpanPrev;

            do
            {
                var word = wordSpan.GetText();
                int i    = point.Position - wordSpan.Start;

                while (0 < i && i < word.Length)
                {
                    if (IsSubwordBoundary(word, i, forward))
                    {
                        return(wordSpan.Start + i);
                    }
                    i += step;
                }

                point = wordSpan.Start + i;

                wordSpanPrev = wordSpan;
                wordSpan     = navigator.GetSpanOfEnclosing(wordSpan);
            } while (wordSpan != wordSpanPrev);

            return(null);
        }
 public SnapshotSpan GetSpanOfNextSibling(SnapshotSpan activeSpan)
 {
     return(_delegateNavigator.GetSpanOfNextSibling(activeSpan));
 }
Exemplo n.º 4
0
 public SnapshotSpan GetSpanOfNextSibling(SnapshotSpan activeSpan)
 {
     return(_plainTextNavigator.GetSpanOfNextSibling(activeSpan));
 }
Exemplo n.º 5
0
 public SnapshotSpan GetSpanOfNextSibling(SnapshotSpan activeSpan) => xmlNavigator.GetSpanOfNextSibling(activeSpan);