diff --git a/src/Lean/Server/FileWorker.lean b/src/Lean/Server/FileWorker.lean index 3261a9b2f3..571cbf0350 100644 --- a/src/Lean/Server/FileWorker.lean +++ b/src/Lean/Server/FileWorker.lean @@ -94,21 +94,6 @@ end Utils /- Asynchronous snapshot elaboration. -/ section Elab - def publishDiagnostics (m : DocumentMeta) (diagnostics : Array Lsp.Diagnostic) (hOut : FS.Stream) : IO Unit := - hOut.writeLspNotification { - method := "textDocument/publishDiagnostics" - param := { - uri := m.uri - version? := m.version - diagnostics := diagnostics - : PublishDiagnosticsParams - } - } - - def publishMessages (m : DocumentMeta) (msgLog : MessageLog) (hOut : FS.Stream) : IO Unit := do - let diagnostics ← msgLog.msgs.mapM (msgToDiagnostic m.text) - publishDiagnostics m diagnostics.toArray hOut - /-- Elaborates the next command after `parentSnap` and emits diagnostics into `hOut`. -/ private def nextCmdSnap (m : DocumentMeta) (parentSnap : Snapshot) (cancelTk : CancelToken) (hOut : FS.Stream) : ExceptT ElabTaskError IO Snapshot := do diff --git a/src/Lean/Server/Utils.lean b/src/Lean/Server/Utils.lean index e90bc1d988..6259c5e4ee 100644 --- a/src/Lean/Server/Utils.lean +++ b/src/Lean/Server/Utils.lean @@ -121,6 +121,21 @@ def foldDocumentChanges (changes : @& Array Lsp.TextDocumentContentChangeEvent) -- NOTE: We assume Lean files are below 16 EiB. changes.foldl accumulateChanges (oldText, 0xffffffff) +def publishDiagnostics (m : DocumentMeta) (diagnostics : Array Lsp.Diagnostic) (hOut : FS.Stream) : IO Unit := + hOut.writeLspNotification { + method := "textDocument/publishDiagnostics" + param := { + uri := m.uri + version? := m.version + diagnostics := diagnostics + : PublishDiagnosticsParams + } + } + +def publishMessages (m : DocumentMeta) (msgLog : MessageLog) (hOut : FS.Stream) : IO Unit := do + let diagnostics ← msgLog.msgs.mapM (msgToDiagnostic m.text) + publishDiagnostics m diagnostics.toArray hOut + end Lean.Server namespace List diff --git a/src/Lean/Server/Watchdog.lean b/src/Lean/Server/Watchdog.lean index 3b2e05919e..190303b4ad 100644 --- a/src/Lean/Server/Watchdog.lean +++ b/src/Lean/Server/Watchdog.lean @@ -229,6 +229,7 @@ section ServerM | Except.error e => WorkerEvent.ioError e def startFileWorker (m : DocumentMeta) : ServerM Unit := do + publishDiagnostics m #[{ range := ⟨⟨0, 0⟩, ⟨0, 0⟩⟩, severity? := DiagnosticSeverity.information, message := "starting new server for file..." }] (← read).hOut let st ← read let headerAst ← parseHeaderAst m.text.source let workerProc ← Process.spawn {