-
Notifications
You must be signed in to change notification settings - Fork 648
Get declaration diagnostics in LSP #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors how diagnostics are aggregated in the LSP endpoint and adds support for declaration diagnostics when emitDeclarations
is enabled.
- Consolidates syntactic, semantic, suggestion, and optional declaration diagnostics into a unified helper.
- Introduces
toLSPDiagnostics
to flatten multiple diagnostic slices. - Adds a conditional branch to include declaration diagnostics based on server options.
Comments suppressed due to low confidence (1)
internal/ls/diagnostics.go:22
- New behavior for declaration diagnostics is gated by
emitDeclarations
. Consider adding or updating tests to cover both enabled and disabled states to ensure correct inclusion/exclusion.
if program.Options().GetEmitDeclarations() {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably, these should just get moved into semantic diagnostics, but...
Eh, they're calculated in a separate pass (basically by doing the emit), so having them separate can be nice for callers that don't really care about them (or are already doing emit and can just pull the diagnostics from the emit step). There's no error category distinction in the editor really, though, you're right.
Do we think declaration diagnostics are stable enough to merge this, or should we wait until more of the module / module specifier code is in? |
#1051 pretty much finishes it out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, program
no longer has a diagnostic caching layer itself, so GetDeclarationDiagnostics
will actually fully recalculate them on every call. Not sure if that needs to be cached somewhere or not.
That's true but I think all callers all call once so it might be okay for now. I'll look into doing caching after |
Sent: #1058 |
The server also has to ask for these if enabled.
Arguably, these should just get moved into semantic diagnostics, but...
(Maybe this is too buggy/slow to expose in the editor at the moment?