microsoft / microsoft/language-server-protocol
Reconsider `Diagnostic.actions` (`CodeAction` property) for quickfix
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13k
- Forks
- 1k
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 10
Description
Ref https://github.com/microsoft/language-server-protocol/issues/581
Ref https://github.com/microsoft/language-server-protocol/issues/887
Problem
Hi, I am a maintainer of Scala language-related tooling, for example its incremental compiler Zinc etc.
We are currently in the process of implementing actionable diagnostics, which allows the Scala compiler and build tools to expose code edit suggestions via Diagnostic. Likely this will proceed using the Diagnostic.data.actions field.
As far as I can tell, most languages interested in using Diagnostic.data are interested in passing along CodeAction quick fixes. So far:
Am I wrong to assume that not having this standardized means that the LSP clients need to implement the embedded CodeAction support one by one for each language?
Possible Solution
I think this is a clear signal that we should standardize list of CodeAction as Diagnostic.actions. Maybe it could be paired with WorkspaceEditClientCapabilities to opt-into or out of having actions attached.
Notes
The primary reason "quick fix" did not happen previously seems to be based on the assumption that that computing the code suggestion would be expensive. Some code suggestions might be, but:
- There are many other cheap code fixes, often already suggested via deprecation warning messages. See for example https://github.com/scala/scala/pull/10406.
- There are also some class of warnings that only compiler can accurately emit because it has the precise knowledge that is often expensive for external linters to re-emulate. In Scala community, there are syntactic Scalafix and semantic Scalafix, and the latter can be very slow. An example of this is unused
importstatement. Another example is organizingimportstatements, becauseimportin one line can affect the imports in latter lines.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the referenced language-server-protocol issues 581 and 887, then compare the proposed Diagnostic.actions property with the existing Diagnostic.data.actions approach described here. Determine whether CodeAction quick fixes should be standardized and how WorkspaceEditClientCapabilities would opt in or out; done means reaching and documenting a protocol decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100