private static string FormatErrorTag(TrackingTagSpan<ErrorTag> tag) { return string.Format("{0}: {1} ({2})", tag.Tag.ErrorType, tag.Tag.ToolTipContent, FormatErrorTagSpan(tag) ); }
private static string FormatErrorTagSpan(TrackingTagSpan <ErrorTag> tag) { return(string.Format("{0}-{1}", tag.Span.GetStartPoint(tag.Span.TextBuffer.CurrentSnapshot).Position, tag.Span.GetEndPoint(tag.Span.TextBuffer.CurrentSnapshot).Position )); }
private static string FormatErrorTag(TrackingTagSpan <ErrorTag> tag) { return(string.Format("{0}: {1} ({2})", tag.Tag.ErrorType, tag.Tag.ToolTipContent, FormatErrorTagSpan(tag) )); }
/// <summary> /// Remove selection for tracking text /// </summary> public void RemoveHighlightMarker() { if (_tagger != null && _marker != null) { _tagger.RemoveTagSpan(_marker); } _marker = null; }
/// <summary> /// Remove selection for tracking text /// </summary> public void RemoveHighlightMarker() { if (m_tagger != null && m_marker != null) { m_tagger.RemoveTagSpan(m_marker); } m_marker = null; }
/// <summary> /// Select current tracking text with <paramref name="highlightColor"/>. /// If highlightColor is null than code will be selected with color from <seealso cref="Color"/>. /// If the mark doesn't support tracking changes, then we simply ignore this condition (addresses VS crash /// reported in Bug 476347 : Code Analysis clicking error report C6244 causes VS2012 to crash). /// Tracking changes helps to ensure that we nativate to the right line even if edits to the file /// have occured, but even if that behavior doesn't work right, it is better to /// simply return here (before the fix this code threw an exception which terminated VS). /// </summary> /// <param name="highlightColor">Color</param> public void AddHighlightMarker(string highlightColor) { if (!IsTracking()) { return; } _marker = _tagger.CreateTagSpan(_trackingSpan, new TextMarkerTag(highlightColor ?? Color)); }
/// <summary> /// Select current tracking text with <paramref name="highlightColor"/>. /// If highlightColor is null than code will be selected with color from <seealso cref="Color"/>. /// If the mark doesn't support tracking changes, then we simply ignore this condition (addresses VS crash /// reported in Bug 476347 : Code Analysis clicking error report C6244 causes VS2012 to crash). /// Tracking changes helps to ensure that we nativate to the right line even if edits to the file /// have occured, but even if that behavior doesn't work right, it is better to /// simply return here (before the fix this code threw an exception which terminated VS). /// </summary> /// <param name="highlightColor">Color</param> public void AddSelectionMarker(string highlightColor) { if (!IsTracking()) { return; } m_marker = m_tagger.CreateTagSpan(m_trackingSpan, new TextMarkerTag(highlightColor ?? Color)); }
private static string FormatErrorTag(TrackingTagSpan <ErrorTag> tag) { return(string.Format("{0}: {1} ({2}:{3})", tag.Tag.ErrorType, tag.Tag.ToolTipContent, (tag.Tag as ErrorTagWithMoniker)?.Moniker ?? "no moniker", FormatErrorTagSpan(tag) )); }
private void RemoveTracking() { if (_trackingSpan != null) { // TODO: Find a way to delete TrackingSpan _marker = _tagger.CreateTagSpan(_trackingSpan, new TextMarkerTag(Color)); RemoveHighlightMarker(); _trackingSpan = null; _tagger = null; _docCookie = null; } }
private void RemoveTracking() { if (m_trackingSpan != null) { // TODO: Find a way to delete TrackingSpan m_marker = m_tagger.CreateTagSpan(m_trackingSpan, new TextMarkerTag(Color)); RemoveMarker(); m_trackingSpan = null; m_tagger = null; m_docCookie = null; } }
public Bookmark(TrackingTagSpan <BookmarkTag> trackingSpan) { this.TrackingSpan = trackingSpan; }
public Bookmark(TrackingTagSpan<Tag> span) { Span = span; }
private void OnLayoutChanged(object sender, TextViewLayoutChangedEventArgs args) { ITextSnapshot snapshot = args.NewSnapshot; if (this.lastVersion == snapshot.Version) { return; } this.lastVersion = snapshot.Version; string code = snapshot.GetText(); SyntaxTree tree = SyntaxTree.Parse(code); if (tree.Errors.Any(e => e.ErrorType == ErrorType.Error)) { return; } List <Tuple <ITrackingSpan, SnapshotSpan> > currentSpans = new List <Tuple <ITrackingSpan, SnapshotSpan> > ( this.spans.Keys.Select(t => new Tuple <ITrackingSpan, SnapshotSpan> (t, t.GetSpan(args.NewSnapshot)))); foreach (MethodDeclaration method in tree.Descendants.OfType <MethodDeclaration>()) { if (method.HasModifier(Modifiers.Abstract) || method.HasModifier(Modifiers.Extern)) { continue; } ITextSnapshotLine nameLine = snapshot.GetLineFromLineNumber(method.NameToken.StartLocation.Line - 1); int pos = nameLine.Start.Position + method.NameToken.StartLocation.Column - 1; SnapshotSpan nameSpan = new SnapshotSpan(snapshot, pos, method.Name.Length); var overlapped = currentSpans.FirstOrDefault(ss => ss.Item2.OverlapsWith(nameSpan)); // If the method is already being tracked, VS will handle it. if (overlapped != null) { // Update example invocation, signature might have changed InstantTagToggleAction action = this.spans[overlapped.Item1].Tag.ActionSets.SelectMany(s => s.Actions).OfType <InstantTagToggleAction>().Single(); action.ExampleCode = method.GetExampleInvocation(); currentSpans.Remove(overlapped); continue; } ITrackingSpan trackingNameSpan = snapshot.CreateTrackingSpan(nameSpan, SpanTrackingMode.EdgeExclusive); ITextSnapshotLine startLine = snapshot.GetLineFromLineNumber(method.StartLocation.Line); ITextSnapshotLine endLine = snapshot.GetLineFromLineNumber(method.EndLocation.Line); ITrackingSpan methodSpan = snapshot.CreateTrackingSpan(Span.FromBounds(startLine.Start.Position, endLine.End.Position), SpanTrackingMode.EdgeExclusive); var actionSets = new ReadOnlyCollection <SmartTagActionSet> (new[] { new SmartTagActionSet(new ReadOnlyCollection <ISmartTagAction> (new[] { new InstantTagToggleAction(this.view, methodSpan, method.GetExampleInvocation()), })), }); var tag = new SmartTag(SmartTagType.Factoid, actionSets); TrackingTagSpan <SmartTag> trackingTagSpan = CreateTagSpan(trackingNameSpan, tag); this.spans[trackingNameSpan] = trackingTagSpan; } // Remove any empty spans, they've been deleted foreach (var kvp in this.spans.Where(kvp => kvp.Key.GetSpan(snapshot).IsEmpty).ToArray()) { foreach (IDisposable disposable in kvp.Value.Tag.ActionSets.SelectMany(s => s.Actions).OfType <IDisposable>()) { disposable.Dispose(); } RemoveTagSpan(kvp.Value); this.spans.Remove(kvp.Key); } }
private void RemoveTracking() { if (m_trackingSpan != null) { // TODO: Find a way to delete TrackingSpan m_marker = m_tagger.CreateTagSpan(m_trackingSpan, new TextMarkerTag(Color)); RemoveHighlightMarker(); m_trackingSpan = null; m_tagger = null; m_docCookie = null; } }
private static string FormatErrorTagSpan(TrackingTagSpan<ErrorTag> tag) { return string.Format("{0}-{1}", tag.Span.GetStartPoint(tag.Span.TextBuffer.CurrentSnapshot).Position, tag.Span.GetEndPoint(tag.Span.TextBuffer.CurrentSnapshot).Position ); }
/// <summary> /// Select current tracking text with <paramref name="highlightColor"/>. /// If highlightColor is null than code will be selected with color from <seealso cref="Color"/>. /// If the mark doesn't support tracking changes, then we simply ignore this condition (addresses VS crash /// reported in Bug 476347 : Code Analysis clicking error report C6244 causes VS2012 to crash). /// Tracking changes helps to ensure that we nativate to the right line even if edits to the file /// have occured, but even if that behavior doesn't work right, it is better to /// simply return here (before the fix this code threw an exception which terminated VS). /// </summary> /// <param name="highlightColor">Color</param> public void AddHighlightMarker(string highlightColor) { if (!IsTracking()) { return; } m_marker = m_tagger.CreateTagSpan(m_trackingSpan, new TextMarkerTag(highlightColor ?? Color)); }