diff --git a/docs/LSPApi.md b/docs/LSPApi.md index af10b690..69fc1d08 100644 --- a/docs/LSPApi.md +++ b/docs/LSPApi.md @@ -2,7 +2,6 @@ The [LSPClientFeatures](https://github.com/redhat-developer/lsp4ij/blob/main/src/main/java/com/redhat/devtools/lsp4ij/client/features/LSPClientFeatures.java) API allows you to customize the behavior of LSP features, including: -- [Client-only features](#client-only-features) - [LSP codeAction feature](#lsp-codeAction-feature) - [LSP codeLens feature](#lsp-codeLens-feature) - [LSP color feature](#lsp-color-feature) @@ -61,6 +60,7 @@ public class MyLanguageServerFactory implements LanguageServerFactory { | boolean keepServerAlive() | Returns `true` if the server is kept alive even if all files associated with the language server are closed and `false` otherwise. | `false` | | boolean canStopServerByUser() | Returns `true` if the user can stop the language server in LSP console from the context menu and `false` otherwise. | `true` | | boolean isEnabled(VirtualFile) | Returns `true` if the language server is enabled for the given file and `false` otherwise. | `true` | +| boolean isCaseSensitive(PsiFile file) | Returns `true` if the language grammar for the given file is case-sensitive and `false` otherwise. | `false` | ```java package my.language.server; @@ -164,14 +164,6 @@ public class MyLSPCodeLensFeature extends LSPCodeLensFeature { } ``` -## Client-only Features - -Client-only features are used to provide information to LSP4IJ that is not available from language servers but is required for proper integration of language server features into the IDE's corresponding features. - -| API | Description | Default Behaviour | -|---------------------------------------|--------------------------------------------------------------------------------------|----------------------------| -| boolean isCaseSensitive(PsiFile file) | Determines whether or not the language grammar for the given file is case-sensitive. | `false` (case-insensitive) | - ## LSP CodeAction Feature | API | Description | Default Behaviour | diff --git a/src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java b/src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java index 7f7bb30c..8a073afa 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java @@ -1169,6 +1169,7 @@ public boolean isDidRenameFilesSupported(@NotNull PsiFile file) { return fileOperationsManager.canDidRenameFiles(LSPIJUtils.toUri(file), file.isDirectory()); } + @NotNull public LSPClientFeatures getClientFeatures() { if (clientFeatures == null) { clientFeatures = getOrCreateClientFeatures(); @@ -1176,6 +1177,7 @@ public LSPClientFeatures getClientFeatures() { return clientFeatures; } + @NotNull private synchronized LSPClientFeatures getOrCreateClientFeatures() { if (clientFeatures != null) { return clientFeatures; diff --git a/src/main/java/com/redhat/devtools/lsp4ij/LanguageServiceAccessor.java b/src/main/java/com/redhat/devtools/lsp4ij/LanguageServiceAccessor.java index 591a7561..93e40a92 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/LanguageServiceAccessor.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/LanguageServiceAccessor.java @@ -423,26 +423,6 @@ public CompletableFuture> getAsyncMatched() { } } - /** - * Returns the language server wrappers for the specified file synchronously. - * - * @param file the file - * @return the language server wrappers that apply to the file - */ - @ApiStatus.Internal - @NotNull - public Set getMatchedLanguageServerWrappersSync(@NotNull VirtualFile file) { - Set languageServerWrappers = new LinkedHashSet<>(); - MatchedLanguageServerDefinitions matchedLanguageServerDefinitions = getMatchedLanguageServerDefinitions(file, project, false); - if (matchedLanguageServerDefinitions != null) { - Set languageServerDefinitions = matchedLanguageServerDefinitions.getMatched(); - for (LanguageServerDefinition languageServerDefinition : languageServerDefinitions) { - languageServerWrappers.add(new LanguageServerWrapper(project, languageServerDefinition)); - } - } - return languageServerWrappers; - } - /** * Returns the matched language server definitions for the given file. * diff --git a/src/main/java/com/redhat/devtools/lsp4ij/usages/LSPExternalReferencesFinder.java b/src/main/java/com/redhat/devtools/lsp4ij/usages/LSPExternalReferencesFinder.java index 274251d4..5766d361 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/usages/LSPExternalReferencesFinder.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/usages/LSPExternalReferencesFinder.java @@ -28,11 +28,8 @@ import com.intellij.psi.search.PsiSearchHelper; import com.intellij.psi.search.UsageSearchContext; import com.intellij.util.Processor; -import com.intellij.util.containers.ContainerUtil; import com.redhat.devtools.lsp4ij.LSPIJUtils; -import com.redhat.devtools.lsp4ij.LanguageServerWrapper; import com.redhat.devtools.lsp4ij.LanguageServiceAccessor; -import com.redhat.devtools.lsp4ij.client.features.LSPClientFeatures; import com.redhat.devtools.lsp4ij.features.LSPPsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -88,21 +85,17 @@ private static void processExternalReferences(@NotNull PsiFile file, return; } - Project project = file.getProject(); - Set languageServerWrappers = LanguageServiceAccessor.getInstance(project).getMatchedLanguageServerWrappersSync(virtualFile); - if (ContainerUtil.isEmpty(languageServerWrappers)) { - return; - } - // Determine whether or not to search/match in a case-sensitive manner based on client configuration - boolean caseSensitive = isCaseSensitive(languageServerWrappers, file); + Project project = file.getProject(); + boolean caseSensitive = LanguageServiceAccessor.getInstance(project) + .hasAny(file.getVirtualFile(), ls -> ls.getClientFeatures().isCaseSensitive(file)); if (progressIndicator != null) { progressIndicator.setText("Finding usages of '" + wordText + "'"); } Set externalReferenceKeys = new HashSet<>(); - PsiSearchHelper.getInstance(file.getProject()).processElementsWithWord( + PsiSearchHelper.getInstance(project).processElementsWithWord( (element, offsetInElement) -> { PsiReference originalReference = element.findReferenceAt(offsetInElement); List references = originalReference != null ? @@ -146,19 +139,6 @@ private static void processExternalReferences(@NotNull PsiFile file, ); } - private static boolean isCaseSensitive(@NotNull Set languageServerWrappers, @NotNull PsiFile psiFile) { - // If any supporting language server is case-sensitive, the search must be case-sensitive; it's better to - // miss changing things that should have been changed than to change things that should not - for (LanguageServerWrapper languageServerWrapper : languageServerWrappers) { - LSPClientFeatures clientFeatures = languageServerWrapper.getClientFeatures(); - if ((clientFeatures != null) && clientFeatures.isCaseSensitive(psiFile)) { - return true; - } - } - - return false; - } - @Nullable private static String getReferenceKey(@NotNull PsiReference reference) { PsiElement sourceElement = reference.getElement();