Skip to content

Commit

Permalink
Merge pull request #6390 from dbalek/dbalek/lsp-open-ws-symbol
Browse files Browse the repository at this point in the history
LSP: Prevent errors written to log on workspace symbol open.
  • Loading branch information
dbalek authored Aug 31, 2023
2 parents d507933 + 548622e commit ca8678a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public CompletableFuture<Object> executeCommand(ExecuteCommandParams params) {
try {
String uri = ((JsonPrimitive) params.getArguments().get(0)).getAsString();
FileObject file = Utils.fromUri(uri);
if (file != null) {
if (file != null && file.isData() && file.canRead()) {
future.complete(file.asText("UTF-8"));
}
future.complete(null);
Expand Down Expand Up @@ -1174,8 +1174,7 @@ public CompletableFuture<WorkspaceSymbol> resolveWorkspaceSymbol(WorkspaceSymbol
sdp.setSelection(new Range(position, position));
client.showDocument(sdp).thenAccept(res -> {
if (res.isSuccess()) {
workspaceSymbol.setLocation(Either.forLeft(new Location(Utils.toUri(loc.getFileObject()), new Range(position, position))));
result.complete(workspaceSymbol);
result.complete(null);
} else {
result.completeExceptionally(new IllegalStateException("Cannot open source for: " + typeHandle.getQualifiedName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1851,19 +1851,20 @@ public CompletableFuture<ShowDocumentResult> showDocument(ShowDocumentParams par
indexingComplete.await();
Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>> symbols = server.getWorkspaceService().symbol(new WorkspaceSymbolParams("Tes")).get();
List<String> actual = symbols.getRight().stream().map(symbol -> {
WorkspaceSymbol ws;
WorkspaceSymbol ws = null;
try {
ws = server.getWorkspaceService().resolveWorkspaceSymbol(symbol).get();
} catch (Exception ex) {
} catch (Exception ex) {}
if (ws == null) {
ws = symbol;
}
return ws.getKind() + ":" + ws.getName() + ":" + ws.getContainerName() + ":" + (ws.getLocation().isLeft() ? toString(ws.getLocation().getLeft()) : toString(ws.getLocation().getRight()));
}).collect(Collectors.toList());
assertEquals(Arrays.asList("Constructor:Test():Test:Test.java:0:7-0:7",
"Method:testMethod():Test:Test.java:2:4-2:38",
"Constructor:TestNested():Test.TestNested:Test.java:1:18-1:18",
"Class:Test:null:Test.java:0:13-0:13",
"Class:TestNested:Test:Test.java:1:24-1:24"),
"Class:Test:null:?CLASS#Test",
"Class:TestNested:Test:?CLASS#Test$TestNested"),
actual);
}

Expand Down

0 comments on commit ca8678a

Please sign in to comment.