Skip to content

Commit

Permalink
NPE with Workspace Symbol when LSP client return null as
Browse files Browse the repository at this point in the history
SymbolInformation List

Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
angelozerr committed Aug 14, 2024
1 parent 228499f commit 8b3973d
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.lsp4mp.ls;

import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
Expand All @@ -22,6 +22,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.lsp4j.DidChangeConfigurationParams;
import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
Expand Down Expand Up @@ -71,7 +72,7 @@ public CompletableFuture<Either<List<? extends SymbolInformation>, List<? extend
.thenCompose((workspaceProjects) -> {

cancelChecker.checkCanceled();

List<CompletableFuture<List<SymbolInformation>>> symbolFutures = workspaceProjects.stream() //
.map(projectLabelInfo -> {
String uri = projectLabelInfo.getUri();
Expand All @@ -81,7 +82,7 @@ public CompletableFuture<Either<List<? extends SymbolInformation>, List<? extend
.collect(Collectors.toList());

cancelChecker.checkCanceled();

// NOTE: we don't need to implement resolve, because resolve is just
// for calculating the source range. The source range is very cheap to calculate
// in comparison to invoking the search engine to locate the symbols.
Expand All @@ -102,7 +103,8 @@ public CompletableFuture<Either<List<? extends SymbolInformation>, List<? extend

return Either.forLeft(symbolFutures.stream() //
.flatMap(projectSymbolsFuture -> {
return projectSymbolsFuture.getNow(Collections.emptyList()).stream();
List<SymbolInformation> symbols = projectSymbolsFuture.getNow(null);
return symbols != null ? symbols.stream() : Stream.empty();
}) //
.collect(Collectors.toList()));
});
Expand Down

0 comments on commit 8b3973d

Please sign in to comment.