-
Notifications
You must be signed in to change notification settings - Fork 409
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
Experimental client-side command executions #596
Changes from 3 commits
f735011
3f74781
66aa25d
666012b
3909f03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'd be Pivotal :-) |
||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.lsp; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.eclipse.lsp4j.ExecuteCommandParams; | ||
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest; | ||
|
||
public interface ExecuteCommandProposedClient { | ||
|
||
@JsonRequest("workspace/executeClientCommand") | ||
CompletableFuture<Object> executeClientCommand(ExecuteCommandParams params); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually need to wait for the client to respond? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is a good idea yes. One possible and useful scenario is an error results because the command was deregistered. If command is a kind of 'callback' as in our case, then this may be a good way to trigger cleanup of the callback table. I've experimented with a more 'proper' cleanup. But as this tends to happen around the same time as server is in the process of shutting down... its not very reliable (messages no longer able to send etc.). Anyhow... callers wanting to catch errors and responding to them seems to be a good enough reason. And I could also imagine that the command could return useful information (not in our use case, but if it used in a more 'request -> response fashion, rather than a callback it could be). |
||
|
||
} |
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.
should probably add a timeout
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.
That raises the question... how long should the timeout be? Or should we change this api and return the CompletableFuture? Then the caller can decide how long they want to wait... or if they want to continue with an async composition instead.
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.
Hmmm... returning CompletableFuture seems a bit 'out of style' with the rest of the api in the same class. I called join because I as trying to follow similar pattern as other stuff in the same class. E.g. like here:
https://github.com/kdvolder/eclipse.jdt.ls/blob/66aa25d44cea30d2fdf90b30058508772b990b48/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JavaClientConnection.java#L107