Skip to content
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

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

Open
DavyLandman opened this issue Dec 6, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@DavyLandman
Copy link
Member

DavyLandman commented Dec 6, 2023

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:

  • translate strings/bool/numbers to rascal literals
  • translate vscode.Uri / Ranges / Positions to source locations (with correct translation of offsets/columns)
  • translate arrays to lists, sets to sets
  • the rest of the objects to JSON representation inside of a string
@DavyLandman DavyLandman added enhancement New feature or request good first issue Good for newcomers labels Dec 6, 2023
@urbanfly
Copy link

urbanfly commented Dec 7, 2023

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|)");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants