From 621427e2404766115fdf11c3f67086ac5bc5abda Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 23 Oct 2024 11:23:58 +0200 Subject: [PATCH 1/2] moved definitions of Message, Command and CodeAction from util::LanguageServer in rascal-lsp to standard library util::IDEServices --- .../rascalmpl/library/util/IDEServices.rsc | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/util/IDEServices.rsc b/src/org/rascalmpl/library/util/IDEServices.rsc index 32950e82142..2950b0458af 100644 --- a/src/org/rascalmpl/library/util/IDEServices.rsc +++ b/src/org/rascalmpl/library/util/IDEServices.rsc @@ -4,7 +4,6 @@ extend analysis::diff::edits::TextEdits; extend Content; extend Message; - @synopsis{Open a browser for a given location.} @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} java void browse(loc uri, str title = "", int viewColumn=1); @@ -45,3 +44,28 @@ public java void registerDiagnostics(list[Message] messages); @javaClass{org.rascalmpl.library.util.IDEServicesLibrary} public java void unregisterDiagnostics(list[loc] resources); + +@synopsis{Fixes are an extension to error messages that allow for interactive code fixes in the IDE.} +@description{ +This definition adds lists of ((CodeActions)) as optional fields to any message. In collaboration +with a language server, these messages then lead to interactive quick fixes in IDEs. +} +data Message(list[CodeAction] fixes = []); + +@synopsis{Code actions bundle synchronous text edits and command execution with a title for the menu option.} +@description{ +For any action instance, the IDE will: +* show a menu option with the given title. +* if the title is selected, then the (optional) edits will be executed first +* and then the (optional) command is executed via the `execution` service of the language service protocol. +} +data CodeAction + = action(list[DocumentEdit] edits = [], Command command = noop(), str title = command.title); + +@synopsis{Commands are an open data-type for describing interactive functions that may be attached to CodeActions.} +@description{ +Commands are simply immutable constructors with parameters. To use a command you can attach it to a ((Message)) +via a ((CodeAction)), and then have it executed by the respective language server. +} +data Command(str title="") + = noop(); From bb6043b4a6860b585285bf1e2032d9d951a20baf Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 23 Oct 2024 20:05:54 +0200 Subject: [PATCH 2/2] fixed documentation links --- src/org/rascalmpl/library/util/IDEServices.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/library/util/IDEServices.rsc b/src/org/rascalmpl/library/util/IDEServices.rsc index 2950b0458af..2de6d3fac2a 100644 --- a/src/org/rascalmpl/library/util/IDEServices.rsc +++ b/src/org/rascalmpl/library/util/IDEServices.rsc @@ -47,7 +47,7 @@ public java void unregisterDiagnostics(list[loc] resources); @synopsis{Fixes are an extension to error messages that allow for interactive code fixes in the IDE.} @description{ -This definition adds lists of ((CodeActions)) as optional fields to any message. In collaboration +This definition adds lists of ((CodeAction))s as optional fields to any message. In collaboration with a language server, these messages then lead to interactive quick fixes in IDEs. } data Message(list[CodeAction] fixes = []); @@ -64,7 +64,7 @@ data CodeAction @synopsis{Commands are an open data-type for describing interactive functions that may be attached to CodeActions.} @description{ -Commands are simply immutable constructors with parameters. To use a command you can attach it to a ((Message)) +Commands are simply immutable constructors with parameters. To use a command you can attach it to a ((module:Message)) via a ((CodeAction)), and then have it executed by the respective language server. } data Command(str title="")