Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
- Ensure that the ActionDispatchers postUpdateQueue is also cleared after  the inital `SetModelAction`
-  Change visibility of private members to protected for better extensibility
- Ensuare that Request and Response actions are initialized with an empty string as request/response id. This is required because otherwise typechecks on the client might fail
  • Loading branch information
tortmayr committed Jun 11, 2024
1 parent 2c110b6 commit bab3fbe
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static void initialize(final ILayoutMetaDataProvider... providers) {
@Inject
protected GModelState modelState;

private IGraphLayoutEngine engine = new RecursiveGraphLayoutEngine();
protected IGraphLayoutEngine engine = new RecursiveGraphLayoutEngine();

protected final ElkGraphFactory factory = ElkGraphFactory.eINSTANCE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class GLSPLayoutConfigurator extends LayoutConfigurator {

private static Pattern ID_REPLACE_PATTERN = Pattern.compile("\\W|^\\d");
public static final Pattern ID_REPLACE_PATTERN = Pattern.compile("\\W|^\\d");

public static String toElkId(final String gmodelId) {
if (gmodelId == null || gmodelId.isEmpty()) {
Expand All @@ -46,8 +46,8 @@ public static String toElkId(final String gmodelId) {
return ID_REPLACE_PATTERN.matcher(gmodelId).replaceAll("_");
}

private final Map<String, MapPropertyHolder> idOptionMap = Maps.newHashMap();
private final Map<String, MapPropertyHolder> typeOptionMap = Maps.newHashMap();
protected final Map<String, MapPropertyHolder> idOptionMap = Maps.newHashMap();
protected final Map<String, MapPropertyHolder> typeOptionMap = Maps.newHashMap();

/*
* Configure layout options for the model element with the given id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
* @param <RESPONSE> The type of the {@link ResponseAction}.
*/
public abstract class RequestAction<RESPONSE extends ResponseAction> extends Action {
private String requestId;
private final String requestId;

public RequestAction(final String kind) {
this(kind, "");
}

public RequestAction(final String kind, final String requestId) {
super(kind);
this.requestId = requestId;
}

public String getRequestId() { return requestId; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ResponseAction extends Action {

public ResponseAction(final String kind) {
super(kind);
responseId = "";
}

public String getResponseId() { return responseId; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ protected Class<? extends SourceModelWatcher> bindSourceModelWatcher() {
return null;
}

private Class<? extends GraphGsonConfigurationFactory> bindGraphGsonConfiguratorFactory() {
protected Class<? extends GraphGsonConfigurationFactory> bindGraphGsonConfiguratorFactory() {
return DefaultGraphGsonConfigurationFactory.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
*/
public class ServerModule extends GLSPModule {
public static final String DIAGRAM_MODULES = "Diagram_Modules";
private final Map<String, Module> diagramModules = new HashMap<>();
protected final Map<String, Module> diagramModules = new HashMap<>();

/**
* Configure a new {@link DiagramModule} for this server. A diagram module represents the base configuration artifact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class GModelStorage implements SourceModelStorage {

private static Logger LOGGER = LogManager.getLogger(GModelStorage.class);
private static String EMPTY_ROOT_ID = "glsp-graph";
public static final String EMPTY_ROOT_ID = "glsp-graph";

@Inject
protected GModelState modelState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.glsp.server.actions.ResponseAction;
import org.eclipse.glsp.server.di.ClientId;
import org.eclipse.glsp.server.disposable.Disposable;
import org.eclipse.glsp.server.features.core.model.SetModelAction;
import org.eclipse.glsp.server.features.core.model.UpdateModelAction;
import org.eclipse.glsp.server.protocol.GLSPClient;
import org.eclipse.glsp.server.utils.FutureUtil;
Expand Down Expand Up @@ -200,7 +201,7 @@ protected List<CompletableFuture<Void>> runAction(final Action action) {
.collect(Collectors.toList());
results.addAll(dispatchAll(responses));
}
if (action instanceof UpdateModelAction) {
if (action instanceof UpdateModelAction || action instanceof SetModelAction) {
results.add(dispatchPostUpdateQueue());
}
return results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public abstract class GLSPServerLauncher {

private static Logger LOGGER = LogManager.getLogger(GLSPServerLauncher.class);
private final List<Module> modules;
protected final List<Module> modules;

public GLSPServerLauncher(final ServerModule serverModule, final Module... additionalModules) {
modules = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public class SocketGLSPServerLauncher extends GLSPServerLauncher {
public static final String START_UP_COMPLETE_MSG = "[GLSP-Server]:Startup completed. Accepting requests on port:";
private static Logger LOGGER = LogManager.getLogger(SocketGLSPServerLauncher.class);

private ExecutorService threadPool;
private AsynchronousServerSocketChannel serverSocket;
private CompletableFuture<Void> onShutdown;
protected ExecutorService threadPool;
protected AsynchronousServerSocketChannel serverSocket;
protected CompletableFuture<Void> onShutdown;

public SocketGLSPServerLauncher(final ServerModule serverModule, final Module... additionalModules) {
super(serverModule, additionalModules);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final class ClientOptionsUtil {
public static final String DIAGRAM_TYPE = "diagramType";
public static final String SOURCE_URI = "sourceUri";
public static final String IS_RECONNECTING = "isReconnecting";
private static final String FILE_PREFIX = "file://";
public static final String FILE_PREFIX = "file://";

private ClientOptionsUtil() {}

Expand Down

0 comments on commit bab3fbe

Please sign in to comment.