Skip to content

Commit

Permalink
Fix upgrade/refactor dialog popping up more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed May 1, 2024
1 parent 4ca41cf commit 71bcc7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.lsp4e.LanguageServers;
import org.eclipse.lsp4e.LanguageServersRegistry;
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
import org.eclipse.lsp4j.ExecuteCommandOptions;
import org.eclipse.lsp4j.ExecuteCommandParams;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
Expand Down Expand Up @@ -86,7 +87,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException {

try {

LanguageServers.forProject(project).withPreferredServer(def).computeFirst(ls -> {
LanguageServers.forProject(project).withPreferredServer(def).withFilter(c -> {
ExecuteCommandOptions commandProvider = c.getExecuteCommandProvider();
return commandProvider != null && commandProvider.getCommands().contains(REWRITE_REFACTORINGS_EXEC);
}).computeFirst(ls -> {

PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
RecipeTreeModel recipesModel = new RecipeTreeModel(ls.getWorkspaceService(), recipeFilter.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public JpqlSupportState(SimpleLanguageServer server, ProjectObserver projectObse
this.server = server;
this.enabled = enabled;
config.addListener(v -> setEnabled(config.isJpqlEnabled()));
projectObserver.addListener(ProjectObserver.onAny(jp -> server.getAsync().execute(() -> server.getClient().refreshSemanticTokens())));
projectObserver.addListener(ProjectObserver.onAny(jp -> {
if (enabled && server.getWorkspaceService().supportsSemanticTokensRefresh()) {
server.getAsync().execute(() -> server.getClient().refreshSemanticTokens());
}
}));
}

public synchronized boolean isEnabled() {
Expand Down

0 comments on commit 71bcc7a

Please sign in to comment.