usethesource / rascal-language-servers

An LSP server for Rascal which includes an easy-to-use LSP generator for languages implemented in Rascal, and an interactive terminal REPL.
BSD 2-Clause "Simplified" License
10 stars 7 forks source link

Quick fix #383

Open jurgenvinju opened 1 month ago

jurgenvinju commented 1 month ago

Describe the bug

Like to have a feature to trigger quick fixes on diagnostic messages.

Expected behavior

data Message (Command quickfix=noop());

That would allow the checker that produces a message to attach any Command.

When the user selects the quickfix, the command is sent over de LSP bridge to the server. The server will have a CommandExecutor ready (the same that also handles the lenses).

Open to any kind of information that can be serialized as a rascal value. So no limits.

DavyLandman commented 1 month ago

I think this is done with the code actions, where you can connect a refactoring to and diagnostic error. In that way there is a quick fix. So if we do this right (when implementing refactorings) well het this.

If you don't mind I'll tag this as feature request, not a bug.

jurgenvinju commented 1 month ago

So if we do this right (when implementing refactorings) well het this.

that does not make sense to me. I'm asking for a specific feature that links the "refactorings" or "quickfixes" that are embedded in our Message format to the code actions.

They are all "code actions", refactorings, quickfixes and lense commands alike, and they all need to be evaluated by the same command executor that the Rascal developers writes for their LSP server via util::LanguageServer

The difference lies in the way the user chooses for the action and fills in parameters.

DavyLandman commented 1 month ago

My understanding:

That lead me to reason that we should consider merging the quick-fix work with the effort to bring refactorings to rascal-lsp. I understand your point that quick-fixes are less complex than regular refactorings, as they require no extra interaction of user input (however, to be clear, CodeActions do not contain a way to model any of that input either). I wanted to point out that a lot of the mechanisms for registering & dealing with them are overlapping with generic refactorings. Especially since the UI interactions that would be needed for other style of refactoring will require a different part of the API.

If you prefer we split this up, we could try that indeed, but I fear that effort wise it would only save off a bit.