GH-1239: prevent NPE when no symbols are around yet

This commit is contained in:
Martin Lippert
2024-04-25 16:29:32 +02:00
parent 029cc73476
commit 2bd054a6b4

View File

@@ -600,21 +600,24 @@ public class SpringSymbolIndex implements InitializingBean, SpringIndex {
private Collection<? extends String> getDocsFromPath(IJavaProject project, String path) {
List<EnhancedSymbolInformation> allProjectSymbols = this.symbolsByProject.get(project.getElementName());
Set<String> result = new HashSet<>();
for (EnhancedSymbolInformation symbol : allProjectSymbols) {
Either<Location, WorkspaceSymbolLocation> location = symbol.getSymbol().getLocation();
Set<String> result = new HashSet<>();
String docURI = null;
if (location.isLeft()) {
docURI = location.getLeft().getUri();
}
else if (location.isRight()) {
docURI = location.getRight().getUri();
}
if (docURI != null && docURI.startsWith(path)) {
result.add(docURI);
if (allProjectSymbols != null) {
for (EnhancedSymbolInformation symbol : allProjectSymbols) {
Either<Location, WorkspaceSymbolLocation> location = symbol.getSymbol().getLocation();
String docURI = null;
if (location.isLeft()) {
docURI = location.getLeft().getUri();
}
else if (location.isRight()) {
docURI = location.getRight().getUri();
}
if (docURI != null && docURI.startsWith(path)) {
result.add(docURI);
}
}
}