private TagSpan <IErrorTag> GetErrorTag(NormalizedSnapshotSpanCollection spans) { if (_error?.LineNumber == null) { return(null); } var line = _error.LineNumber.Value - 1; var col = (_error?.LinePosition ?? 1) - 1; if (line < 0 || line >= _buffer.CurrentSnapshot.LineCount || col < 0) { return(null); } var snapshotline = _buffer.CurrentSnapshot.GetLineFromLineNumber(line); if (snapshotline.Start.Position + col >= snapshotline.Snapshot.Length) { return(null); } var start = snapshotline.Start + col; var startSpan = new SnapshotSpan(start, start + 1); var span = _navigator.GetSpanOfFirstChild(startSpan); var tag = new ErrorTag(PredefinedErrorTypeNames.CompilerError, _error.Message); if (!spans.IntersectsWith(span)) { return(null); } return(new TagSpan <IErrorTag>(span, tag)); }
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 IEnumerable <ITagSpan <IErrorTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (_error?.LineNumber != null) { var line = _buffer.CurrentSnapshot.GetLineFromLineNumber(Math.Max(_error.LineNumber.Value - 1, 0)); var start = line.Start + Math.Max(((_error?.LinePosition ?? 1) - 1), 0); var startSpan = new SnapshotSpan(start, start + 1); var span = _navigator.GetSpanOfFirstChild(startSpan); var tag = new ErrorTag(PredefinedErrorTypeNames.CompilerError, _error.Message); if (spans.OverlapsWith(span)) { return(new[] { new TagSpan <IErrorTag>(span, tag) }); } } return(Array.Empty <ITagSpan <IErrorTag> >()); }
public SnapshotSpan GetSpanOfFirstChild(SnapshotSpan activeSpan) { return(_delegateNavigator.GetSpanOfFirstChild(activeSpan)); }
public SnapshotSpan GetSpanOfFirstChild(SnapshotSpan activeSpan) { return(_plainTextNavigator.GetSpanOfFirstChild(activeSpan)); }
public SnapshotSpan GetSpanOfFirstChild(SnapshotSpan activeSpan) => xmlNavigator.GetSpanOfFirstChild(activeSpan);