public static GetDiagnostics ( ITextBuffer buffer ) : IEnumerable |
||
buffer | ITextBuffer | |
Résultat | IEnumerable |
private void FindDiagnostics() { spansAndDiagnostics.Clear(); int minPosition = buffer.CurrentSnapshot.Length; int maxPosition = 0; ClangServices.Process(buffer); foreach (var diagnostic in ClangServices.GetDiagnostics(buffer)) { if (!diagnostic.FilePath.Any(c => Path.GetInvalidPathChars().Contains(c))) { // Crude check, should find a more sophisticated way to check if two paths are equal, ignoring different directory separator chars. if (Path.GetFileName(diagnostic.FilePath) == Path.GetFileName(document.FilePath)) { if (diagnostic.StartLine != 0) { diagnostic.StartLine--; } var textLine = buffer.CurrentSnapshot.GetLineFromLineNumber(diagnostic.StartLine); var startPosition = textLine.Start.Position; var endPosition = textLine.End.Position; minPosition = Math.Min(minPosition, startPosition); maxPosition = Math.Max(maxPosition, endPosition); SnapshotSpan span = new SnapshotSpan(buffer.CurrentSnapshot, Span.FromBounds(startPosition, endPosition)); spansAndDiagnostics.Add(Tuple.Create(span, diagnostic)); } } } if (spansAndDiagnostics.Any()) { RaiseTagsChanged(minPosition, maxPosition); } else { if (TagsChanged != null) { TagsChanged(this, new SnapshotSpanEventArgs(lastTotalDiagnosticsSpan)); } } }
public static IEnumerable <Diagnostic> Find(ITextBuffer buffer) { ITextDocument document; if (!buffer.Properties.TryGetProperty(typeof(ITextDocument), out document) || document == null) { return(Enumerable.Empty <Diagnostic>()); } ClangServices.Process(buffer); ErrorList.ClearDiagnosticsFromFile(document.FilePath); var diags = (from diag in ClangServices.GetDiagnostics(buffer) where DiagnosticsBlacklist.Contains(diag) == false && !diag.FilePath.Any(c => Path.GetInvalidPathChars().Contains(c)) && Path.GetFileName(diag.FilePath) == Path.GetFileName(document.FilePath) select diag).ToList(); ErrorList.Show(diags); return(diags); }