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

sdedic 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 469f33d  Avoid NPEs when Finder returns DeclarationLocation.NONE or no 
FObject.
     new 44738fc  Merge pull request #3030 from sdedic/lsp/npe-hyperlink2
469f33d is described below

commit 469f33d64f3303ed1c69a5d592334ec13ba91c66
Author: Svata Dedic <svatopluk.de...@oracle.com>
AuthorDate: Thu Jul 1 10:23:01 2021 +0200

    Avoid NPEs when Finder returns DeclarationLocation.NONE or no FObject.
---
 ide/api.lsp/src/org/netbeans/api/lsp/HyperlinkLocation.java            | 2 +-
 .../src/org/netbeans/modules/csl/editor/hyperlink/GoToSupport.java     | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ide/api.lsp/src/org/netbeans/api/lsp/HyperlinkLocation.java 
b/ide/api.lsp/src/org/netbeans/api/lsp/HyperlinkLocation.java
index 2069379..f790674 100644
--- a/ide/api.lsp/src/org/netbeans/api/lsp/HyperlinkLocation.java
+++ b/ide/api.lsp/src/org/netbeans/api/lsp/HyperlinkLocation.java
@@ -152,7 +152,7 @@ public final class HyperlinkLocation {
             List<HyperlinkLocation> locations = new 
ArrayList<>(futures.length);
             for (CompletableFuture<HyperlinkLocation> future : futures) {
                 HyperlinkLocation location = future.getNow(null);
-                if (location != null) {
+                if (location != null && location.getFileObject() != null) {
                     locations.add(location);
                 }
             }
diff --git 
a/ide/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/GoToSupport.java 
b/ide/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/GoToSupport.java
index 30f3ed5..b6386ae 100644
--- a/ide/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/GoToSupport.java
+++ b/ide/csl.api/src/org/netbeans/modules/csl/editor/hyperlink/GoToSupport.java
@@ -98,7 +98,8 @@ public class GoToSupport {
     public static CompletableFuture<HyperlinkLocation> getGoToLocation(final 
Document doc, final int offset) {
         DeclarationLocation[] location = new DeclarationLocation[1];
         perform(doc, offset, false, location, new AtomicBoolean());
-        return CompletableFuture.completedFuture(location[0] == null ? null : 
HyperlinkLocationProvider.createHyperlinkLocation(location[0].getFileObject(), 
location[0].getOffset(), location[0].getOffset()));
+        return CompletableFuture.completedFuture(location[0] == null || 
location[0] == DeclarationLocation.NONE ? 
+                null : 
HyperlinkLocationProvider.createHyperlinkLocation(location[0].getFileObject(), 
location[0].getOffset(), location[0].getOffset()));
     }
 
     private static String perform(final Document doc, final int offset, final 
boolean tooltip, final DeclarationLocation[] location, final AtomicBoolean 
cancel) {

---------------------------------------------------------------------
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