mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:31:15 +01:00
Publish empty diagnostics on close (#4954)
Without this, diagnostics will linger after closing a file. This refactors towards a pattern of putting outgoing calls as methods on `Context`. I'm mixed on this, mainly thinking it's an improvement on using `outgoing` directly (because it shares the name and structure), might want to move it to a side-class later that is _only_ LSP wrappers. I could also make inheritance private on OutgoingMessages and these kinds of methods public there, but I'm hesitant to adopt that approach versus a type separation.
This commit is contained in:
@@ -61,7 +61,9 @@ class PublishDiagnosticConsumer : public DiagnosticConsumer {
|
||||
}
|
||||
|
||||
// Returns the constructed request.
|
||||
auto params() -> llvm::json::Value { return params_; }
|
||||
auto params() -> const clang::clangd::PublishDiagnosticsParams& {
|
||||
return params_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Returns the LSP range for a diagnostic. Note that Carbon uses 1-based
|
||||
@@ -151,8 +153,7 @@ auto Context::File::SetText(Context& context, std::optional<int64_t> version,
|
||||
// Note we need to publish diagnostics even when empty.
|
||||
// TODO: Consider caching previously published diagnostics and only publishing
|
||||
// when they change.
|
||||
context.outgoing().notify("textDocument/publishDiagnostics",
|
||||
consumer.params());
|
||||
context.PublishDiagnostics(consumer.params());
|
||||
}
|
||||
|
||||
auto Context::LookupFile(llvm::StringRef filename) -> File* {
|
||||
|
||||
Reference in New Issue
Block a user