diff --git a/javacc-wrapper.xml b/javacc-wrapper.xml
index e340703084..f0e14fa6c7 100644
--- a/javacc-wrapper.xml
+++ b/javacc-wrapper.xml
@@ -479,10 +479,10 @@ public interface" />
-
+
+ token="default Object visit(${node-name} node, Object data) { return visit${node-name}(node, data); }"
+ value="default Object visit${node-name}(${node-name} node, Object data) { for (int i = 0, len = node.getNumChildren(); i < len; i++) node.getChild(i).jjtAccept(this, data); return data; }">
@@ -497,7 +497,8 @@ public interface" />
-
+
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaVisitorBase.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaVisitorBase.java
index a11b330397..6bfec5e17c 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaVisitorBase.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaVisitorBase.java
@@ -30,31 +30,31 @@ public class JavaVisitorBase
extends AstVisitorBase
implements JavaV
//
- public R visit(ASTMethodOrConstructorDeclaration node, P data) {
- return visit((JavaNode) node, data);
+ public R visitMethodOrCtor(ASTMethodOrConstructorDeclaration node, P data) {
+ return visitJavaNode(node, data);
}
@Override
public R visit(ASTMethodDeclaration node, P data) {
- return visit((ASTMethodOrConstructorDeclaration) node, data);
+ return visitMethodOrCtor(node, data);
}
@Override
public R visit(ASTConstructorDeclaration node, P data) {
- return visit((ASTMethodOrConstructorDeclaration) node, data);
+ return visitMethodOrCtor(node, data);
}
//
//
- public R visit(ASTAnyTypeDeclaration node, P data) {
- return visit((JavaNode) node, data);
+ public R visitTypeDecl(ASTAnyTypeDeclaration node, P data) {
+ return visitJavaNode(node, data);
}
@Override
public R visit(ASTClassOrInterfaceDeclaration node, P data) {
- return visit((ASTAnyTypeDeclaration) node, data);
+ return visitTypeDecl(node, data);
}
// @Override
@@ -64,17 +64,17 @@ public class JavaVisitorBase extends AstVisitorBase
implements JavaV
@Override
public R visit(ASTRecordDeclaration node, P data) {
- return visit((ASTAnyTypeDeclaration) node, data);
+ return visitTypeDecl(node, data);
}
@Override
public R visit(ASTEnumDeclaration node, P data) {
- return visit((ASTAnyTypeDeclaration) node, data);
+ return visitTypeDecl(node, data);
}
@Override
public R visit(ASTAnnotationTypeDeclaration node, P data) {
- return visit((ASTAnyTypeDeclaration) node, data);
+ return visitTypeDecl(node, data);
}
//
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java
index 85ba3ab04a..6eff9db9c8 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java
@@ -375,7 +375,7 @@ public class LanguageLevelChecker {
@Override
public Void visit(ASTEnumDeclaration node, T data) {
check(node, RegularLanguageFeature.ENUMS, data);
- visit((ASTAnyTypeDeclaration) node, data);
+ visitTypeDecl((ASTAnyTypeDeclaration) node, data);
return null;
}
@@ -514,7 +514,7 @@ public class LanguageLevelChecker {
}
@Override
- public Void visit(ASTAnyTypeDeclaration node, T data) {
+ public Void visitTypeDecl(ASTAnyTypeDeclaration node, T data) {
String simpleName = node.getSimpleName();
if ("var".equals(simpleName)) {
check(node, ReservedIdentifiers.VAR_AS_A_TYPE_NAME, data);
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaDesignerBindings.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaDesignerBindings.java
index d44fbd225d..f5f30099a8 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaDesignerBindings.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaDesignerBindings.java
@@ -31,13 +31,12 @@ public final class JavaDesignerBindings extends DefaultDesignerBindings {
@Override
public Attribute getMainAttribute(Node node) {
if (node instanceof JavaNode) {
- Attribute attr = ((JavaNode) node).acceptVisitor(MainAttrVisitor.INSTANCE, null);
+ Attribute attr = node.acceptVisitor(MainAttrVisitor.INSTANCE, null);
if (attr != null) {
return attr;
}
}
-
return super.getMainAttribute(node);
}
@@ -74,12 +73,12 @@ public final class JavaDesignerBindings extends DefaultDesignerBindings {
private static final MainAttrVisitor INSTANCE = new MainAttrVisitor();
@Override
- public Attribute visit(JavaNode node, Void data) {
+ public Attribute visitJavaNode(JavaNode node, Void data) {
return null; // don't recurse
}
@Override
- public Attribute visit(ASTAnyTypeDeclaration node, Void data) {
+ public Attribute visitTypeDecl(ASTAnyTypeDeclaration node, Void data) {
return new Attribute(node, "SimpleName", node.getSimpleName());
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/CycloVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/CycloVisitor.java
index c6fdec5812..82012dd1fa 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/CycloVisitor.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/CycloVisitor.java
@@ -46,8 +46,8 @@ public class CycloVisitor extends JavaVisitorBase {
@Override
- public final Void visit(JavaNode localNode, MutableInt data) {
- return localNode.isFindBoundary() && !localNode.equals(topNode) ? null : super.visit(localNode, data);
+ public final Void visitJavaNode(JavaNode localNode, MutableInt data) {
+ return localNode.isFindBoundary() && !localNode.equals(topNode) ? null : super.visitJavaNode(localNode, data);
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NcssVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NcssVisitor.java
index e4d434b57c..d21e57758f 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NcssVisitor.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NcssVisitor.java
@@ -64,9 +64,9 @@ public class NcssVisitor extends JavaParserVisitorAdapter {
@Override
- public final Object visit(JavaNode node, Object data) {
+ public final Object visitJavaNode(JavaNode node, Object data) {
// same here
- return super.visit(node, data);
+ return super.visitJavaNode(node, data);
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NpathBaseVisitor.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NpathBaseVisitor.java
index 351d1e685f..c937d63df7 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NpathBaseVisitor.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/NpathBaseVisitor.java
@@ -80,13 +80,13 @@ public class NpathBaseVisitor extends JavaParserVisitorAdapter {
@Override
- public Object visit(ASTMethodOrConstructorDeclaration node, Object data) {
+ public Object visitMethodOrCtor(ASTMethodOrConstructorDeclaration node, Object data) {
return multiplyChildrenComplexities(node, data);
}
@Override
- public Object visit(JavaNode node, Object data) {
+ public Object visitJavaNode(JavaNode node, Object data) {
return multiplyChildrenComplexities(node, data);
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/TccAttributeAccessCollector.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/TccAttributeAccessCollector.java
index 4a6c04c7eb..d7f5a30544 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/TccAttributeAccessCollector.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/internal/visitors/TccAttributeAccessCollector.java
@@ -52,18 +52,18 @@ public class TccAttributeAccessCollector extends JavaParserVisitorAdapter {
*/
@SuppressWarnings("unchecked")
public Map> start() {
- return (Map>) this.visit(exploredClass, new HashMap>());
+ return (Map>) this.visitTypeDecl(exploredClass, new HashMap>());
}
@Override
- public Object visit(ASTAnyTypeDeclaration node, Object data) {
+ public Object visitTypeDecl(ASTAnyTypeDeclaration node, Object data) {
if (Objects.equals(node, exploredClass)) {
methodAttributeAccess = new HashMap<>();
- super.visit(node, data);
+ super.visitTypeDecl(node, data);
} else if (node instanceof ASTClassOrInterfaceDeclaration
&& ((ASTClassOrInterfaceDeclaration) node).isLocal()) {
- super.visit(node, data);
+ super.visitTypeDecl(node, data);
}
return methodAttributeAccess;
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/qname/QualifiedNameResolver.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/qname/QualifiedNameResolver.java
index b0090a5516..51091985c1 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/qname/QualifiedNameResolver.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/qname/QualifiedNameResolver.java
@@ -204,7 +204,7 @@ public class QualifiedNameResolver extends JavaParserVisitorAdapter {
@Override
- public Object visit(ASTAnyTypeDeclaration node, Object data) {
+ public Object visitTypeDecl(ASTAnyTypeDeclaration node, Object data) {
int localIndex = NOTLOCAL_PLACEHOLDER;
if (node instanceof ASTClassOrInterfaceDeclaration
&& ((ASTClassOrInterfaceDeclaration) node).isLocal()) {
@@ -216,7 +216,7 @@ public class QualifiedNameResolver extends JavaParserVisitorAdapter {
((AbstractAnyTypeDeclaration) node).setQualifiedName(contextClassQName());
- super.visit(node, data);
+ super.visitTypeDecl(node, data);
// go back to previous context
rollbackClassContext();
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaMetricsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaMetricsRule.java
index 651e8b7282..40f60f72ac 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaMetricsRule.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaMetricsRule.java
@@ -13,7 +13,6 @@ import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTLambdaExpression;
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
-import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.ast.MethodLikeNode;
@@ -46,7 +45,7 @@ public abstract class AbstractJavaMetricsRule extends AbstractJavaRule {
public Object visit(ASTAnyTypeDeclaration node, Object data) {
- return visit((JavaNode) node, data);
+ return visitJavaNode(node, data);
}
@@ -73,7 +72,7 @@ public abstract class AbstractJavaMetricsRule extends AbstractJavaRule {
public Object visit(MethodLikeNode node, Object data) {
- return visit((JavaNode) node, data);
+ return visitJavaNode(node, data);
}
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRulechainRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRulechainRule.java
index a8a6d05b4c..68b4861393 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRulechainRule.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/AbstractJavaRulechainRule.java
@@ -39,7 +39,7 @@ public abstract class AbstractJavaRulechainRule extends AbstractJavaRule {
}
@Override
- public Object visit(JavaNode node, Object data) {
+ public Object visitJavaNode(JavaNode node, Object data) {
return data;
}
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java
index 540bd27afa..4e4b872f4c 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java
@@ -323,11 +323,11 @@ public class UnusedAssignmentRule extends AbstractJavaRule {
// following deals with control flow structures
@Override
- public Object visit(JavaNode node, Object data) {
+ public Object visitJavaNode(JavaNode node, Object data) {
for (JavaNode child : node.children()) {
// each output is passed as input to the next (most relevant for blocks)
- data = child.jjtAccept(this, data);
+ data = child.acceptVisitor(this, data);
}
return data;
@@ -572,7 +572,7 @@ public class UnusedAssignmentRule extends AbstractJavaRule {
@Override
public Object visit(ASTCatchStatement node, Object data) {
- SpanInfo result = (SpanInfo) visit((JavaNode) node, data);
+ SpanInfo result = (SpanInfo) visitJavaNode(node, data);
result.deleteVar(node.getExceptionId());
return result;
}
@@ -826,7 +826,7 @@ public class UnusedAssignmentRule extends AbstractJavaRule {
}
return result;
} else {
- return visit(node, data);
+ return visitJavaNode(node, data);
}
}
@@ -858,7 +858,7 @@ public class UnusedAssignmentRule extends AbstractJavaRule {
@Override
public Object visit(ASTPrimaryExpression node, Object data) {
- SpanInfo state = (SpanInfo) visit((JavaNode) node, data); // visit subexpressions
+ SpanInfo state = (SpanInfo) visitJavaNode(node, data); // visit subexpressions
ASTVariableDeclaratorId var = getVarFromExpression(node, false);
if (var != null) {
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AbstractJavaCounterCheckRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AbstractJavaCounterCheckRule.java
index bb53d162a5..d9a741004f 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AbstractJavaCounterCheckRule.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AbstractJavaCounterCheckRule.java
@@ -46,7 +46,7 @@ public abstract class AbstractJavaCounterCheckRule extends A
@Override
- public Object visit(JavaNode node, Object data) {
+ public Object visitJavaNode(JavaNode node, Object data) {
@SuppressWarnings("unchecked")
T t = (T) node;
// since we only visit this node, it's ok
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ScopeAndDeclarationFinder.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ScopeAndDeclarationFinder.java
index b2773f4bdc..c7b11b1a29 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ScopeAndDeclarationFinder.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ScopeAndDeclarationFinder.java
@@ -25,7 +25,6 @@ import net.sourceforge.pmd.lang.java.ast.ASTRecordDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement;
import net.sourceforge.pmd.lang.java.ast.ASTTryStatement;
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
-import net.sourceforge.pmd.lang.java.ast.AbstractJavaNode;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
import net.sourceforge.pmd.lang.symboltable.Scope;
@@ -294,8 +293,8 @@ public class ScopeAndDeclarationFinder extends JavaParserVisitorAdapter {
return data;
}
- private void cont(AbstractJavaNode node) {
- super.visit(node, null);
+ private void cont(JavaNode node) {
+ super.visitJavaNode(node, null);
scopes.pop();
}
}
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AccessNodeTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AccessNodeTest.java
index 1db6859106..053dc9a30f 100644
--- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AccessNodeTest.java
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/AccessNodeTest.java
@@ -25,7 +25,7 @@ public class AccessNodeTest extends BaseParserTest {
@Override
protected R acceptVisitor(JavaVisitor super P, ? extends R> visitor, P data) {
- return visitor.visit(this, data);
+ return visitor.visitJavaNode(this, data);
}
}
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/metrics/ProjectMemoizerTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/metrics/ProjectMemoizerTest.java
index b11a593272..9d9512ba37 100644
--- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/metrics/ProjectMemoizerTest.java
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/metrics/ProjectMemoizerTest.java
@@ -67,20 +67,20 @@ public class ProjectMemoizerTest extends BaseNonParserTest {
acu.jjtAccept(new JavaParserVisitorAdapter() {
@Override
- public Object visit(ASTMethodOrConstructorDeclaration node, Object data) {
+ public Object visitMethodOrCtor(ASTMethodOrConstructorDeclaration node, Object data) {
if (opMetricKey.supports(node)) {
result.add((int) MetricsUtil.computeMetric(opMetricKey, node, MetricOptions.emptyOptions(), force));
}
- return super.visit(node, data);
+ return super.visitMethodOrCtor(node, data);
}
@Override
- public Object visit(ASTAnyTypeDeclaration node, Object data) {
+ public Object visitTypeDecl(ASTAnyTypeDeclaration node, Object data) {
if (classMetricKey.supports(node)) {
result.add((int) MetricsUtil.computeMetric(classMetricKey, node, MetricOptions.emptyOptions(), force));
}
- return super.visit(node, data);
+ return super.visitTypeDecl(node, data);
}
}, null);