Commits

Jan Lahoda committed 73d8ec0

Ignore generated constructors while searching for declarations, use correct name span to detect declarations.

  • Participants
  • Parent commits 7176389

Comments (0)

Files changed (2)

File remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/ResolveService.java

 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
 import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
             case MEMBER_SELECT: name = ((MemberSelectTree) forTree.getLeaf()).getIdentifier(); break;
             case ANNOTATION_TYPE: case CLASS:
             case ENUM: case INTERFACE: name = ((ClassTree) forTree.getLeaf()).getSimpleName(); break;
-            case METHOD: name = ((MethodTree) forTree.getLeaf()).getName(); break;
+            case METHOD:
+                if ((((JCMethodDecl) forTree.getLeaf()).getModifiers().flags & Flags.GENERATEDCONSTR) != 0) {
+                    //no positions for generated constructors:
+                    return new long[] {-1, -1, -1, -1};
+                }
+                name = ((MethodTree) forTree.getLeaf()).getName();
+                break;
             case VARIABLE: name = ((VariableTree) forTree.getLeaf()).getName(); break;
         }
 

File remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java

 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
 import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import freemarker.template.TemplateException;
 import java.io.IOException;
 import java.net.URI;
 
                 long[] span = ResolveService.nameSpan(info, getCurrentPath());
 
-                if (span[0] <= position && position <= span[1]) {
+                if (span[2] <= position && position <= span[3]) {
                     if (JavaUtils.SUPPORTED_KINDS.contains(el.getKind())) {
                         signature[0] = JavaUtils.serialize(ElementHandle.create(el));
                     }