- Notifications
You must be signed in to change notification settings - Fork 151
Closed
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededlangserverlsp
Description
Provide quick fix with LSP for this case.
What you need to do:
- Find the place where this error is generated in the kcl compiler(~/kclvm/sema/src/resolver/scope.rs lookup_type_from_scope() and set_type_to_scope()) and fill in
suggested_replacement
in the structure representing the error. In this case it would beSome("aaa")
- Convert KCL's Diagnostic to LSP's Diagnostic. Most of the work is already done, but you need to convert
suggested_replacement
into thedata
field.
pub struct Diagnostic { /// The range at which the message applies. pub range: Range, ... /// A data entry field that is preserved between a `textDocument/publishDiagnostics` /// notification and `textDocument/codeAction` request. pub data: Option<serde_json::Value>, }
- handle the
CodeActionRequest
and provide a quick fix response. you can ref this pr: feat: lsp quick fix #652. This is a very simple demo that fix warning about useless import. It replaces the useless import stmt with an empty string. But you need to get thenew_text
from RequestParam(The IDE will return thedata
generated in the previous step as a parameter) - Install KCL extension within VSCode and build lsp binary locally, add the
kcl-language-server
to PATH - After completing above, you can see a button like this in the IDE (VSCode). Click the button and the IDE will fix the incorrect code (aa->aaa)
You can fork this repository and develop in your own repository. After completion, you can contact me via email or slack. Of course, if you have any questions during this process, you can also contact me
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededlangserverlsp