diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java index 2ed4860578..f6820e568f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java @@ -23,7 +23,7 @@ public abstract class AbstractJjtreeNode> extends Abstra private JavaccToken lastToken; - public AbstractJjtreeNode(int id) { + protected AbstractJjtreeNode(int id) { super(); this.id = id; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaNode.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaNode.java index 67e7789396..5ddc34f542 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaNode.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaNode.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.ast; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode; import net.sourceforge.pmd.lang.symboltable.Scope; @@ -25,24 +24,6 @@ public abstract class AbstractJavaNode extends AbstractJjtreeNode impl super(id); } - @Override - public Object childrenAccept(JavaParserVisitor visitor, Object data) { - for (Node child : children()) { - ((JavaNode) child).jjtAccept(visitor, data); - } - - return data; - } - - - @Override - public void childrenAccept(SideEffectingVisitor visitor, T data) { - for (Node child : children()) { - ((JavaNode) child).jjtAccept(visitor, data); - } - - } - @Override public Scope getScope() { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaNode.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaNode.java index 450f240160..f39565a941 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaNode.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaNode.java @@ -27,24 +27,6 @@ public interface JavaNode extends ScopedNode, JjtreeNode { Object jjtAccept(JavaParserVisitor visitor, Object data); - /** - * Dispatches the given visitor to the children of this node. This is the default implementation - * of {@link JavaParserVisitor#visit(JavaNode, Object)}, to which all other default - * implementations for visit methods delegate. Unless visit methods are overridden without calling - * {@code super.visit}, the visitor performs a depth-first tree walk. - * - *

The return value of the visit methods called on children are ignored. - * - * @param visitor Visitor to dispatch - * @param data Visit data - * - * @deprecated This method is not useful, the logic for combining - * children values should be present on the visitor, not the node - */ - @Deprecated - Object childrenAccept(JavaParserVisitor visitor, Object data); - - /** * Calls back the visitor's visit method corresponding to the runtime type of this Node. * @@ -55,18 +37,6 @@ public interface JavaNode extends ScopedNode, JjtreeNode { void jjtAccept(SideEffectingVisitor visitor, T data); - /** - * Dispatches the given visitor to the children of this node. This is the default implementation - * of {@link SideEffectingVisitor#visit(JavaNode, Object)}, to which all other default - * implementations for visit methods delegate. Unless visit methods are overridden without calling - * {@code super.visit}, the visitor performs a depth-first tree walk. - * - * @param visitor Visitor to dispatch - * @param data Visit data - * @param Type of data - */ - void childrenAccept(SideEffectingVisitor visitor, T data); - @InternalApi @Deprecated void setScope(Scope scope); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CouplingBetweenObjectsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CouplingBetweenObjectsRule.java index 83988c0421..c2d3f23236 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CouplingBetweenObjectsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/CouplingBetweenObjectsRule.java @@ -54,14 +54,16 @@ public class CouplingBetweenObjectsRule extends AbstractJavaRule { typesFoundSoFar = new HashSet<>(); couplingCount = 0; - Object returnObj = cu.childrenAccept(this, data); + for (JavaNode child : cu.children()) { + child.jjtAccept(this, data); + } if (couplingCount > getProperty(THRESHOLD_DESCRIPTOR)) { addViolation(data, cu, "A value of " + couplingCount + " may denote a high amount of coupling within the class"); } - return returnObj; + return data; } @Override diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/MoreThanOneLoggerRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/MoreThanOneLoggerRule.java index 96647cea68..2c7bcd023d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/MoreThanOneLoggerRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/MoreThanOneLoggerRule.java @@ -49,7 +49,9 @@ public class MoreThanOneLoggerRule extends AbstractJavaRule { stack.push(count); count = NumericConstants.ZERO; - node.childrenAccept(this, data); + for (JavaNode child : node.children()) { + child.jjtAccept(this, data); + } if (count > 1) { addViolation(data, node); diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/AbstractEcmascriptNode.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/AbstractEcmascriptNode.java index fa1c5b2ef0..2000f9c8fc 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/AbstractEcmascriptNode.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/AbstractEcmascriptNode.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.ast; import org.mozilla.javascript.ast.AstNode; -import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.SourceCodePositioner; import net.sourceforge.pmd.lang.ast.impl.AbstractNodeWithTextCoordinates; @@ -42,21 +41,6 @@ abstract class AbstractEcmascriptNode extends AbstractNodeWit return visitor.visit(this, data); } - /** - * Accept the visitor. * - */ - @Override - public Object childrenAccept(EcmascriptParserVisitor visitor, Object data) { - for (Node child : children) { - // we know that the children here - // are all EcmascriptNodes - @SuppressWarnings("unchecked") - EcmascriptNode ecmascriptNode = (EcmascriptNode) child; - ecmascriptNode.jjtAccept(visitor, data); - } - return data; - } - @Override @Deprecated public T getNode() { diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptNode.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptNode.java index 8af33ba419..5ec0fe88b5 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptNode.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptNode.java @@ -15,14 +15,6 @@ public interface EcmascriptNode extends GenericNode node, Object data); - Object visit(ASTArrayComprehension node, Object data); + default Object visit(EcmascriptNode node, Object data) { + for (EcmascriptNode child : node.children()) { + child.jjtAccept(this, data); + } + return data; + } - Object visit(ASTArrayComprehensionLoop node, Object data); + default Object visit(ASTArrayComprehension node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTArrayLiteral node, Object data); + default Object visit(ASTArrayComprehensionLoop node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTAssignment node, Object data); + default Object visit(ASTArrayLiteral node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTAstRoot node, Object data); + default Object visit(ASTAssignment node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTBlock node, Object data); + default Object visit(ASTAstRoot node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTBreakStatement node, Object data); + default Object visit(ASTBlock node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTCatchClause node, Object data); + default Object visit(ASTBreakStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTComment node, Object data); + default Object visit(ASTCatchClause node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTConditionalExpression node, Object data); + default Object visit(ASTComment node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTContinueStatement node, Object data); + default Object visit(ASTConditionalExpression node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTDoLoop node, Object data); + default Object visit(ASTContinueStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTElementGet node, Object data); + default Object visit(ASTDoLoop node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTEmptyExpression node, Object data); + default Object visit(ASTElementGet node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTExpressionStatement node, Object data); + default Object visit(ASTEmptyExpression node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTForInLoop node, Object data); + default Object visit(ASTExpressionStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTForLoop node, Object data); + default Object visit(ASTForInLoop node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTFunctionCall node, Object data); + default Object visit(ASTForLoop node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTFunctionNode node, Object data); + default Object visit(ASTFunctionCall node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTIfStatement node, Object data); + default Object visit(ASTFunctionNode node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTInfixExpression node, Object data); + default Object visit(ASTIfStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTKeywordLiteral node, Object data); + default Object visit(ASTInfixExpression node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTLabel node, Object data); + default Object visit(ASTKeywordLiteral node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTLabeledStatement node, Object data); + default Object visit(ASTLabel node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTLetNode node, Object data); + default Object visit(ASTLabeledStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTName node, Object data); + default Object visit(ASTLetNode node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTNewExpression node, Object data); + default Object visit(ASTName node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTNumberLiteral node, Object data); + default Object visit(ASTNewExpression node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTObjectLiteral node, Object data); + default Object visit(ASTNumberLiteral node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTObjectProperty node, Object data); + default Object visit(ASTObjectLiteral node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTParenthesizedExpression node, Object data); + default Object visit(ASTObjectProperty node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTPropertyGet node, Object data); + default Object visit(ASTParenthesizedExpression node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTRegExpLiteral node, Object data); + default Object visit(ASTPropertyGet node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTReturnStatement node, Object data); + default Object visit(ASTRegExpLiteral node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTScope node, Object data); + default Object visit(ASTReturnStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTStringLiteral node, Object data); + default Object visit(ASTScope node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTSwitchCase node, Object data); + default Object visit(ASTStringLiteral node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTSwitchStatement node, Object data); + default Object visit(ASTSwitchCase node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTThrowStatement node, Object data); + default Object visit(ASTSwitchStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTTryStatement node, Object data); + default Object visit(ASTThrowStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTUnaryExpression node, Object data); + default Object visit(ASTTryStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTVariableDeclaration node, Object data); + default Object visit(ASTUnaryExpression node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTVariableInitializer node, Object data); + default Object visit(ASTVariableDeclaration node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTWhileLoop node, Object data); + default Object visit(ASTVariableInitializer node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTWithStatement node, Object data); + default Object visit(ASTWhileLoop node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTXmlDotQuery node, Object data); + default Object visit(ASTWithStatement node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTXmlExpression node, Object data); + default Object visit(ASTXmlDotQuery node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTXmlMemberGet node, Object data); + default Object visit(ASTXmlExpression node, Object data) { + return visit((EcmascriptNode) node, data); + } - Object visit(ASTXmlString node, Object data); + default Object visit(ASTXmlMemberGet node, Object data) { + return visit((EcmascriptNode) node, data); + } + + default Object visit(ASTXmlString node, Object data) { + return visit((EcmascriptNode) node, data); + } } diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserVisitorAdapter.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserVisitorAdapter.java index b8ee75de59..4b42dfc3ee 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserVisitorAdapter.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParserVisitorAdapter.java @@ -6,254 +6,4 @@ package net.sourceforge.pmd.lang.ecmascript.ast; public class EcmascriptParserVisitorAdapter implements EcmascriptParserVisitor { - @Override - public Object visit(EcmascriptNode node, Object data) { - node.childrenAccept(this, data); - return null; - } - - @Override - public Object visit(ASTArrayComprehension node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTArrayComprehensionLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTArrayLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTAssignment node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTAstRoot node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTBlock node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTBreakStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTCatchClause node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTComment node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTConditionalExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTContinueStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTDoLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTElementGet node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTEmptyExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTExpressionStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTForInLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTForLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTFunctionCall node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTFunctionNode node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTIfStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTInfixExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTKeywordLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTLabel node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTLabeledStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTLetNode node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTName node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTNewExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTNumberLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTObjectLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTObjectProperty node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTParenthesizedExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTPropertyGet node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTRegExpLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTReturnStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTScope node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTStringLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTSwitchCase node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTSwitchStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTThrowStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTTryStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTUnaryExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTVariableDeclaration node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTVariableInitializer node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTWhileLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTWithStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlDotQuery node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlMemberGet node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlString node, Object data) { - return visit((EcmascriptNode) node, data); - } } diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java index 61ab2aa106..954742a9b8 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/rule/AbstractEcmascriptRule.java @@ -13,56 +13,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ecmascript.EcmascriptLanguageModule; import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions; import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions.Version; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTArrayComprehension; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTArrayComprehensionLoop; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTArrayLiteral; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTAssignment; import net.sourceforge.pmd.lang.ecmascript.ast.ASTAstRoot; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTBlock; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTBreakStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTCatchClause; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTComment; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTConditionalExpression; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTContinueStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTDoLoop; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTElementGet; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTEmptyExpression; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTExpressionStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTForInLoop; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTForLoop; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTFunctionCall; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTFunctionNode; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTIfStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTInfixExpression; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTKeywordLiteral; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTLabel; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTLabeledStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTLetNode; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTName; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTNewExpression; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTNumberLiteral; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTObjectLiteral; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTObjectProperty; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTParenthesizedExpression; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTPropertyGet; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTRegExpLiteral; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTReturnStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTScope; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTStringLiteral; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTSwitchCase; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTSwitchStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTThrowStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTTryStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTUnaryExpression; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTVariableDeclaration; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTVariableInitializer; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTWhileLoop; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTWithStatement; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTXmlDotQuery; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTXmlExpression; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTXmlMemberGet; -import net.sourceforge.pmd.lang.ecmascript.ast.ASTXmlString; -import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptNode; import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserVisitor; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.lang.rule.ImmutableLanguage; @@ -101,261 +52,4 @@ public abstract class AbstractEcmascriptRule extends AbstractRule } } - // - // The following APIs are identical to those in - // EcmascriptParserVisitorAdapter. - // Due to Java single inheritance, it preferred to extend from the more - // complex Rule base class instead of from relatively simple Visitor. - // - - @Override - public Object visit(EcmascriptNode node, Object data) { - node.childrenAccept(this, data); - return null; - } - - @Override - public Object visit(ASTArrayComprehension node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTArrayComprehensionLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTArrayLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTAssignment node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTAstRoot node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTBlock node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTBreakStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTCatchClause node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTComment node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTConditionalExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTContinueStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTDoLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTElementGet node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTEmptyExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTExpressionStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTForInLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTForLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTFunctionCall node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTFunctionNode node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTIfStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTInfixExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTKeywordLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTLabel node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTLabeledStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTLetNode node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTName node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTNewExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTNumberLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTObjectLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTObjectProperty node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTParenthesizedExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTPropertyGet node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTRegExpLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTReturnStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTScope node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTStringLiteral node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTSwitchCase node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTSwitchStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTThrowStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTTryStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTUnaryExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTVariableDeclaration node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTVariableInitializer node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTWhileLoop node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTWithStatement node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlDotQuery node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlExpression node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlMemberGet node, Object data) { - return visit((EcmascriptNode) node, data); - } - - @Override - public Object visit(ASTXmlString node, Object data) { - return visit((EcmascriptNode) node, data); - } }