Open jurgenvinju opened 1 week ago
Will post some screenshots later. This is still a draft.
Failed conditions
C Reliability Rating on New Code (required ≥ A)
See analysis details on SonarCloud
Catch issues before they fail your Quality Gate with our IDE extension SonarLint
lightbulb appears next to error message:
CMD+dot activates menu:
Selecting the right option fixes the issue:
Code for the quickfix:
// attaches multiple quickfix command options to every error (one for every proposed new name):
s.messages += {<src, error("<id> is not defined", src, fixes=[changeToFix(src, existing<0>, title="Change to <existing<0>>") | existing <- defs])>
| <src, id> <- uses, id notin defs<0>};
// executes the command:
value picoCommands(changeToFix(loc src, str newName)) {
applyDocumentsEdits([changed(src.top, [replace(src, newName)])]);
return ("result": true);
}
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.
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).