Show references command

Hello!

I’m trying to run vscode-java extension as a plugin in Theia. This extension wants to execute editor.action.showReferences but as I see in https://github.com/theia-ide/theia/blob/master/packages/monaco/src/browser/monaco-command.ts#L124 the command to show references is registered with different id (textEditor.commands.showReferences). So if some plugin executes (editor.action.showReferences) it won’t find this command because it was registered as textEditor.commands.showReferences. Should this command be registered with editor.action.showReferences id?

[original thread by Valeriy Svydenko]

We should NOT change ids of existing commands. Changing existing command can break existing clients.

But introduce new commands in plugin-ext-vscode extension delegating to existing commands. When we don’t need to check whether existign command can be removed or not.

[Valeriy Svydenko]

I’ve created an issue for that https://github.com/theia-ide/theia/issues/4084

AFAIK the command alias should be in plugin-ext as the name is generic enough to be used for all plug-ins. (not only in vscode model)
Also is that possible to deprecate older name of commands when they’re close but not the same than in VSCode ?
So for example we may remove them in a future.

I think we should align with vs code commands, at least that should be our longterm goal. I’d prefer to change the commands and register the old one as deprecated somehow.

ok, if we announce it somewhere, changelog?

I’ve just realized that we already have editor.action.showReferences command registered by Monaco

our textEditor.commands.showReferences is implemented via it https://github.com/theia-ide/theia/blob/33590a9a8fc9899fdd0f0ed57cb3ea4871adf6e1/packages/monaco/src/browser/monaco-command.ts#L134

if we rename textEditor.commands.showReferences to editor.action.showReferences then it will override Monaco command

@vsvydenko are you sure that editor.action.showReferences does not work at the moment? to me it looks like it is already there and does exactly what we want

ok, not totally, Monaco 1-based, VS Code api 0-bazed

I don’t think we can replace editor.action.showReferences, it would break Find References Monaco feature

Would it be possible to intercept a command call from plugins, do conversion of positions/locations and then call our command registry?

[Valeriy Svydenko]

It doesn’t work because the handler was registered with id textEditor.commands.showReferences but plugin searches editor.action.showReferences in command.CommandRegistry. I think we can redirect editor.action.showReferences command to textEditor.commands.showReferences as it was done here https://github.com/theia-ide/theia/blob/master/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts#L35

yes, something like that should work

There are a bunch of commands that are predefined in vscode: vscode extensions may rely on them being present:

I think we’ll have to provide them all if we want to be vscode-compatible.