From 26a5971af308e8e51c6d291136035a7b48298313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 17 Jan 2020 15:11:01 +0100 Subject: [PATCH] Replace deprecated usages --- .../sourceforge/pmd/lang/ast/NodeStream.java | 2 +- pmd-java/etc/grammar/Java.jjt | 2 +- .../pmd/lang/java/ast/ASTAmbiguousName.java | 6 ++--- .../ast/ASTAnonymousClassDeclaration.java | 2 +- .../pmd/lang/java/ast/ASTArgumentList.java | 2 +- .../pmd/lang/java/ast/ASTArrayAccess.java | 4 ++-- .../pmd/lang/java/ast/ASTArrayAllocation.java | 4 ++-- .../pmd/lang/java/ast/ASTArrayDimExpr.java | 2 +- .../pmd/lang/java/ast/ASTArrayDimensions.java | 6 ++--- .../pmd/lang/java/ast/ASTArrayType.java | 4 ++-- .../pmd/lang/java/ast/ASTAssignableExpr.java | 4 ++-- .../java/ast/ASTAssignmentExpression.java | 2 +- .../pmd/lang/java/ast/ASTBlock.java | 4 ++-- .../pmd/lang/java/ast/ASTCastExpression.java | 2 +- .../pmd/lang/java/ast/ASTClassLiteral.java | 4 ++-- .../java/ast/ASTConditionalExpression.java | 4 ++-- .../pmd/lang/java/ast/ASTConstructorCall.java | 10 ++++----- .../pmd/lang/java/ast/ASTDefaultValue.java | 2 +- .../pmd/lang/java/ast/ASTEnumConstant.java | 2 +- .../lang/java/ast/ASTExpressionStatement.java | 2 +- .../pmd/lang/java/ast/ASTForUpdate.java | 2 +- .../lang/java/ast/ASTForeachStatement.java | 2 +- .../lang/java/ast/ASTFormalParameters.java | 2 +- .../java/ast/ASTInstanceOfExpression.java | 2 +- .../lang/java/ast/ASTIntersectionType.java | 4 ++-- .../lang/java/ast/ASTLabeledStatement.java | 2 +- .../lang/java/ast/ASTLambdaExpression.java | 4 ++-- .../lang/java/ast/ASTLambdaParameterList.java | 6 ++--- .../lang/java/ast/ASTLocalClassStatement.java | 2 +- .../pmd/lang/java/ast/ASTMemberValuePair.java | 4 ++-- .../pmd/lang/java/ast/ASTMethodCall.java | 6 ++--- .../lang/java/ast/ASTMethodDeclaration.java | 2 +- .../lang/java/ast/ASTMethodDeclarator.java | 2 +- .../pmd/lang/java/ast/ASTMethodReference.java | 4 ++-- .../lang/java/ast/ASTReceiverParameter.java | 2 +- .../pmd/lang/java/ast/ASTResource.java | 4 ++-- .../pmd/lang/java/ast/ASTResourceList.java | 4 ++-- .../pmd/lang/java/ast/ASTResultType.java | 2 +- .../pmd/lang/java/ast/ASTSuperExpression.java | 2 +- .../pmd/lang/java/ast/ASTSwitchLike.java | 2 +- .../java/ast/ASTSynchronizedStatement.java | 4 ++-- .../pmd/lang/java/ast/ASTThisExpression.java | 2 +- .../pmd/lang/java/ast/ASTThrowsList.java | 4 ++-- .../pmd/lang/java/ast/ASTTryStatement.java | 2 +- .../pmd/lang/java/ast/ASTTypeExpression.java | 2 +- .../pmd/lang/java/ast/ASTUnaryExpression.java | 2 +- .../pmd/lang/java/ast/ASTUnionType.java | 4 ++-- .../java/ast/ASTVariableDeclaratorId.java | 8 +++---- .../pmd/lang/java/ast/ASTWildcardType.java | 8 +++---- .../pmd/lang/java/ast/AbstractJavaNode.java | 17 +++++++------- .../pmd/lang/java/ast/AstImplUtil.java | 4 ++-- .../pmd/lang/java/ast/InternalInterfaces.java | 22 +++++++++---------- .../pmd/lang/java/ast/JavaNode.java | 1 - .../ast/internal/LanguageLevelChecker.java | 2 +- .../internal/AnnotationSuppressionUtil.java | 10 ++++----- .../symboltable/VariableNameDeclaration.java | 10 ++++----- .../typeresolution/ClassTypeResolver.java | 12 +++++----- .../typeresolution/MethodTypeResolution.java | 8 +++---- .../pmd/lang/java/ast/ASTFieldAccessTest.kt | 5 ++--- .../pmd/lang/java/ast/NodeParsingCtx.kt | 4 +--- .../pmd/lang/plsql/ast/AbstractPLSQLNode.java | 2 +- 61 files changed, 129 insertions(+), 134 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java index 9ce57d3249..9441de7294 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java @@ -367,7 +367,7 @@ public interface NodeStream extends Iterable<@NonNull T> { * Returns a node stream containing all the (first-degree) parents of the nodes * contained in this stream. * - *

This is equivalent to {@code map(Node::jjtGetParent)}. + *

This is equivalent to {@code map(Node::getParent)}. * * @return A stream of parents * diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 50dd0c2c8e..a98798ff1c 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -371,7 +371,7 @@ class JavaParser { private void injectTop() { AbstractJavaNode top = (AbstractJavaNode) jjtree.popNode(); AbstractJavaNode prev = (AbstractJavaNode) jjtree.peekNode(); - prev.jjtAddChild(top, prev.jjtGetNumChildren()); + prev.jjtAddChild(top, prev.getNumChildren()); prev.jjtSetLastToken(top.jjtGetLastToken()); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAmbiguousName.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAmbiguousName.java index d312566bd5..a875c6c0d9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAmbiguousName.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAmbiguousName.java @@ -207,12 +207,12 @@ public final class ASTAmbiguousName extends AbstractJavaExpr implements ASTRefer // this reference and the lambdas can be optimised to a singleton shrinkOneSegment( simpleName -> { - simpleName.jjtGetParent().setImage(simpleName.getImage()); - simpleName.jjtGetParent().removeChildAtIndex(simpleName.jjtGetChildIndex()); + simpleName.getParent().setImage(simpleName.getImage()); + simpleName.getParent().removeChildAtIndex(simpleName.getIndexInParent()); return null; }, (ambig, simpleName) -> { - ambig.jjtGetParent().setImage(simpleName); + ambig.getParent().setImage(simpleName); return null; } ); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnonymousClassDeclaration.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnonymousClassDeclaration.java index 377f8b317a..7adc698138 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnonymousClassDeclaration.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnonymousClassDeclaration.java @@ -55,7 +55,7 @@ public final class ASTAnonymousClassDeclaration extends AbstractJavaTypeNode imp * Returns the body of the anonymous class. */ public ASTClassOrInterfaceBody getBody() { - return (ASTClassOrInterfaceBody) jjtGetChild(0); + return (ASTClassOrInterfaceBody) getChild(0); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArgumentList.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArgumentList.java index fd5d81acbd..0f764d78e1 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArgumentList.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArgumentList.java @@ -42,7 +42,7 @@ public final class ASTArgumentList extends AbstractJavaNode implements Iterable< * Returns the number of arguments of this list. */ public int getArgumentCount() { - return jjtGetNumChildren(); + return getNumChildren(); } @Override diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAccess.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAccess.java index 142a2aebbe..fefe216f3e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAccess.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAccess.java @@ -36,12 +36,12 @@ public final class ASTArrayAccess extends AbstractJavaExpr implements ASTAssigna @NonNull @Override public ASTExpression getQualifier() { - return (ASTExpression) jjtGetChild(0); + return (ASTExpression) getChild(0); } /** Returns the expression within the brackets. */ public ASTExpression getIndexExpression() { - return (ASTExpression) jjtGetChild(1); + return (ASTExpression) getChild(1); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAllocation.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAllocation.java index e6cd34cea3..5ad735a03f 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAllocation.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayAllocation.java @@ -46,13 +46,13 @@ public final class ASTArrayAllocation extends AbstractJavaExpr implements ASTPri * Returns the node representing the array type being instantiated. */ public ASTArrayType getTypeNode() { - return (ASTArrayType) jjtGetChild(0); + return (ASTArrayType) getChild(0); } /** Returns the initializer, if present. */ @Nullable public ASTArrayInitializer getArrayInitializer() { - return AstImplUtil.getChildAs(this, jjtGetNumChildren() - 1, ASTArrayInitializer.class); + return AstImplUtil.getChildAs(this, getNumChildren() - 1, ASTArrayInitializer.class); } /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimExpr.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimExpr.java index c26f841ebf..15c22bff23 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimExpr.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimExpr.java @@ -40,7 +40,7 @@ public final class ASTArrayDimExpr extends ASTArrayTypeDim implements Annotatabl public ASTExpression getLengthExpression() { - return (ASTExpression) jjtGetChild(jjtGetNumChildren() - 1); + return (ASTExpression) getChild(getNumChildren() - 1); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimensions.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimensions.java index e96bce8bfa..26d2a8326c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimensions.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayDimensions.java @@ -62,8 +62,8 @@ public final class ASTArrayDimensions extends AbstractJavaTypeNode implements It } @Override - public ASTArrayTypeDim jjtGetChild(int index) { - return (ASTArrayTypeDim) super.jjtGetChild(index); + public ASTArrayTypeDim getChild(int index) { + return (ASTArrayTypeDim) super.getChild(index); } /** @@ -72,6 +72,6 @@ public final class ASTArrayDimensions extends AbstractJavaTypeNode implements It * is always greater than 0. */ public int getSize() { - return jjtGetNumChildren(); + return getNumChildren(); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayType.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayType.java index c3c277a0ab..db7d06976f 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayType.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTArrayType.java @@ -35,12 +35,12 @@ public final class ASTArrayType extends AbstractJavaTypeNode implements ASTRefer } public ASTArrayDimensions getDimensions() { - return (ASTArrayDimensions) jjtGetChild(1); + return (ASTArrayDimensions) getChild(1); } public ASTType getElementType() { - return (ASTType) jjtGetChild(0); + return (ASTType) getChild(0); } @Override diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignableExpr.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignableExpr.java index 55e52b62c1..56568bb330 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignableExpr.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignableExpr.java @@ -36,10 +36,10 @@ public interface ASTAssignableExpr extends ASTPrimaryExpression { @NonNull default AccessType getAccessType() { - Node parent = this.jjtGetParent(); + Node parent = this.getParent(); if (parent instanceof ASTUnaryExpression && !((ASTUnaryExpression) parent).getOperator().isPure() - || jjtGetChildIndex() == 0 && parent instanceof ASTAssignmentExpression) { + || getIndexInParent() == 0 && parent instanceof ASTAssignmentExpression) { return AccessType.WRITE; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignmentExpression.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignmentExpression.java index cc853d6b72..db7b31a0e5 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignmentExpression.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignmentExpression.java @@ -35,7 +35,7 @@ public final class ASTAssignmentExpression extends AbstractJavaExpr implements I /** Returns the left-hand side, ie the expression being assigned to. */ @Override public ASTAssignableExpr getLeftOperand() { - return (ASTAssignableExpr) jjtGetChild(0); + return (ASTAssignableExpr) getChild(0); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTBlock.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTBlock.java index 450f613e28..54f29bc001 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTBlock.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTBlock.java @@ -55,7 +55,7 @@ public final class ASTBlock extends AbstractStatement implements Iterable 0 ? (ASTClassOrInterfaceType) jjtGetChild(0) : null; + return getNumChildren() > 0 ? (ASTClassOrInterfaceType) getChild(0) : null; } @Override diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java index dffeeb3cdc..2775cab978 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLike.java @@ -56,7 +56,7 @@ public interface ASTSwitchLike extends JavaNode, Iterable { * This is the expression between the parentheses. */ default ASTExpression getTestedExpression() { - return (ASTExpression) jjtGetChild(0); + return (ASTExpression) getChild(0); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSynchronizedStatement.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSynchronizedStatement.java index 604934583c..d917f730de 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSynchronizedStatement.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSynchronizedStatement.java @@ -39,13 +39,13 @@ public final class ASTSynchronizedStatement extends AbstractStatement { * Returns the expression evaluating to the lock object. */ public ASTExpression getLockExpression() { - return (ASTExpression) jjtGetChild(0); + return (ASTExpression) getChild(0); } /** * Returns the body of the statement. */ public ASTBlock getBody() { - return (ASTBlock) jjtGetChild(1); + return (ASTBlock) getChild(1); } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThisExpression.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThisExpression.java index fbf4975c40..c426b06585 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThisExpression.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThisExpression.java @@ -30,7 +30,7 @@ public final class ASTThisExpression extends AbstractJavaExpr implements ASTPrim @Nullable public ASTClassOrInterfaceType getQualifier() { - return jjtGetNumChildren() > 0 ? (ASTClassOrInterfaceType) jjtGetChild(0) : null; + return getNumChildren() > 0 ? (ASTClassOrInterfaceType) getChild(0) : null; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThrowsList.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThrowsList.java index 42bd94107a..5666ae8b16 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThrowsList.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTThrowsList.java @@ -38,8 +38,8 @@ public final class ASTThrowsList extends AbstractJavaNode implements Iterable}. */ public boolean hasUpperBound() { - return isUpperBound && jjtGetNumChildren() > 0; + return isUpperBound && getNumChildren() > 0; } @@ -59,7 +59,7 @@ public final class ASTWildcardType extends AbstractJavaTypeNode implements ASTRe * in {@code }. */ public boolean hasLowerBound() { - return !isUpperBound && jjtGetNumChildren() > 0; + return !isUpperBound && getNumChildren() > 0; } 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 d0a6ef3105..203c1c13c6 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,11 +7,10 @@ package net.sourceforge.pmd.lang.java.ast; import org.apache.commons.lang3.ArrayUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.lang.ast.AbstractNode; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; import net.sourceforge.pmd.lang.java.symbols.table.JSymbolTable; -import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode; import net.sourceforge.pmd.lang.symboltable.Scope; abstract class AbstractJavaNode extends AbstractJjtreeNode implements JavaNode { @@ -91,7 +90,7 @@ abstract class AbstractJavaNode extends AbstractJjtreeNode implements @Override public Scope getScope() { if (scope == null) { - return jjtGetParent().getScope(); + return getParent().getScope(); } return scope; } @@ -144,12 +143,12 @@ abstract class AbstractJavaNode extends AbstractJjtreeNode implements */ void flatten(int idx) { - AbstractJavaNode child = (AbstractJavaNode) jjtGetChild(idx); + AbstractJavaNode child = (AbstractJavaNode) getChild(idx); children = ArrayUtils.remove(children, idx); child.jjtSetParent(null); child.jjtSetChildIndex(-1); - if (child.jjtGetNumChildren() > 0) { + if (child.getNumChildren() > 0) { children = ArrayUtils.insert(idx, children, child.children); } updateChildrenIndices(idx); @@ -199,8 +198,8 @@ abstract class AbstractJavaNode extends AbstractJjtreeNode implements } private void enlargeLeft() { - if (jjtGetNumChildren() > 0) { - enlargeLeft((AbstractJavaNode) jjtGetChild(0)); + if (getNumChildren() > 0) { + enlargeLeft((AbstractJavaNode) getChild(0)); } } @@ -223,14 +222,14 @@ abstract class AbstractJavaNode extends AbstractJjtreeNode implements } /** - * Updates the {@link #jjtGetChildIndex()} of the children with their + * Updates the {@link #getIndexInParent()} of the children with their * real position, starting at [startIndex]. */ private void updateChildrenIndices(int startIndex) { if (startIndex < 0) { startIndex = 0; } - for (int j = startIndex; j < jjtGetNumChildren(); j++) { + for (int j = startIndex; j < getNumChildren(); j++) { children[j].jjtSetChildIndex(j); // shift the children to the right children[j].jjtSetParent(this); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java index 8ef5b24134..7da30381fd 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AstImplUtil.java @@ -20,10 +20,10 @@ final class AstImplUtil { @Nullable public static T getChildAs(JavaNode javaNode, int idx, Class type) { - if (javaNode.jjtGetNumChildren() <= idx || idx < 0) { + if (javaNode.getNumChildren() <= idx || idx < 0) { return null; } - Node child = javaNode.jjtGetChild(idx); + Node child = javaNode.getChild(idx); return type.isInstance(child) ? type.cast(child) : null; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java index a4a234b99a..a51ac6697c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java @@ -40,13 +40,13 @@ final class InternalInterfaces { /** Returns the left-hand-side operand. */ default ASTExpression getLeftOperand() { - return (ASTExpression) jjtGetChild(0); + return (ASTExpression) getChild(0); } /** Returns the right-hand side operand. */ default ASTExpression getRightOperand() { - return (ASTExpression) jjtGetChild(1); + return (ASTExpression) getChild(1); } @@ -82,8 +82,8 @@ final class InternalInterfaces { @Override @NonNull default JavaNode getFirstChild() { - assert jjtGetNumChildren() > 0; - return jjtGetChild(0); + assert getNumChildren() > 0; + return getChild(0); } @@ -91,8 +91,8 @@ final class InternalInterfaces { @Override @NonNull default JavaNode getLastChild() { - assert jjtGetNumChildren() > 0; - return jjtGetChild(jjtGetNumChildren() - 1); + assert getNumChildren() > 0; + return getChild(getNumChildren() - 1); } } @@ -103,15 +103,15 @@ final class InternalInterfaces { interface AtLeastOneChildOfType extends JavaNode { @Override - T jjtGetChild(int index); + T getChild(int index); /** Returns the first child of this node, never null. */ @Override @NonNull default T getFirstChild() { - assert jjtGetNumChildren() > 0; - return jjtGetChild(0); + assert getNumChildren() > 0; + return getChild(0); } @@ -119,8 +119,8 @@ final class InternalInterfaces { @Override @NonNull default T getLastChild() { - assert jjtGetNumChildren() > 0; - return jjtGetChild(jjtGetNumChildren() - 1); + assert getNumChildren() > 0; + return getChild(getNumChildren() - 1); } } 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 f8ffc31587..a19f4591eb 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 @@ -8,7 +8,6 @@ package net.sourceforge.pmd.lang.java.ast; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.TextAvailableNode; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; 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 08dfaddeec..28aafac1ac 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 @@ -246,7 +246,7 @@ public class LanguageLevelChecker { @Override public void visit(ASTIntersectionType node, T data) { - if (node.jjtGetParent() instanceof ASTCastExpression) { + if (node.getParent() instanceof ASTCastExpression) { check(node, RegularLanguageFeature.INTERSECTION_TYPES_IN_CASTS, data); } visitChildren(node, data); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AnnotationSuppressionUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AnnotationSuppressionUtil.java index 8e109ece83..5316715051 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AnnotationSuppressionUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/AnnotationSuppressionUtil.java @@ -58,15 +58,15 @@ final class AnnotationSuppressionUtil { boolean result = suppresses(node, rule); if (!result && node instanceof ASTCompilationUnit) { - for (int i = 0; !result && i < node.jjtGetNumChildren(); i++) { - result = AnnotationSuppressionUtil.suppresses(node.jjtGetChild(i), rule); + for (int i = 0; !result && i < node.getNumChildren(); i++) { + result = AnnotationSuppressionUtil.suppresses(node.getChild(i), rule); } } if (!result) { - Node parent = node.jjtGetParent(); + Node parent = node.getParent(); while (!result && parent != null) { result = AnnotationSuppressionUtil.suppresses(parent, rule); - parent = parent.jjtGetParent(); + parent = parent.getParent(); } } return result; @@ -97,7 +97,7 @@ final class AnnotationSuppressionUtil { return (Annotatable) node; } else if (node instanceof ASTTypeDeclaration) { // this is just necessary while we have this node in the tree, it will be removed - return (Annotatable) node.jjtGetChild(0); + return (Annotatable) node.getChild(0); } else { return null; } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/VariableNameDeclaration.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/VariableNameDeclaration.java index 104b4ae2ec..e0600a6a09 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/VariableNameDeclaration.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/VariableNameDeclaration.java @@ -78,11 +78,11 @@ public class VariableNameDeclaration extends AbstractNameDeclaration implements public AccessNode getAccessNodeParent() { if (node.getParent() instanceof ASTFormalParameter) { - return (AccessNode) node.jjtGetParent(); - } else if (node.jjtGetParent() instanceof ASTLambdaParameter) { - return (AccessNode) node.jjtGetParent().jjtGetParent().jjtGetParent(); - } else if (node.jjtGetParent() instanceof ASTEnumConstant) { - return (AccessNode) node.jjtGetParent().jjtGetParent().jjtGetParent(); + return (AccessNode) node.getParent(); + } else if (node.getParent() instanceof ASTLambdaParameter) { + return (AccessNode) node.getParent().getParent().getParent(); + } else if (node.getParent() instanceof ASTEnumConstant) { + return (AccessNode) node.getParent().getParent().getParent(); } else if (node.getParent() instanceof ASTCatchParameter) { return (AccessNode) node.getParent(); } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java index ca6c478b76..e9f92df08f 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/ClassTypeResolver.java @@ -795,8 +795,8 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter { public Object visit(ASTPrimaryExpression primaryNode, Object data) { return data; // visit method arguments in reverse - // for (int i = primaryNode.jjtGetNumChildren() - 1; i >= 0; --i) { - // ((JavaNode) primaryNode.jjtGetChild(i)).jjtAccept(this, data); + // for (int i = primaryNode.getNumChildren() - 1; i >= 0; --i) { + // ((JavaNode) primaryNode.getChild(i)).jjtAccept(this, data); // } // // JavaTypeDefinition primaryNodeType = null; @@ -804,10 +804,10 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter { // AbstractJavaTypeNode nextChild; // Class accessingClass = getEnclosingTypeDeclarationClass(primaryNode); // - // for (int childIndex = 0; childIndex < primaryNode.jjtGetNumChildren(); ++childIndex) { - // AbstractJavaTypeNode currentChild = (AbstractJavaTypeNode) primaryNode.jjtGetChild(childIndex); - // nextChild = childIndex + 1 < primaryNode.jjtGetNumChildren() - // ? (AbstractJavaTypeNode) primaryNode.jjtGetChild(childIndex + 1) : null; + // for (int childIndex = 0; childIndex < primaryNode.getNumChildren(); ++childIndex) { + // AbstractJavaTypeNode currentChild = (AbstractJavaTypeNode) primaryNode.getChild(childIndex); + // nextChild = childIndex + 1 < primaryNode.getNumChildren() + // ? (AbstractJavaTypeNode) primaryNode.getChild(childIndex + 1) : null; // // // skip children which already have their type assigned // if (currentChild.getType() == null) { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/MethodTypeResolution.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/MethodTypeResolution.java index 8d5ebde466..0da1d4e665 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/MethodTypeResolution.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/typeresolution/MethodTypeResolution.java @@ -187,19 +187,19 @@ public final class MethodTypeResolution { private static boolean isStandAlonePrimitive(ASTExpression expression) { - if (expression.jjtGetNumChildren() != 1) { + if (expression.getNumChildren() != 1) { return false; } ASTPrimaryExpression primaryExpression = expression.getFirstChildOfType(ASTPrimaryExpression.class); - if (primaryExpression == null || primaryExpression.jjtGetNumChildren() != 1) { + if (primaryExpression == null || primaryExpression.getNumChildren() != 1) { return false; } ASTPrimaryPrefix primaryPrefix = primaryExpression.getFirstChildOfType(ASTPrimaryPrefix.class); - if (primaryPrefix == null || primaryPrefix.jjtGetNumChildren() != 1) { + if (primaryPrefix == null || primaryPrefix.getNumChildren() != 1) { return false; } @@ -208,7 +208,7 @@ public final class MethodTypeResolution { // if it is not a string literal and not a null, then it is one of // byte, short, char, int, long, float, double, boolean return literal != null && !literal.isStringLiteral() - && (literal.jjtGetNumChildren() == 0 || !(literal.jjtGetChild(0) instanceof ASTNullLiteral)); + && (literal.getNumChildren() == 0 || !(literal.getChild(0) instanceof ASTNullLiteral)); } public static MethodType parameterizeInvocation(JavaTypeDefinition context, Method method, diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt index 396630fa9c..ede2b65efe 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ASTFieldAccessTest.kt @@ -2,7 +2,6 @@ package net.sourceforge.pmd.lang.java.ast import io.kotlintest.shouldBe import io.kotlintest.shouldNotBe -import net.sourceforge.pmd.lang.ast.test.parent import net.sourceforge.pmd.lang.ast.test.shouldBe /** @@ -47,14 +46,14 @@ class ASTFieldAccessTest : ParserTestSpec({ it::getQualifier shouldBe child { it::getName shouldBe "a.b" // test the parent is set correctly - it::parent shouldBe fieldAccess + it::getParent shouldBe fieldAccess } } "a" should matchExpr { it::getVariableName shouldBe "a" - it::parent shouldNotBe null + it::getParent shouldNotBe null } } }) diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt index 4192a43a07..fd61ab8a9f 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/NodeParsingCtx.kt @@ -5,8 +5,6 @@ package net.sourceforge.pmd.lang.java.ast import net.sourceforge.pmd.lang.ast.Node -import net.sourceforge.pmd.lang.ast.test.getChild -import net.sourceforge.pmd.lang.ast.test.numChildren /** * Describes a kind of node that can be found commonly in the same contexts. @@ -95,7 +93,7 @@ object StatementParsingCtx : NodeParsingCtx("statement") { override fun retrieveNode(acu: ASTCompilationUnit): ASTStatement = EnclosedDeclarationParsingCtx.retrieveNode(acu) - .getFirstDescendantOfType(ASTBlock::class.java).jjtGetChild(0) + .getFirstDescendantOfType(ASTBlock::class.java).getChild(0) } object EnclosedDeclarationParsingCtx : NodeParsingCtx("enclosed declaration") { diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/AbstractPLSQLNode.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/AbstractPLSQLNode.java index 5d61e367a6..def82d1a5c 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/AbstractPLSQLNode.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/AbstractPLSQLNode.java @@ -7,8 +7,8 @@ package net.sourceforge.pmd.lang.plsql.ast; -import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode; import net.sourceforge.pmd.lang.symboltable.Scope; public abstract class AbstractPLSQLNode extends AbstractJjtreeNode implements PLSQLNode {