-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GLSP-1117: Remove need for explicit definition of client actions
Refactor the base GLSP protocol to allow the client to tell the server which actions it is going to handle i.e. which actions should be forwarded to the client - Add `clientActions` array to `InitializeClientSessionParams`. This means the client now has to pass the action kinds it wants to handle as part of the initalize request - Refactor `ClientSessionManager` API directly use the `InitializeClientSessionParams` object for creating new sessions. This means that the `ClientSessionManager` can also access the generic `args` properties that might have been passed with the initialize request. - Replace `ClientActionHandler` with `ClientActionForwader` a separate component that is not part of the server-side action handlers. - Remove `configureClientActions` method from `DiagramModule` as the explicit configuration is no longer needed - Refactor `ClientIdModule` to `ClietnSessionModule` responsible for injection session specific configuration like the clientId and the clientActions
- Loading branch information
Showing
19 changed files
with
216 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...ns/org.eclipse.glsp.server/src/org/eclipse/glsp/server/actions/ClientActionForwarder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020-2023 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.glsp.server.actions; | ||
|
||
import static org.eclipse.glsp.server.di.ClientSessionModule.CLIENT_ACTIONS; | ||
|
||
import java.util.Set; | ||
|
||
import org.eclipse.glsp.server.di.ClientId; | ||
import org.eclipse.glsp.server.di.DiagramType; | ||
import org.eclipse.glsp.server.model.GModelState; | ||
import org.eclipse.glsp.server.protocol.GLSPClient; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Provider; | ||
import com.google.inject.Singleton; | ||
import com.google.inject.name.Named; | ||
|
||
/** | ||
* Component responsible for forwarding actions that are (also) handled by the | ||
* client. | ||
*/ | ||
@Singleton | ||
public class ClientActionForwarder { | ||
|
||
@Inject | ||
protected Provider<GLSPClient> client; | ||
|
||
@Inject | ||
protected GModelState modelState; | ||
|
||
@Inject | ||
@ClientId | ||
protected String clientId; | ||
|
||
@Inject | ||
@DiagramType | ||
protected String diagramType; | ||
|
||
@Inject | ||
@Named(CLIENT_ACTIONS) | ||
protected Set<String> clientActionKinds; | ||
|
||
/** | ||
* Processes the given action and checks wether it is a | ||
* `clientAction` i.e. andaction that should be forwared to | ||
* the client to be handled there. If the check is successful | ||
* the action is wrapped in an {@link ActionMessage} and sent to the client. | ||
* | ||
* @param action The action to check and forward | ||
* @return `true` if the action was forwared to the client, `false` otherwise | ||
*/ | ||
public boolean handle(final Action action) { | ||
if (shouldForwardToClient(action)) { | ||
ActionMessage message = new ActionMessage(clientId, action); | ||
client.get().process(message); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
protected boolean shouldForwardToClient(final Action action) { | ||
if (action.isReceivedFromClient()) { | ||
return false; | ||
} | ||
return (clientActionKinds.contains(action.getKind()) || action instanceof ResponseAction); | ||
} | ||
|
||
} |
67 changes: 0 additions & 67 deletions
67
plugins/org.eclipse.glsp.server/src/org/eclipse/glsp/server/actions/ClientActionHandler.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.