chore: more generic import out of date diagnostic (#3739)
The concrete dependency that is stale isn't really actionable information for users (ideally we'd like something like "amount of dependencies that will be rebuilt when you restart file"). This also makes the diagnostic an "information" diagnostic so that non-infoview users can still see it. Since we are moving away from using notifications for stale dependency information, we don't need to provide an ID anymore, either.
This commit is contained in:
parent
1f4dea8582
commit
3f8f2b09af
1 changed files with 10 additions and 15 deletions
|
|
@ -435,26 +435,21 @@ section NotificationHandling
|
|||
|
||||
/--
|
||||
Received from the watchdog when a dependency of this file is detected as being stale.
|
||||
Issues a `LanguageServer_ImportOutOfDate` sticky diagnostic to the client.
|
||||
Issues a sticky diagnostic to the client that it should run "Restart File".
|
||||
-/
|
||||
def handleStaleDependency (p : LeanStaleDependencyParams) : WorkerM Unit := do
|
||||
def handleStaleDependency (_ : LeanStaleDependencyParams) : WorkerM Unit := do
|
||||
let ctx ← read
|
||||
let s ← get
|
||||
let text := s.doc.meta.text
|
||||
let _ ← IO.mapTask (t := s.srcSearchPathTask) fun srcSearchPath => do
|
||||
let some staleDependencyName ← moduleFromDocumentUri srcSearchPath p.staleDependency
|
||||
| return
|
||||
let diagnostic := {
|
||||
range := ⟨⟨0, 0⟩, ⟨1, 0⟩⟩
|
||||
fullRange? := some ⟨⟨0, 0⟩, text.utf8PosToLspPos text.source.endPos⟩
|
||||
severity? := DiagnosticSeverity.hint
|
||||
code? := some <| .string "LanguageServer_ImportOutOfDate"
|
||||
message := .text s!"Import '{staleDependencyName}' is out of date; \
|
||||
use the \"Restart File\" command in your editor."
|
||||
data? := some staleDependencyName.toString
|
||||
let diagnostic := {
|
||||
range := ⟨⟨0, 0⟩, ⟨1, 0⟩⟩
|
||||
fullRange? := some ⟨⟨0, 0⟩, text.utf8PosToLspPos text.source.endPos⟩
|
||||
severity? := DiagnosticSeverity.information
|
||||
message := .text s!"Imports are out of date and should be rebuilt; \
|
||||
use the \"Restart File\" command in your editor."
|
||||
}
|
||||
ctx.stickyDiagnosticsRef.modify fun stickyDiagnostics => stickyDiagnostics.insert diagnostic
|
||||
publishDiagnostics ctx s.doc.toEditableDocumentCore
|
||||
ctx.stickyDiagnosticsRef.modify fun stickyDiagnostics => stickyDiagnostics.insert diagnostic
|
||||
publishDiagnostics ctx s.doc.toEditableDocumentCore
|
||||
|
||||
def handleRpcRelease (p : Lsp.RpcReleaseParams) : WorkerM Unit := do
|
||||
-- NOTE(WN): when the worker restarts e.g. due to changed imports, we may receive `rpc/release`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue