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
Relevant for #472 and other LSP-related quality of life improvements.
This is potentially a pretty difficult issue, I think it's worth it though...
It would be lovely to be able to attach a quick-fix / code action (resolvable by the user in the editor) to an error emitted in the compiler.
Currently our error messages don't allow attaching code actions to them, some slight architectural workarounds might be needed in Kiama (see below).
Moreover, it should be relatively easy to add a new quick-fix to both an existing and a new error message in order to make doing the right thing easy :)
I'd personally prefer something slightly subtler for now, such as C.error("Expected 'new' before an object instance") { TextAction(pos, pos, "new ") }. I also think it's fine to hardcode it for a single possible quick-fix/code action for now.
Where to start
We need to pair a Kiama Message (a LSP Diagnostic) with a corresponding Kiama TreeAction (a LSP CodeAction).
As far as I can tell, we would need to dynamically register CodeActions based on the Diagnostics we currently have / sent to the user.
Relevant for #472 and other LSP-related quality of life improvements.
This is potentially a pretty difficult issue, I think it's worth it though...
It would be lovely to be able to attach a quick-fix / code action (resolvable by the user in the editor) to an error emitted in the compiler.
Currently our error messages don't allow attaching code actions to them, some slight architectural workarounds might be needed in Kiama (see below).
Moreover, it should be relatively easy to add a new quick-fix to both an existing and a new error message in order to make doing the right thing easy :)
As an example of how attaching a quick-fix to an error looks like, take a look at Scala 3:
https://github.com/scala/scala3/blob/e0c030ccd44089e70629b59d76962c1dfc8dbb16/compiler/src/dotty/tools/dotc/reporting/messages.scala#L871-L891
I'd personally prefer something slightly subtler for now, such as
C.error("Expected 'new' before an object instance") { TextAction(pos, pos, "new ") }
. I also think it's fine to hardcode it for a single possible quick-fix/code action for now.Where to start
We need to pair a Kiama
Message
(a LSPDiagnostic
) with a corresponding KiamaTreeAction
(a LSPCodeAction
).As far as I can tell, we would need to dynamically register
CodeActions
based on theDiagnostics
we currently have / sent to the user.I think this also means we'd need to store some Message ID -> CodeAction pairing somewhere? (Since the user can tell us relatively late that they want a code action for a message we no longer have?) Something like the
Notebook
storage here: https://github.com/effekt-lang/kiama/pull/3/files#diff-7539cc29669c287a1796c04d6a185e48593a9d59fe587322995b6f3f82a79671R183-R185. Note that this needs to be performant and it should know when to empty such a map...The text was updated successfully, but these errors were encountered: