Fix final catch param

This commit is contained in:
Clément Fournier
2019-10-03 14:25:01 +02:00
parent 56ed5823cf
commit ee1e9bf286
2 changed files with 7 additions and 15 deletions

View File

@ -2989,6 +2989,7 @@ void CatchParameter() :
{boolean isFinal = false;} {boolean isFinal = false;}
{ {
isFinal=LocalVarModifierList() UnionType() VariableDeclaratorId() isFinal=LocalVarModifierList() UnionType() VariableDeclaratorId()
{jjtThis.setFinal(isFinal);}
} }
// Special type for catch formal parameters // Special type for catch formal parameters

View File

@ -4,16 +4,11 @@
package net.sourceforge.pmd.lang.java.ast; package net.sourceforge.pmd.lang.java.ast;
import net.sourceforge.pmd.annotation.InternalApi;
/** /**
* Formal parameter of a {@linkplain ASTCatchStatement catch statement}. * Formal parameter of a {@linkplain ASTCatchStatement catch statement}.
* The type node may be a {@link ASTUnionType union type}, which represents * The type node may be a {@link ASTUnionType union type}, which represents
* multi-catch clauses. * multi-catch clauses.
* *
* TODO warning suppression
*
* <pre class="grammar"> * <pre class="grammar">
* *
* CatchParameter ::= ( "final" | {@link ASTAnnotation Annotation} )* {@link ASTType Type} {@link ASTVariableDeclaratorId VariableDeclaratorId} * CatchParameter ::= ( "final" | {@link ASTAnnotation Annotation} )* {@link ASTType Type} {@link ASTVariableDeclaratorId VariableDeclaratorId}
@ -24,9 +19,7 @@ public class ASTCatchParameter extends AbstractJavaTypeNode implements Annotatab
private boolean isFinal; private boolean isFinal;
@InternalApi ASTCatchParameter(int id) {
@Deprecated
public ASTCatchParameter(int id) {
super(id); super(id);
} }
@ -43,10 +36,6 @@ public class ASTCatchParameter extends AbstractJavaTypeNode implements Annotatab
isFinal = f; isFinal = f;
} }
public String getName() {
return getVariableId().getVariableName();
}
@Override @Override
public Object jjtAccept(JavaParserVisitor visitor, Object data) { public Object jjtAccept(JavaParserVisitor visitor, Object data) {
return visitor.visit(this, data); return visitor.visit(this, data);
@ -58,10 +47,12 @@ public class ASTCatchParameter extends AbstractJavaTypeNode implements Annotatab
visitor.visit(this, data); visitor.visit(this, data);
} }
/** Returns the name of the variable. */
public String getName() {
return getVariableId().getVariableName();
}
/** /** Returns the declarator ID of this catch parameter. */
* Returns the declarator ID of this catch parameter.
*/
public ASTVariableDeclaratorId getVariableId() { public ASTVariableDeclaratorId getVariableId() {
return (ASTVariableDeclaratorId) getLastChild(); return (ASTVariableDeclaratorId) getLastChild();
} }