Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove isValid which can require a ReadAcion when element is a
Browse files Browse the repository at this point in the history
TreeElement (ex: Qute token).

Signed-off-by: azerr <[email protected]>
angelozerr committed Dec 12, 2024
1 parent 2e44c67 commit 347a618
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
package com.redhat.devtools.lsp4ij.features.workspaceSymbol;

import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.openapi.application.QueryExecutorBase;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
@@ -45,41 +46,45 @@
/**
* Implements the IDE's standard Go To Implementation(s) action using LSP textDocument/implementation. -->
*/
public class LSPWorkspaceImplementationsSearch implements QueryExecutor<PsiElement, DefinitionsScopedSearch.SearchParameters> {
public class LSPWorkspaceImplementationsSearch extends QueryExecutorBase<PsiElement, DefinitionsScopedSearch.SearchParameters> {

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

public LSPWorkspaceImplementationsSearch() {
super(true);
}

@Override
public boolean execute(@NotNull DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull Processor<? super PsiElement> consumer) {
public void processQuery(DefinitionsScopedSearch.@NotNull SearchParameters queryParameters, @NotNull Processor<? super PsiElement> consumer) {
Project project = queryParameters.getProject();
if (project.isDisposed()) {
return true;
return;
}

PsiElement element = queryParameters.getElement();
if (!element.isValid()) {
return true;
return;
}

PsiFile file = element.getContainingFile();
if ((file == null) || !file.isValid()) {
return true;
return;
}

Document document = LSPIJUtils.getDocument(file);
if (document == null) {
return true;
return;
}

if (ProjectIndexingManager.canExecuteLSPFeature(file) != ExecuteLSPFeatureStatus.NOW) {
// The file is not associated to a language server
return true;
return;
}

// Check if the file can support the feature
if (!LanguageServiceAccessor.getInstance(project)
.hasAny(file.getVirtualFile(), ls -> ls.getClientFeatures().getImplementationFeature().isImplementationSupported(file))) {
return true;
return;
}

int offset = element.getTextRange().getStartOffset();
@@ -111,12 +116,10 @@ public boolean execute(@NotNull DefinitionsScopedSearch.SearchParameters queryPa
// textDocument/implementations has been collected correctly
for (Location implementation : implementations) {
if (!consumer.process(LSPPsiElementFactory.toPsiElement(implementation, project))) {
return false;
return;
}
}
}
}

return true;
}
}

0 comments on commit 347a618

Please sign in to comment.