-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code actions for dsls #402
Conversation
…tic messages can carry a list of quickfixes. Only for DSLs though
Will post some screenshots later. This is still a draft. |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Looking for suggestions on how to improve the asynchronous code and suggestions how to test the UI part of this. It's most LSP integration code. The algorithm for generating focus lists could be tested as a unit. |
…bles a better UX by default for actions with diagnostics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code is ready for merging. @jurgenvinju when all the test has passed, you do the honors 🎉
Quality Gate passedIssues Measures |
Done. This was a very nice collab @DavyLandman |
This PR connects the
codeActions
LSP server service for the parametrized LSP server (so for DLSs).CodeActionContributor
is of typelist[Command] (list[Tree] focus)
and registered withdata LanguageService = codeActionContributor(CodeActionContributor actions)
. The "focus" tells us which parse trees are active on the given line and column of the current cursor, ordered with the most specific (smallest) trees first and ending always with thestart
tree.Pico example, where we are looking for a cursor position over an
IdType
somewhere in astart[Program]
, and we register the commandremoveDecl
which can be interpreter later:Command
s are used just like the lenses. They need to be evaluated by the commandExecutor contribution.Message
can now have a keyword parameter:data Message(list[Command] fixes=[])
. Every message that is registred with the LSP client (e.g. via a Summary), will lead to a contributed code action when the cursor is at theat
location of the info, warning or error message.demo::lang::pico::LanguageServer
demonstrates these two different ways of contributing actions (see above). Below the Message alternative:The
error
constructor now receives an additionalfixes
keyword field with a list of options on how to fix the broken variable reference. Each generated command fixes the bug in its own way (with a different variable name to use).