[javascript] Internalize AST constructors

This commit is contained in:
Andreas Dangel
2020-04-17 20:41:54 +02:00
parent 1d4884d954
commit 623ba4c92e
60 changed files with 315 additions and 229 deletions

View File

@ -80,7 +80,7 @@ You can identify them with the `@InternalApi` annotation. You'll also get a depr
As part of the changes we'd like to do to AST classes for 7.0.0, we would like to
hide some methods and constructors that rule writers should not have access to.
The following usages are now deprecated in the **Visualforce** and **PLSQL** ASTs:
The following usages are now deprecated in the **Javascript**, **Visualforce** and **PLSQL** ASTs:
* Manual instantiation of nodes. **Constructors of node classes are deprecated** and
marked {% jdoc core::annotation.InternalApi %}. Nodes should only be obtained from the parser,
@ -101,6 +101,7 @@ The following usages are now deprecated in the **Visualforce** and **PLSQL** AST
These deprecations are added to the following language modules in this release.
Please look at the package documentation to find out the full list of deprecations.
* Javascript: **{% jdoc_package javascript::lang.ecmascript.ast %}**
* Visualforce: **{% jdoc_package visualforce::lang.vf.ast %}**
* PL/SQL: **{% jdoc_package plsql::lang.plsql.ast %}**

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ArrayComprehension;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTArrayComprehension extends AbstractEcmascriptNode<ArrayComprehension> {
@Deprecated
@InternalApi
public ASTArrayComprehension(ArrayComprehension arrayComprehension) {
super(arrayComprehension);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,15 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ArrayComprehensionLoop;
public class ASTArrayComprehensionLoop extends AbstractEcmascriptNode<ArrayComprehensionLoop> {
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTArrayComprehensionLoop extends AbstractEcmascriptNode<ArrayComprehensionLoop> {
@Deprecated
@InternalApi
public ASTArrayComprehensionLoop(ArrayComprehensionLoop arrayComprehensionLoop) {
super(arrayComprehensionLoop);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,17 +6,18 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ArrayLiteral;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTArrayLiteral extends AbstractEcmascriptNode<ArrayLiteral>
implements DestructuringNode, TrailingCommaNode {
private boolean trailingComma;
@Deprecated
@InternalApi
public ASTArrayLiteral(ArrayLiteral arrayLiteral) {
super(arrayLiteral);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);
@ -33,7 +34,14 @@ public class ASTArrayLiteral extends AbstractEcmascriptNode<ArrayLiteral>
}
@Override
@Deprecated
@InternalApi
public void setTrailingComma(boolean trailingComma) {
this.trailingComma = trailingComma;
setTrailingCommaExists(trailingComma);
}
@Override
protected void setTrailingCommaExists(boolean b) {
this.trailingComma = b;
}
}

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.Assignment;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTAssignment extends AbstractInfixEcmascriptNode<Assignment> {
@Deprecated
@InternalApi
public ASTAssignment(Assignment asssignment) {
super(asssignment);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,16 +6,16 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.AstRoot;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.RootNode;
public class ASTAstRoot extends AbstractEcmascriptNode<AstRoot> implements RootNode {
@Deprecated
@InternalApi
public ASTAstRoot(AstRoot astRoot) {
super(astRoot);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.Block;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTBlock extends AbstractEcmascriptNode<Block> {
@Deprecated
@InternalApi
public ASTBlock(Block block) {
super(block);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,15 +6,16 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.BreakStatement;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTBreakStatement extends AbstractEcmascriptNode<BreakStatement> {
@Deprecated
@InternalApi
public ASTBreakStatement(BreakStatement breakStatement) {
super(breakStatement);
super.setImage(breakStatement.getBreakLabel() != null ? breakStatement.getBreakLabel().getIdentifier() : null);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.CatchClause;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTCatchClause extends AbstractEcmascriptNode<CatchClause> {
@Deprecated
@InternalApi
public ASTCatchClause(CatchClause catchClause) {
super(catchClause);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.Comment;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTComment extends AbstractEcmascriptNode<Comment> {
@Deprecated
@InternalApi
public ASTComment(Comment comment) {
super(comment);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ConditionalExpression;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTConditionalExpression extends AbstractEcmascriptNode<ConditionalExpression> {
@Deprecated
@InternalApi
public ASTConditionalExpression(ConditionalExpression conditionalExpression) {
super(conditionalExpression);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,15 +6,16 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ContinueStatement;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTContinueStatement extends AbstractEcmascriptNode<ContinueStatement> {
@Deprecated
@InternalApi
public ASTContinueStatement(ContinueStatement continueStatement) {
super(continueStatement);
super.setImage(continueStatement.getLabel() != null ? continueStatement.getLabel().getIdentifier() : null);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.DoLoop;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTDoLoop extends AbstractEcmascriptNode<DoLoop> {
@Deprecated
@InternalApi
public ASTDoLoop(DoLoop doLoop) {
super(doLoop);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ElementGet;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTElementGet extends AbstractEcmascriptNode<ElementGet> {
@Deprecated
@InternalApi
public ASTElementGet(ElementGet elementGet) {
super(elementGet);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.EmptyExpression;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTEmptyExpression extends AbstractEcmascriptNode<EmptyExpression> {
@Deprecated
@InternalApi
public ASTEmptyExpression(EmptyExpression emptyExpression) {
super(emptyExpression);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,7 +6,11 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.EmptyStatement;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTEmptyStatement extends AbstractEcmascriptNode<EmptyStatement> {
@Deprecated
@InternalApi
public ASTEmptyStatement(EmptyStatement emptyStatement) {
super(emptyStatement);
}

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -7,14 +7,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.Token;
import org.mozilla.javascript.ast.ExpressionStatement;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTExpressionStatement extends AbstractEcmascriptNode<ExpressionStatement> {
@Deprecated
@InternalApi
public ASTExpressionStatement(ExpressionStatement expressionStatement) {
super(expressionStatement);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ForInLoop;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTForInLoop extends AbstractEcmascriptNode<ForInLoop> {
@Deprecated
@InternalApi
public ASTForInLoop(ForInLoop forInLoop) {
super(forInLoop);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.ForLoop;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTForLoop extends AbstractEcmascriptNode<ForLoop> {
@Deprecated
@InternalApi
public ASTForLoop(ForLoop forLoop) {
super(forLoop);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.FunctionCall;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTFunctionCall extends AbstractEcmascriptNode<FunctionCall> {
@Deprecated
@InternalApi
public ASTFunctionCall(FunctionCall functionCall) {
super(functionCall);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,15 +6,16 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.FunctionNode;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTFunctionNode extends AbstractEcmascriptNode<FunctionNode> {
@Deprecated
@InternalApi
public ASTFunctionNode(FunctionNode functionNode) {
super(functionNode);
super.setImage(functionNode.getName());
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.IfStatement;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTIfStatement extends AbstractEcmascriptNode<IfStatement> {
@Deprecated
@InternalApi
public ASTIfStatement(IfStatement ifStatement) {
super(ifStatement);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.InfixExpression;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTInfixExpression extends AbstractInfixEcmascriptNode<InfixExpression> {
@Deprecated
@InternalApi
public ASTInfixExpression(InfixExpression infixExpression) {
super(infixExpression);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -9,15 +9,16 @@ import java.util.Locale;
import org.mozilla.javascript.Token;
import org.mozilla.javascript.ast.KeywordLiteral;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTKeywordLiteral extends AbstractEcmascriptNode<KeywordLiteral> {
@Deprecated
@InternalApi
public ASTKeywordLiteral(KeywordLiteral keywordLiteral) {
super(keywordLiteral);
super.setImage(Token.typeToName(keywordLiteral.getType()).toLowerCase(Locale.ROOT));
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,15 +6,16 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.Label;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTLabel extends AbstractEcmascriptNode<Label> {
@Deprecated
@InternalApi
public ASTLabel(Label label) {
super(label);
super.setImage(label.getName());
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.LabeledStatement;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTLabeledStatement extends AbstractEcmascriptNode<LabeledStatement> {
@Deprecated
@InternalApi
public ASTLabeledStatement(LabeledStatement labeledStatement) {
super(labeledStatement);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.LetNode;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTLetNode extends AbstractEcmascriptNode<LetNode> {
@Deprecated
@InternalApi
public ASTLetNode(LetNode letNode) {
super(letNode);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,15 +6,16 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.Name;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTName extends AbstractEcmascriptNode<Name> {
@Deprecated
@InternalApi
public ASTName(Name name) {
super(name);
super.setImage(name.getIdentifier());
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,14 +6,15 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.NewExpression;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTNewExpression extends AbstractEcmascriptNode<NewExpression> {
@Deprecated
@InternalApi
public ASTNewExpression(NewExpression newExpression) {
super(newExpression);
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

View File

@ -1,4 +1,4 @@
/**
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
@ -6,15 +6,16 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import org.mozilla.javascript.ast.NumberLiteral;
import net.sourceforge.pmd.annotation.InternalApi;
public class ASTNumberLiteral extends AbstractEcmascriptNode<NumberLiteral> {
@Deprecated
@InternalApi
public ASTNumberLiteral(NumberLiteral numberLiteral) {
super(numberLiteral);
super.setImage(numberLiteral.getValue());
}
/**
* Accept the visitor.
*/
@Override
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
return visitor.visit(this, data);

Some files were not shown because too many files have changed in this diff Show More