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 2b80a5d  Minor bug fixes. (#3847)
2b80a5d is described below

commit 2b80a5d87d1e37592749f43f7bf68fdc875b9c80
Author: Dusan Balek <[email protected]>
AuthorDate: Thu Mar 24 17:43:55 2022 +0100

    Minor bug fixes. (#3847)
    
    * TreePathHandles cannot be created for PackageElements.
    * Limit fallback copy to class files only.
---
 .../java/source/indexing/VanillaCompileWorker.java |  5 +++--
 .../netbeans/api/java/source/ui/ElementOpen.java   |  4 ++--
 .../modules/java/source/ui/LspElementUtils.java    | 26 ++++++++++++----------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git 
a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
 
b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
index d98c5ab..d35cf64 100644
--- 
a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
+++ 
b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
@@ -474,9 +474,10 @@ final class VanillaCompileWorker extends CompileWorker {
 
             for (FileObject f : listed) {
                 String name = f.getNameExt();
-                if (name.endsWith(".class"))
+                if (name.endsWith(".class")) {
                     name = name.substring(0, name.length() - 
FileObjects.CLASS.length()) + FileObjects.SIG;
-                copyRecursively(f, targetRoot, new File(target, name), filter, 
fmtx, copied);
+                    copyRecursively(f, targetRoot, new File(target, name), 
filter, fmtx, copied);
+                }
             }
         } else {
             if (target.isDirectory()) {
diff --git 
a/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java 
b/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
index 0684c5f..d58e614 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
@@ -515,13 +515,13 @@ public final class ElementOpen {
                         return;
                     }
 
-                    FindDeclarationVisitor v = new FindDeclarationVisitor(el, 
info);
+                    result[6] = TreePathHandle.create(el, info);
 
+                    FindDeclarationVisitor v = new FindDeclarationVisitor(el, 
info);
                     CompilationUnitTree cu = info.getCompilationUnit();
 
                     v.scan(cu, null);
                     Tree elTree = v.declTree;
-                    result[6] = TreePathHandle.create(el, info);
                     if (elTree != null) {
                         result[1] = 
(int)info.getTrees().getSourcePositions().getStartPosition(cu, elTree);
                         result[2] = 
(int)info.getTrees().getSourcePositions().getEndPosition(cu, elTree);
diff --git 
a/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java
 
b/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java
index 2d41900..8e13f27 100644
--- 
a/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java
+++ 
b/java/java.sourceui/src/org/netbeans/modules/java/source/ui/LspElementUtils.java
@@ -237,20 +237,22 @@ public class LspElementUtils {
         }
         TreePathHandle pathHandle = (TreePathHandle)info[6];
         FileObject f = (FileObject)info[0];
-        boolean[] synthetic = new boolean[1];
+        boolean[] synthetic = new boolean[] { false };
         if (f != null) {
             builder.file(f);
-            try {
-                JavaSource js = JavaSource.forFileObject(f);
-                if (js == null) {
-                    return null;
+            if (pathHandle != null) {
+                try {
+                    JavaSource js = JavaSource.forFileObject(f);
+                    if (js == null) {
+                        return null;
+                    }
+                    js.runUserActionTask((cc) -> {
+                        TreePath path = pathHandle.resolve(cc);
+                        synthetic[0] = cc.getTreeUtilities().isSynthetic(path);
+                    }, true);
+                } catch (IOException ex) {
+                    // ignore
                 }
-                js.runUserActionTask((cc) -> {
-                    TreePath path = pathHandle.resolve(cc);
-                    synthetic[0] = cc.getTreeUtilities().isSynthetic(path);
-                }, true);
-            } catch (IOException ex) {
-                // ignore
             }
         }
         if (synthetic[0]) {
@@ -258,7 +260,7 @@ public class LspElementUtils {
         }
         
builder.expandedStartOffset((int)info[1]).expandedEndOffset((int)info[2]);
         builder.selectionStartOffset(selStart).selectionEndOffset(selEnd);
-       return builder; 
+       return builder;
     }
     
     private static CompletableFuture<StructureProvider.Builder> 
setFutureOffsets(CompilationInfo ci, Element original, 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to