protected Node findContainingTypeDeclOrObjectCreationExpr(Node node) { if (node instanceof ClassOrInterfaceDeclaration) { return node; } if (node instanceof EnumDeclaration) { return node; } Node parent = requireParentNode(node); if (parent instanceof ObjectCreationExpr && !((ObjectCreationExpr) parent).getArguments().contains(node)) { return parent; } return findContainingTypeDeclOrObjectCreationExpr(parent); }
private static boolean isSyntacticallyAModuleName(Node name) { // A name is syntactically classified as a ModuleName in these contexts: // // 1. In a requires directive in a module declaration (§7.7.1) if (whenParentIs(ModuleRequiresDirective.class, name, (p, c) -> p.getName() == name)) { return true; } // 2. To the right of to in an exports or opens directive in a module declaration (§7.7.2) if (whenParentIs(ModuleExportsDirective.class, name, (p, c) -> p.getModuleNames().contains(name))) { return true; } if (whenParentIs(ModuleOpensDirective.class, name, (p, c) -> p.getModuleNames().contains(name))) { return true; } return false; }
protected com.github.javaparser.ast.Node findContainingTypeDeclOrObjectCreationExpr(Node node) { if (node instanceof ClassOrInterfaceDeclaration) { return (ClassOrInterfaceDeclaration) node; } else if (node instanceof EnumDeclaration) { return (EnumDeclaration) node; } else if (getParentNode(node) == null) { throw new IllegalArgumentException(); } else if (getParentNode(node) instanceof ObjectCreationExpr && !((ObjectCreationExpr)getParentNode(node)).getArguments().contains(node)) { return getParentNode(node); } else { return findContainingTypeDeclOrObjectCreationExpr(getParentNode(node)); } }
protected com.github.javaparser.ast.Node findContainingTypeDeclOrObjectCreationExpr(Node node) { if (node instanceof ClassOrInterfaceDeclaration) { return (ClassOrInterfaceDeclaration) node; } else if (node instanceof EnumDeclaration) { return (EnumDeclaration) node; } else if (getParentNode(node) == null) { throw new IllegalArgumentException(); } else if (getParentNode(node) instanceof ObjectCreationExpr && !((ObjectCreationExpr)getParentNode(node)).getArguments().contains(node)) { return getParentNode(node); } else { return findContainingTypeDeclOrObjectCreationExpr(getParentNode(node)); } }
if (parentNode instanceof ObjectCreationExpr && (node == ((ObjectCreationExpr) parentNode).getType() || ((ObjectCreationExpr) parentNode).getArguments().contains(node))) { return getContext(requireParentNode(parentNode), typeSolver);
ne.getResources().contains(c2)) )) { return true; p1.getName() == c1 && whenParentIs(VariableDeclarator.class, p1, (p2, c2) -> p2.getInitializer().isPresent() && p2.getInitializer().get() == c2 && whenParentIs(VariableDeclarationExpr.class, p2, (p3, c3) -> p3.getVariables().contains(c3) && whenParentIs(TryStmt.class, p3, (p4, c4) -> p4.getResources().contains(c4) ne.getResources().contains(c2))) { return true; p3.getVariables().contains(c3) && whenParentIs(TryStmt.class, p3, (p4, c4) -> p4.getResources().contains(c4)
p.getExtendedTypes().contains(c) || p.getImplementedTypes().contains(c))) { return true; p.getThrownExceptions().contains(c))) { return true; p.getThrownExceptions().contains(c))) { return true; p2.getVariables().contains(c2)))) { return true; p2.getVariables().contains(c2)))) { return true; p.getTypeArguments().isPresent() && p.getTypeArguments().get().contains(c))) { return true; p.getTypeArguments().isPresent() && p.getTypeArguments().get().contains(c))) { return true;
return NameRole.DECLARATION; if (whenParentIs(ClassOrInterfaceDeclaration.class, name, (p, c) -> p.getExtendedTypes().contains(c) || p.getImplementedTypes().contains(c))) { return NameRole.REFERENCE; if (whenParentIs(MethodDeclaration.class, name, (p, c) -> p.getType() == c || p.getThrownExceptions().contains(c))) { return NameRole.REFERENCE; (p.getTypeArguments().isPresent() && p.getTypeArguments().get().contains(c)) || (p.getScope().isPresent() && p.getScope().get() == c))) { return NameRole.REFERENCE; if (whenParentIs(ConstructorDeclaration.class, name, (p, c) -> p.getName() == c || p.getThrownExceptions().contains(c))) { return NameRole.REFERENCE; if (whenParentIs(ModuleExportsDirective.class, name, (p, c) -> p.getModuleNames().contains(c))) { return NameRole.REFERENCE; if (whenParentIs(ModuleOpensDirective.class, name, (p, c) -> p.getModuleNames().contains(c))) { return NameRole.REFERENCE; if (whenParentIs(TryStmt.class, name, (p, c) -> p.getResources().contains(c))) { return NameRole.REFERENCE; (p.getTypeArguments().isPresent() && p.getTypeArguments().get().contains(c)))) { return NameRole.REFERENCE;