internal void UpdateErrorList(ITextSnapshot snapshot) { if (this.errorListProvider == null) { return; } try { this.errorListProvider.SuspendRefresh(); this.ClearErrors(); SourceText sourceText = this.singletons.SourceTextCache.Get(snapshot); IReadOnlyList <ParseError> errors = this.singletons.FeatureContainer.DiagnosticsProvider.GetDiagnostics(sourceText); if (errors.Count == 0) { return; } int errorCount = 0; for (int i = 0; i < errors.Count; ++i) { ParseError error = errors[i]; if (errorCount >= Constants.MaximumErrorsPerFile) { break; } SnapshotSpan errorSnapshotSpan = EditorUtilities.CreateSnapshotSpan(snapshot, error.Start, error.Length); string filePath = snapshot.TextBuffer.GetFilePath(); Debug.Assert(filePath != null, "We should always be able to get the moniker for a file opened in the editor (even if it hasn't been saved)"); if (!string.IsNullOrEmpty(filePath)) { ErrorListItem errorListItem = this.CreateErrorListItem(errorSnapshotSpan, error, filePath); this.errorListProvider.Tasks.Add(errorListItem); } errorCount++; } } finally { this.errorListProvider.ResumeRefresh(); } }
private void ClearErrors() { foreach (object task in this.errorListProvider.Tasks) { ErrorListItem errorTask = task as ErrorListItem; if (errorTask != null) { errorTask.Navigate -= this.OnErrorListItemNavigate; } } this.errorListProvider.Tasks.Clear(); }
private ErrorListItem CreateErrorListItem(SnapshotSpan span, ParseError error, string filePath) { ITextSnapshotLine line = span.Snapshot.GetLineFromPosition(span.Start); var errorListItem = new ErrorListItem(span); errorListItem.Category = TaskCategory.All; errorListItem.Priority = TaskPriority.Normal; errorListItem.Document = filePath; errorListItem.ErrorCategory = TaskErrorCategory.Error; errorListItem.Text = error.Message; errorListItem.Line = line.LineNumber; errorListItem.Column = Math.Min(line.End, span.Start) - line.Start; errorListItem.Navigate += this.OnErrorListItemNavigate; return errorListItem; }
private ErrorListItem CreateErrorListItem(SnapshotSpan span, ParseError error, string filePath) { ITextSnapshotLine line = span.Snapshot.GetLineFromPosition(span.Start); var errorListItem = new ErrorListItem(span); errorListItem.Category = TaskCategory.All; errorListItem.Priority = TaskPriority.Normal; errorListItem.Document = filePath; errorListItem.ErrorCategory = TaskErrorCategory.Error; errorListItem.Text = error.Message; errorListItem.Line = line.LineNumber; errorListItem.Column = Math.Min(line.End, span.Start) - line.Start; errorListItem.Navigate += this.OnErrorListItemNavigate; return(errorListItem); }