public void AttachTextView(string path, ITextView textView) { SourceFileData data = this.FindSourceFile(path, false); data.AttachTextView(textView); data.ViewClosed += SourceFileData_ViewClosed; }
public void AddSourceFiles(IEnumerable <string> files) { foreach (string file in files) { SourceFileData data = new SourceFileData(this, file); this.files.Add(data); } }
public CompilerMessageTagger(ITextView textView, string fullPath) : base(textView.TextBuffer) { this.textView = textView; this.FileName = fullPath; this.sourceFileData = SourceFileCompiler.Instance.FindSourceFileData(fullPath); this.sourceFileData.SourceFileSet.SetClosed += SourceFileSet_SetClosed; this.sourceFileData.SourceFileSet.CompileComplete += SourceFileSet_CompileComplete; }
private SourceFileData FindSourceFile(string file, bool createIfMissing) { SourceFileData data = this.files.FirstOrDefault(d => string.Equals(d.Path, file, StringComparison.OrdinalIgnoreCase)); if (data == null && createIfMissing) { data = new SourceFileData(this, file); this.files.Add(data); } return(data); }
void Task_Navigate(object sender, EventArgs e) { Task task = sender as Task; VsShellUtilities.OpenDocument(SourceFileCompiler.Instance.ServiceProvider, task.Document); SourceFileData data = SourceFileCompiler.Instance.FindSourceFileData(task.Document); if (data != null && data.TextView != null) { SnapshotSpan span = data.TextView.TextSnapshot.CreateSpan(task.Line, task.Column, task.Column + 1); data.TextView.Caret.MoveTo(span.Start, PositionAffinity.Successor); data.TextView.ViewScroller.EnsureSpanVisible(span, EnsureSpanVisibleOptions.ShowStart); } }
void SourceFileData_ViewClosed(object sender, EventArgs e) { SourceFileData data = sender as SourceFileData; data.ViewClosed -= SourceFileData_ViewClosed; // If there are no more source files with views, we can kill the entire set. if (this.files.All(d => d.TextView == null)) { this.files.Clear(); this.Items.Clear(); this.messages.Clear(); this.OnSetClosed(); } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; // Map the trigger point down to our buffer. SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(this.textBuffer.CurrentSnapshot); if (!subjectTriggerPoint.HasValue) { return; } // Find the source file we're looking at. SourceFileData sourceFileData = SourceFileCompiler.Instance.FindSourceFileData(this.textBuffer); if (sourceFileData == null) { return; } // Find the line/position of the trigger... ITextSnapshotLine line = subjectTriggerPoint.Value.GetContainingLine(); int column = subjectTriggerPoint.Value.Position - line.Start; // See if there's an error/message that intersects the trigger... CompilerMessageEventArgs message = sourceFileData.Messages.FirstOrDefault(m => m.LineNumber - 1 == line.LineNumber && m.LinePosition - 1 <= column && m.LinePositionEnd > column); if (message == null) { return; } // If we found it, create the span and content! applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpanFromSwix(message); // For some reason, we sometimes get doubled (and more!) messages... we specifically check for this, just in case. if (quickInfoContent.Count > 0 || session.QuickInfoContent.Count > 0) { System.Diagnostics.Debug.Assert(false, "multiple quick info?"); System.Diagnostics.Debugger.Break(); } quickInfoContent.Add(message.Message.Message); }