Exemple #1
0
 private static PublishDiagnosticsParams ToPublishDiagnostics(DafnyDocument document, CancellationToken cancellationToken)
 {
     return(new PublishDiagnosticsParams {
         Uri = document.Uri,
         Version = document.Version,
         Diagnostics = ToDiagnostics(document, cancellationToken).ToArray(),
     });
 }
Exemple #2
0
 public void HideDiagnostics(DafnyDocument document)
 {
     _languageServer.PublishDiagnostics(new PublishDiagnosticsParams {
         Uri         = document.Uri,
         Version     = document.Version,
         Diagnostics = new Container <Diagnostic>()
     });
 }
Exemple #3
0
 private static PublishDiagnosticsParams ToPublishDiagnostics(DafnyDocument document)
 {
     return(new() {
         Uri = document.Uri,
         Version = document.Version,
         Diagnostics = ToDiagnostics(document).ToArray(),
     });
 }
Exemple #4
0
 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>());
 }
Exemple #5
0
 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));
 }
Exemple #6
0
 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()
             });
         }
     }
 }
Exemple #7
0
 public void PublishDiagnostics(DafnyDocument document, CancellationToken cancellationToken)
 {
     _languageServer.PublishDiagnostics(ToPublishDiagnostics(document, cancellationToken));
 }