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