private static PublishDiagnosticsParams ToPublishDiagnostics(DafnyDocument document, CancellationToken cancellationToken) { return(new PublishDiagnosticsParams { Uri = document.Uri, Version = document.Version, Diagnostics = ToDiagnostics(document, cancellationToken).ToArray(), }); }
public void HideDiagnostics(DafnyDocument document) { _languageServer.PublishDiagnostics(new PublishDiagnosticsParams { Uri = document.Uri, Version = document.Version, Diagnostics = new Container <Diagnostic>() }); }
private static PublishDiagnosticsParams ToPublishDiagnostics(DafnyDocument document) { return(new() { Uri = document.Uri, Version = document.Version, Diagnostics = ToDiagnostics(document).ToArray(), }); }
private static IEnumerable <Diagnostic> ToDiagnostics(DafnyDocument document) { // Only report errors of the entry-document. if (document.Errors.Diagnostics.TryGetValue(document.GetFilePath(), out var diagnostics)) { return(diagnostics); } return(Enumerable.Empty <Diagnostic>()); }
public void PublishDiagnostics(DafnyDocument document) { if (document.LoadCanceled) { // We leave the responsibility to shift the error locations to the LSP clients. // Therefore, we do not republish the errors when the document (re-)load was canceled. return; } languageServer.TextDocument.PublishDiagnostics(ToPublishDiagnostics(document)); }
private static IEnumerable <Diagnostic> ToDiagnostics(DafnyDocument document, CancellationToken cancellationToken) { foreach (var(level, messages) in document.Errors.AllMessages) { foreach (var message in messages) { cancellationToken.ThrowIfCancellationRequested(); if (!document.IsPartOf(message.token)) { // TODO The reported error belongs to another file. Report it anyway? continue; } yield return(new Diagnostic { Severity = ToSeverity(level), Range = message.token.GetLspRange(), Message = message.message, Source = message.source.ToString() }); } } }
public void PublishDiagnostics(DafnyDocument document, CancellationToken cancellationToken) { _languageServer.PublishDiagnostics(ToPublishDiagnostics(document, cancellationToken)); }