Skip to content

Commit

Permalink
perf: don't force the start language server for menu action
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Sep 20, 2024
1 parent 04998bf commit eca7ca6
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.ServerCapabilities;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import static com.redhat.devtools.lsp4ij.internal.CompletableFutures.isDoneNormally;

Expand All @@ -39,8 +36,6 @@
*/
public abstract class AbstractLSPGoToAction extends AnAction {

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractLSPGoToAction.class);

@NotNull
private final LSPUsageType usageType;

Expand Down Expand Up @@ -112,14 +107,8 @@ private boolean canSupportAction(@NotNull AnActionEvent e) {
return false;
}
// Check if the file can support the feature
try {
return !LanguageServiceAccessor.getInstance(project)
.getLanguageServers(file, this::canSupportFeature)
.get(200, TimeUnit.MILLISECONDS)
.isEmpty();
} catch (Exception ex) {
return false;
}
return LanguageServiceAccessor.getInstance(project)
.hasAny(file, ls -> canSupportFeature(ls.getServerCapabilitiesSync()));
}

protected abstract boolean canSupportFeature(ServerCapabilities serverCapabilities);
Expand Down

0 comments on commit eca7ca6

Please sign in to comment.