Skip to content
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

#435 Fix Navigation from marker to affected element is no longer working #47

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ public class IdeActionDispatcher extends DefaultActionDispatcher {
protected final ModelInitializationConstraint initializationConstraint;

@Inject
public IdeActionDispatcher(final Injector injector, @ClientId() final String clientId,
public IdeActionDispatcher(@ClientId() final String clientId,
final ModelInitializationConstraint initializationConstraint) {
super();
this.clientId = clientId;
this.initializationConstraint = initializationConstraint;
this.onModelInitialized = initializationConstraint.onInitialized();
this.onModelInitialized.thenRun(() -> LOGGER.info("Model Initialized."));
}

@Inject
public void initInjector(final Injector injector) {
GLSPIdeEditorPlugin.getDefaultGLSPEditorRegistry().getGLSPEditor(clientId)
.ifPresent(editor -> editor.setInjector(injector));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@

import org.eclipse.glsp.ide.editor.actions.InitializeCanvasBoundsAction;
import org.eclipse.glsp.server.actions.Action;
import org.eclipse.glsp.server.features.core.model.UpdateModelAction;
import org.eclipse.glsp.server.features.core.model.SetModelAction;

/**
* Default initialization constraint triggers after a non-empty UpdateModelAction and a subsequent
* InitializeCanvasBoundsAction.
*/
public class DefaultModelInitializationConstraint extends AbstractModelInitializationConstraint {

private boolean nonEmptyUpdateModelActionDispatched;
private boolean nonEmptySetModelActionDispatched;

@Override
protected boolean isInitializedAfter(final Action action) {
nonEmptyUpdateModelActionDispatched = nonEmptyUpdateModelActionDispatched || isNonEmptyUpdateModelAction(action);
return nonEmptyUpdateModelActionDispatched && isInitializeCanvasBoundsAction(action);
nonEmptySetModelActionDispatched = nonEmptySetModelActionDispatched || isNotEmptySetModelAction(action);
return nonEmptySetModelActionDispatched && isInitializeCanvasBoundsAction(action);
}

private static boolean isNonEmptyUpdateModelAction(final Action action) {
return action instanceof UpdateModelAction
&& ((UpdateModelAction) action).getNewRoot() != null
&& !Objects.equals(((UpdateModelAction) action).getNewRoot().getType(), "NONE");
private static boolean isNotEmptySetModelAction(final Action action) {
return action instanceof SetModelAction
&& ((SetModelAction) action).getNewRoot() != null
&& !Objects.equals(((SetModelAction) action).getNewRoot().getType(), "NONE");
}

private static boolean isInitializeCanvasBoundsAction(final Action action) {
Expand Down