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

Move findReferences in LSPEclipseUtils #282

Closed
wants to merge 1 commit into from

Conversation

angelozerr
Copy link
Contributor

Move findReferences in LSPEclipseUtils

This PR provide the capability to move the search LSP references in the LSPEclipseUtils in order to use it in another plugin / component.

I need that to fix eclipse-wildwebdeveloper/wildwebdeveloper#644 in order to execute the LSP search references from CodeLens with XML language server.

@angelozerr
Copy link
Contributor Author

@angelozerr
Copy link
Contributor Author

To see the result with XML references in WWD, see eclipse-wildwebdeveloper/wildwebdeveloper#942 (comment)

if (languageServers.isEmpty()) {
return;
}
LanguageServer ls = languageServers.get(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize you are just moving the code, but is the general pattern not to loop over all LSs, why take here just the first one?

@mickaelistria
Copy link
Contributor

I'm not found of the idea of crowding LSPEclipseUtils with "functional" units; it's mostly a set of utils to translate LSP<->Eclipse elements and actions; not a util class that's meant at orchestrating the Language Servers. So I would rather see the references package being exported than this code being moved.
Also, I'm wondering if we could have the initial feature part of LSP by default? This particular pattern of showing references in CodeLens and having a click opening them seems relatively independent of the LS, so could we instead host the handlers in LSP4E and make that consumer should just bind their specific command ids (eg xml.show.references) to this handler?

@angelozerr
Copy link
Contributor Author

angelozerr commented Nov 7, 2022

Also, I'm wondering if we could have the initial feature part of LSP by default? This particular pattern of showing references in CodeLens and having a click opening them seems relatively independent of the LS, so could we instead host the handlers in LSP4E and make that consumer should just bind their specific command ids (eg xml.show.references) to this handler?

It is exactly that I tried to explain here eclipse-wildwebdeveloper/wildwebdeveloper#644 (comment) in otherwords standardize some client command because I use a custom structure uri as first argument and line/character at the second arguments.

If you wish to provide that in LSP4e it means other LSP server should use the same structure, it was the reason why I wanted to standardize those client command at microsoft/vscode-languageserver-node#495 (comment)

@mickaelistria
Copy link
Contributor

It is exactly that I tried to explain here eclipse-wildwebdeveloper/wildwebdeveloper#644 (comment) in otherwords standardize some client command because I use a custom structure uri as first argument and line/character at the second arguments.

OK, I didn't understand the grain of action. But now we're a bit forward and the goal and proposal is clearer, I think it's indeed worth adding the handlers in LSP4E for such standard structures and commands.

@angelozerr
Copy link
Contributor Author

OK, I didn't understand the grain of action. But now we're a bit forward and the goal and proposal is clearer, I think it's indeed worth adding the handlers in LSP4E for such standard structures and commands.

IMHO I think LSP should specify standard command ID like lsp.showReferences and after that any language server could generate codelens with this standar command id, but I fear it will never done.

I tried to define lsp4e.showReferences but Ihave no idea how to bind / associate / alias ?this command ID with the custom ID of XML language server xml.show.references. I wonder if we could define this mapping with extension point like this:

<extension
         point="org.eclipse.lsp4e.languageServer">
      <server>
   ...
      </server>
      <commandMapping
            standardCommandId="lsp4e.showReferences"
            commandId="xml.show.references">

@angelozerr
Copy link
Contributor Author

@mickaelistria do you like the idea with commandMapping extension point? If you like it I could experiment it.

@mickaelistria
Copy link
Contributor

I'm fine with LSP4E defining an Eclipse command or a handler for such common operation.
About a command mapping/alias, I don't think it should be LSP4E but the Eclipse command framework hosting this functionality.

@mickaelistria
Copy link
Contributor

I'm curious: does VSCode has the concept of generic and reusable commands? Doesn't it define a common findreference command? If yes, we could just have LSP4E adopting the same ids as VSCode and try to have lemminx using those common command ids.

If not, I see 2 other good solutions:

  1. Create a strategy to define alias commands (in Platform ideally), or
  2. make LemMinX look at the LSP client id (provided by the client to the server as part of InitializationOptions) and return the LSP4E command ids when it's LSP4E running.

My favorite is 1.

@angelozerr
Copy link
Contributor Author

Create a strategy to define alias commands (in Platform ideally), or

I fear it will take some time to do that, and I need this feature for WWD.

make LemMinX look at the LSP client id (provided by the client to the server as part of InitializationOptions) and return the LSP4E command ids when it's LSP4E running.

It will work only with LemMinx and not with another LS language server which could not provide this feature.

I'm curious: does VSCode has the concept of generic and reusable commands?

Indeed vscode defines some commands https://vscode-docs.readthedocs.io/en/latest/extensionAPI/vscode-api-commands/ and for references it defines editor.action.showReferences, but it works with vscode structure and not with lsp structure. In other I defined the LemMinx references command and call the vscode editor.action.showReferences by translating LSP structure to vscode structure https://github.com/redhat-developer/vscode-xml/blob/698f913553d2063cd6d9d72f18b53ae766e71ff1/src/commands/registerCommands.ts#L114

I think we could follow the same idea (I don't know if it is possible):

  • LSP4e defines a command lsp4e.showReferences
  • WWD XML defines a command lemminx.showReferences with an handler class which call lsp4e.showReferences.

Once Platform will define a command mapping, WWD could use it and remove the lemminx.showReferences handler class.

@mickaelistria
Copy link
Contributor

LSP4e defines a command lsp4e.showReferences

LSP4E already defines a handler for org.eclipse.ui.genericeditor.findReferences command.
This handler can be improved to read an (optional) parameter which would be used with a code lens, and if this parameter is not set, use current selection as it does now.

WWD XML defines a command lemminx.showReferences with an handler class which call lsp4e.showReferences.

We can try that for the moment. Wild Web Developer can create a "delegating" handler for its specific command, using command and handler services to retrieve the org.eclipse.ui.gemericeditor.findReferences command/handler and implement enablement/execution by delegating to it.

@eclipsewebmaster eclipsewebmaster deleted the branch eclipse:master May 21, 2024 14:09
@mickaelistria
Copy link
Contributor

The initial target branch master was deleted and replaced by main, so this PR got closed automatically. If this is still relevant, please re-create this PR targetting the main branch.

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

Successfully merging this pull request may close these issues.

Clicking XML CodeLens link results in Unhandled event loop exception
4 participants