From e5ca36926e78614eb06dd9c5d722361f67176ba1 Mon Sep 17 00:00:00 2001 From: Scott Wells Date: Wed, 11 Dec 2024 16:04:01 -0600 Subject: [PATCH] Ugh...this still wasn't working quite right, so I read the JavaDoc for getSymbolTypeDeclarations() and finally realized that implementations must return null and not an empty array to indicate that they didn't service the request. --- .../LSPWorkspaceTypeDeclarationProvider.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/redhat/devtools/lsp4ij/features/workspaceSymbol/LSPWorkspaceTypeDeclarationProvider.java b/src/main/java/com/redhat/devtools/lsp4ij/features/workspaceSymbol/LSPWorkspaceTypeDeclarationProvider.java index a46c8a8e4..2021953ff 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/features/workspaceSymbol/LSPWorkspaceTypeDeclarationProvider.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/features/workspaceSymbol/LSPWorkspaceTypeDeclarationProvider.java @@ -54,37 +54,37 @@ public class LSPWorkspaceTypeDeclarationProvider implements TypeDeclarationPlace @Override public PsiElement @Nullable [] getSymbolTypeDeclarations(@NotNull PsiElement symbol) { // Not much we can do without an offset - return PsiElement.EMPTY_ARRAY; + return null; } @Override public PsiElement @Nullable [] getSymbolTypeDeclarations(@NotNull PsiElement symbol, Editor editor, int offset) { if (!symbol.isValid()) { - return PsiElement.EMPTY_ARRAY; + return null; } Project project = symbol.getProject(); if (project.isDisposed()) { - return PsiElement.EMPTY_ARRAY; + return null; } PsiFile file = symbol.getContainingFile(); if ((file == null) || !file.isValid()) { - return PsiElement.EMPTY_ARRAY; + return null; } Document document = LSPIJUtils.getDocument(file); if (document == null) { - return PsiElement.EMPTY_ARRAY; + return null; } if (ProjectIndexingManager.canExecuteLSPFeature(file) != ExecuteLSPFeatureStatus.NOW) { - return PsiElement.EMPTY_ARRAY; + return null; } if (!LanguageServiceAccessor.getInstance(project) .hasAny(file.getVirtualFile(), ls -> ls.getClientFeatures().getTypeDefinitionFeature().isTypeDefinitionSupported(file))) { - return PsiElement.EMPTY_ARRAY; + return null; } LSPTypeDefinitionSupport typeDefinitionSupport = LSPFileSupport.getSupport(file).getTypeDefinitionSupport(); @@ -113,11 +113,12 @@ public class LSPWorkspaceTypeDeclarationProvider implements TypeDeclarationPlace for (Location typeDefinition : typeDefinitions) { ContainerUtil.addIfNotNull(typeDefinitionElements, LSPPsiElementFactory.toPsiElement(typeDefinition, project)); } - return typeDefinitionElements.toArray(PsiElement.EMPTY_ARRAY); + if (!ContainerUtil.isEmpty(typeDefinitionElements)) { + return typeDefinitionElements.toArray(PsiElement.EMPTY_ARRAY); + } } } - return PsiElement.EMPTY_ARRAY; + return null; } - }