You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 be Some("aaa")
Convert KCL's Diagnostic to LSP's Diagnostic. Most of the work is already done, but you need to convert suggested_replacement into the data 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 the new_text from RequestParam(The IDE will return the data 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
The text was updated successfully, but these errors were encountered:
Do we need to create a gist for this or how do we present our solutions? cc @He1pa@Peefy
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
Provide quick fix with LSP for this case.
What you need to do:
suggested_replacement
in the structure representing the error. In this case it would beSome("aaa")
suggested_replacement
into thedata
field.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)kcl-language-server
to PATHYou 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
The text was updated successfully, but these errors were encountered: