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
15 stars 8 forks source link

Make it easier to call rascal LSP commands by helping the user translate to rascal call #342

Open DavyLandman opened 12 months ago

DavyLandman commented 12 months ago

Is your feature request related to a problem? Please describe. currently a user of a lsp command, has to (when not invoked as part of a code-lens) call vscode.commands.executeCommand, with rascal-meta-command as target (in deployment mode the language name is suffixed to it), and then the next argument is a full rascal value in a javascript string.

The user has to take care to translate JS types to rascal literals. This can be error prone (quoting of strings/escaping of nested quotes & back slashes).

Describe the solution you'd like

If we were to extend the command handler with a second mode that would take JS values and translates them as good as we can to a rascal value.

// original mode:
vscode.commands.executeCommand("rascal-meta-command", "calcX("A string \\\" with nested \\\\ stuff gets messy", |file:///x.txt|)");

// second mode (only triggered if more than 1 argument:
vscode.commands.executeCommand("rascal-meta-command", "calcX", "A string \" with nested \\ stuff gets messy", vscode.Uri.file("/x.txt"));

Which would:

urbanfly commented 12 months ago

The 'original mode' example demonstrates the difficulty with escaping strings correctly - it is not escaping the quotes that surround the inner string.

// original mode:
vscode.commands.executeCommand("rascal-meta-command", "calcX(\"A string \\\" with nested \\\\ stuff gets messy\", |file:///x.txt|)");