kcl icon indicating copy to clipboard operation
kcl copied to clipboard

[LFX] LSP quick fix for kcl compiler

Open He1pa opened this issue 1 year ago • 7 comments
trafficstars

Provide quick fix capability with LSP for kcl compiler image

How to apply

  1. Submit an application on the LFX membership platform.
  2. Complete the pretest
  3. Wait for the result

Pretest

To apply for this mentorship, you MUST finish a pre-test. Pre-test link: https://github.com/kcl-lang/kcl/issues/1020

Detail

+ According to different errors, provide different quick_fix schemes in the KCL compiler,

That is, provide suggested_replacement in the structure below. Now, this field is almost entirely None

pub struct Message {
    pub range: Range,
    pub style: Style,
    pub message: String,
    pub note: Option<String>,
    pub suggested_replacement: Option<String>,
}

This field will be processed as a CodeAction response in the LSP, and provide quick fix capability in editor.

Appendix

LSP Overview:

  • https://code.visualstudio.com/api/language-extensions/overview
  • https://code.visualstudio.com/api/language-extensions/language-server-extension-guide

LSP spec:

  • https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeAction

quick fix impl pr:

  • https://github.com/kcl-lang/kcl/pull/652

He1pa avatar Jan 24 '24 06:01 He1pa

Hey @He1pa I would like to work on this issue under the LFX Mentorship Program. Since the LFX Mentorship is not started yet, and is under project proposal period, I would like to break down this issue and start creating some child issues to QuickStart the work //cc @zong-zhe

Ishani217 avatar Jan 24 '24 18:01 Ishani217

Hi! I would like to work on this issue under the upcoming LFX term. Are there any related issues to the same, which I can parse through or try to solve as pre-tasks for the same?

EshaanAgg avatar Feb 01 '24 12:02 EshaanAgg

Hi! I would like to work on this issue under the upcoming LFX term. Are there ant related issues to the same, which I can parse through or try to solve as pre-tasks for the same?

Sorry, I didn't understand what you meant 'Are there ant related issues to the same'? But if you are interested in this, you can take a look at the previous PR first: https://github.com/kcl-lang/kcl/pull/652 This is a very simple demo that achieves the effect in the picture above. It replaces the useless import stmt with an empty string so user can remove it by click in editor.

You can learn about LSP, https://code.visualstudio.com/api/language-extensions/overview

Finally, You can try to set up a development environment (Rust & LLVM), build an LSP binary locally and install the KCL extension(https://marketplace.visualstudio.com/items?itemName=kcl.kcl-vscode-extension) to experience it.

He1pa avatar Feb 02 '24 03:02 He1pa

Hi @He1pa! Thanks for the detailed response. Since this is an LFX issue, I thought the same would be frozen for contributors until the mentees are officially announced, and thus, I asked for any other related child issues, sort of qualifying tasks for the term.

EshaanAgg avatar Feb 02 '24 05:02 EshaanAgg

Hi @He1pa! Thanks for the detailed response. Since this is an LFX issue, I thought the same would be frozen for contributors until the mentees are officially announced, and thus, I asked for any other related child issues, sort of qualifying tasks for the term.

Do you want me to provide a pretest to determine candidates? I will provide a new issue as soon as possible, this issue is to solve a smaller but related problem

He1pa avatar Feb 02 '24 05:02 He1pa

hey @He1pa , I would like to work on this

7h3-3mp7y-m4n avatar Feb 04 '24 10:02 7h3-3mp7y-m4n

Hi @He1pa! Thanks for the detailed response. Since this is an LFX issue, I thought the same would be frozen for contributors until the mentees are officially announced, and thus, I asked for any other related child issues, sort of qualifying tasks for the term.

Do you want me to provide a pretest to determine candidates? I will provide a new issue as soon as possible, this issue is to solve a smaller but related problem

Hey @He1pa, can you please shed some light on the scope of this project ? Specifically, which types of errors or warnings are expected to be quick fixed ? Does the project cover every error possible ? Thanks in advance.

I have prior experience in building custom linters and custom fixes for errors. Please look at this issue where I created a documentation checking linter from scratch for the Dart/Flutter codebase, and this PR where I implemented quick fixes for the same.

Excited to work on this project.

literalEval avatar Feb 13 '24 12:02 literalEval

Dup with #1125

Peefy avatar Apr 09 '24 09:04 Peefy