Skip to content

Commit 52b9f92

Browse files
committed
fix: solve JDT Null Analysis Mismatch Error
1 parent 9e060df commit 52b9f92

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/symbols/LSPSymbolInWorkspaceDialog.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package org.eclipse.lsp4e.operations.symbols;
1313

1414
import java.util.ArrayList;
15+
import java.util.Collections;
1516
import java.util.Comparator;
1617
import java.util.List;
1718
import java.util.Objects;
@@ -230,10 +231,10 @@ private static List<WorkspaceSymbol> toWorkspaceSymbols(@Nullable List<? extends
230231
return res;
231232
}
232233

233-
static List<? extends WorkspaceSymbol> eitherToWorkspaceSymbols(
234+
static List<@Nullable ? extends WorkspaceSymbol> eitherToWorkspaceSymbols(
234235
final @Nullable Either<List<? extends SymbolInformation>, List<@Nullable ? extends WorkspaceSymbol>> source) {
235236
return source == null //
236-
? List.of()
237-
: source.map(LSPSymbolInWorkspaceDialog::toWorkspaceSymbols, Function.identity());
237+
? Collections.emptyList()
238+
: source.map(LSPSymbolInWorkspaceDialog::toWorkspaceSymbols, Function.identity());
238239
}
239240
}

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/symbols/WorkspaceSymbolsQuickAccessProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.ArrayList;
1515
import java.util.Collections;
1616
import java.util.List;
17+
import java.util.Objects;
1718
import java.util.concurrent.CompletableFuture;
1819
import java.util.concurrent.ExecutionException;
1920
import java.util.concurrent.TimeUnit;
@@ -69,7 +70,7 @@ public QuickAccessElement[] computeElements(String query, IProgressMonitor monit
6970
CompletableFuture.allOf(usedLanguageServerWrappers.stream()
7071
.map(w -> w.execute(ls -> ls.getWorkspaceService().symbol(params).thenAcceptAsync((@Nullable Either<List<? extends SymbolInformation>, List<@Nullable ? extends WorkspaceSymbol>> symbols) -> {
7172
if (symbols != null) {
72-
res.addAll(LSPSymbolInWorkspaceDialog.eitherToWorkspaceSymbols(symbols).stream().map(WorkspaceSymbolQuickAccessElement::new)
73+
res.addAll(LSPSymbolInWorkspaceDialog.eitherToWorkspaceSymbols(symbols).stream().filter(Objects::nonNull).map(WorkspaceSymbolQuickAccessElement::new)
7374
.toList());
7475
}
7576
}))).toArray(CompletableFuture[]::new)).get(1, TimeUnit.SECONDS);

0 commit comments

Comments
 (0)