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

Create a callback function for vs code when editor selection changes. #241

Open
tpnbolwerk opened this issue Mar 29, 2023 · 5 comments
Open

Comments

@tpnbolwerk
Copy link

Is your feature request related to a problem? Please describe.
I want to create a way to visualize a selection in the editor of vs code. I could not find a way to get the vs code editor selection by using the rascal language server vs code extension.

Describe the solution you'd like
In RascalLSPConnection by adding the following lines we could get the active text editor selection information. We can propagate this e.g. to the webview like is done below, or create a callback function as an interface for Rascal.
vscode.window.onDidChangeTextEditorSelection((s) => {
const selection = vscode.window.activeTextEditor?.selection;
if(selection){
panel.webview.postMessage({selection : JSON.stringify(selection)})
}
});

Describe alternatives you've considered
I see no other way than changing the vs code extension in order to get access to the vs code API that supports the previously mentioned callback function, since in Rascal we do not have access to all its features.

Additional context
Add any other context or screenshots about the feature request here.

Copy link
Member

Interesting idea. Could be very useful for other things as well. I wonder if we could try and get some synergy with these features: microsoft/language-server-protocol#377 such that we don't extend the protocol in a direction that has to be changed later.

@DavyLandman
Copy link
Member

Also, if we would indeed pass it to the webview (after some dejittering), we would still need to do work to pass this back to rascal.

but i'm wondering, @tpnbolwerk is this for a DSL, or would you like it for any selection that happens?

@jurgenvinju
Copy link
Member

The general idea is to either use hover, with the additional location parameter as the rust people did, or connect it to the command interface such that the location is a command parameter. Other LSP s have extended in either direction. I'd like to find out which has the most chance of being included in the protocol for the long run.

@tpnbolwerk
Copy link
Author

I think the vs code rascal language server already has some information in its debugging output that we might use. This is the message when hovering in the DSL text document.

2023-04-25 08:46:05,700 [pool-3-thread-1] DEBUG - org.rascalmpl.vscode.lsp.parametric.ParametricTextDocumentService Hover: TextDocumentIdentifier [
  uri = "file:///example.dsl"
] at Position [
  line = 4
  character = 29
]

Is it possible to get this debugging information?

@DavyLandman
Copy link
Member

This functionality is trigger by the hover lsp for a DSL. This reads from the documentation in the summary, or calls the function provided as the documenter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants