This is an automated email from the ASF dual-hosted git repository.

dbalek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 548622e2a0 LSP: Prevent errors written to log on workspace symbol open.
     new ca8678a8b3 Merge pull request #6390 from 
dbalek/dbalek/lsp-open-ws-symbol
548622e2a0 is described below

commit 548622e2a007e824cf576b09917b085fd9520fae
Author: Dusan Balek <dusan.ba...@oracle.com>
AuthorDate: Wed Aug 30 16:08:25 2023 +0200

    LSP: Prevent errors written to log on workspace symbol open.
---
 .../modules/java/lsp/server/protocol/WorkspaceServiceImpl.java   | 5 ++---
 .../netbeans/modules/java/lsp/server/protocol/ServerTest.java    | 9 +++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java
 
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java
index afa8ed4782..a8d4876166 100644
--- 
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java
+++ 
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/WorkspaceServiceImpl.java
@@ -281,7 +281,7 @@ public final class WorkspaceServiceImpl implements 
WorkspaceService, LanguageCli
                 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);
@@ -1174,8 +1174,7 @@ public final class WorkspaceServiceImpl implements 
WorkspaceService, LanguageCli
                         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()));
                             }
diff --git 
a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
 
b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
index 9d3412e0aa..84867cfa97 100644
--- 
a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
+++ 
b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
@@ -1851,10 +1851,11 @@ public class ServerTest extends NbTestCase {
         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()));
@@ -1862,8 +1863,8 @@ public class ServerTest extends NbTestCase {
         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);
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to