-
Notifications
You must be signed in to change notification settings - Fork 386
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
Initialize ExecuteCommandProvider for the server's capabilities #424
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this only returns delegated commands. We also need to report the ones from the LSP extension provided by jdt.ls
Sorry my mistake, spec says it should be the commands executable from workspace/executeCommand
.
Mockito.when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies); | ||
InitializeResult result = initialize(false); | ||
List<String> commands = result.getCapabilities().getExecuteCommandProvider().getCommands(); | ||
assertTrue(commands.size() > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertFalse(commands.isEmpty())
Mockito.when(mockCapabilies.isExecuteCommandDynamicRegistrationSupported()).thenReturn(Boolean.TRUE); | ||
Mockito.when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies); | ||
InitializeResult result = initialize(true); | ||
assertTrue(result.getCapabilities().getExecuteCommandProvider() == null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertNull(result.getCapabilities().getExecuteCommandProvider())
|
||
@Test | ||
public void testExecuteCommandProvider() throws Exception { | ||
ClientPreferences mockCapabilies = Mockito.mock(ClientPreferences.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use static imports for Mockito stuff, makes the code less bloated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dynamic registration is missing from JDTLanguageServer.didChangeConfiguration(DidChangeConfigurationParams params)
retest this please |
@snjeza no, the client never receives the commands if dynamic registration is on, that's why you need to add it to JDTLanguageServer.didChangeConfiguration, just like the others. |
@@ -249,6 +249,13 @@ public void didChangeConfiguration(DidChangeConfigurationParams params) { | |||
unregisterCapability(Preferences.RENAME_ID, Preferences.TEXT_DOCUMENT_RENAME); | |||
} | |||
} | |||
if (preferenceManager.getClientPreferences().isExecuteCommandDynamicRegistrationSupported()) { | |||
if (preferenceManager.getPreferences().isExecuteCommandEnabled()) { | |||
registerCapability(Preferences.EXECUTE_COMMAND_ID, Preferences.WORKSPACE_EXECUTE_COMMAND); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty sure you need to return new ExecuteCommandOptions(new ArrayList<>(commands))
(see CodeLensOptions L233)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to update JDTLanguageServerTest as well
427d143
to
7e214f7
Compare
retest this please |
if (preferenceManager.getClientPreferences().isExecuteCommandDynamicRegistrationSupported()) { | ||
if (preferenceManager.getPreferences().isExecuteCommandEnabled()) { | ||
unregisterCapability(Preferences.EXECUTE_COMMAND_ID, Preferences.WORKSPACE_EXECUTE_COMMAND); | ||
registerCapability(Preferences.EXECUTE_COMMAND_ID, Preferences.WORKSPACE_EXECUTE_COMMAND, new ExecuteCommandCapabilities(true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ExecuteCommandCapabilities(true)/new ExecuteCommandOptions(new ArrayList<>(WorkspaceExecuteCommandHandler.getCommands())
Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
I have updated the PR. |
Ok so vscode receives:
|
The PR does the job, however, I'm wondering whether we should migrate all other commands (classFileContents, projectConfigurationUpdate, buildWorkspace) to |
Fixes #399
Signed-off-by: Snjezana Peco snjezana.peco@redhat.com