Cleanup ecmascript visitor

This commit is contained in:
Clément Fournier
2020-04-26 17:08:20 +02:00
parent cd1aaa64de
commit 7beb2824c1
4 changed files with 162 additions and 606 deletions

View File

@ -7,6 +7,7 @@ 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.NodeStream;
public interface EcmascriptNode<T extends AstNode> extends Node {
@ -31,6 +32,13 @@ public interface EcmascriptNode<T extends AstNode> extends Node {
@Deprecated
T getNode();
@Override
default NodeStream<? extends EcmascriptNode<?>> children() {
return (NodeStream) Node.super.children();
}
/**
* Get the JsDoc associated with the given node. If there is no JsDoc on
* this node, it may be associated with a parent node, on more

View File

@ -5,103 +5,207 @@
package net.sourceforge.pmd.lang.ecmascript.ast;
public interface EcmascriptParserVisitor {
Object visit(EcmascriptNode<?> 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);
}
}

View File

@ -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);
}
}