Class ASTFormalParameter
-
- All Implemented Interfaces:
Node,AccessNode,Annotatable,CanSuppressWarnings,Dimensionable,JavaNode,TypeNode,ScopedNode
- Direct Known Subclasses:
ASTResource
public class ASTFormalParameter extends AbstractJavaAccessTypeNode implements Dimensionable, CanSuppressWarnings
Formal parameter node. Used in theASTFormalParametersproduction ofASTMethodDeclaratorto represent a method's formal parameter. Also used in theASTCatchStatementproduction to represent the declared exception variable. Also used in LambdaExpressions for the LambdaParameters.( "final" | Annotation )* Type ( "|" Type )* [ "..." ] VariableDeclaratorId
-
-
Field Summary
-
Fields inherited from class net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessTypeNode
typeDefinition
-
Fields inherited from class net.sourceforge.pmd.lang.java.ast.AbstractJavaNode
parser
-
Fields inherited from class net.sourceforge.pmd.lang.ast.AbstractNode
beginColumn, beginLine, childIndex, children, endColumn, endLine, firstToken, id, lastToken, parent
-
Fields inherited from interface net.sourceforge.pmd.lang.java.ast.AccessNode
ABSTRACT, DEFAULT, FINAL, NATIVE, NON_SEALED, PRIVATE, PROTECTED, PUBLIC, SEALED, STATIC, STRICTFP, SYNCHRONIZED, TRANSIENT, VOLATILE
-
-
Constructor Summary
Constructors Constructor Description ASTFormalParameter(int id)Deprecated.ASTFormalParameter(JavaParser p, int id)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ASTAnnotationgetAnnotation(String binaryName)Returns a specific annotation on this node, or null if absent.intgetArrayDepth()Deprecated.protected ASTVariableDeclaratorIdgetDecl()Deprecated.List<ASTAnnotation>getDeclaredAnnotations()Get all annotations present on this node.Class<?>getType()Returns the type of this formal parameter.JavaTypeDefinitiongetTypeDefinition()Get the TypeDefinition associated with this node.ASTTypegetTypeNode()Returns the type node of this formal parameter.ASTVariableDeclaratorIdgetVariableDeclaratorId()Returns the declarator ID of this formal parameter.booleanhasSuppressWarningsAnnotationFor(Rule rule)booleanisAnnotationPresent(String binaryName)Checks whether the annotation is present on this node.booleanisAnyAnnotationPresent(Collection<String> binaryNames)Checks whether any annotation is present on this node.booleanisArray()Deprecated.booleanisExplicitReceiverParameter()Returns true if this node is the explicit receiver parameter, e.g.booleanisTypeInferred()If true, this formal parameter represents one without explicit types.booleanisVarargs()Returns true if this node is a varargs parameter.ObjectjjtAccept(JavaParserVisitor visitor, Object data)Calls back the visitor's visit method corresponding to the runtime type of this Node.voidsetType(Class<?> type)Deprecated.voidsetTypeDefinition(JavaTypeDefinition type)Deprecated.voidsetVarargs()Deprecated.Will be made private in 7.0.0-
Methods inherited from class net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessNode
getModifiers, isAbstract, isDefault, isFinal, isNative, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, setAbstract, setDefault, setFinal, setModifiers, setNative, setPrivate, setProtected, setPublic, setStatic, setStrictfp, setSynchronized, setTransient, setVolatile
-
Methods inherited from class net.sourceforge.pmd.lang.java.ast.AbstractJavaNode
childrenAccept, comment, comment, getRoot, getScope, getXPathNodeName, jjtClose, jjtOpen, setScope
-
Methods inherited from class net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode
children, getChild, getParent
-
Methods inherited from class net.sourceforge.pmd.lang.ast.AbstractNode
appendElement, findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, findDescendantsOfType, getAsDocument, getBeginColumn, getBeginLine, getDataFlowNode, getEndColumn, getEndLine, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfAnyType, getFirstParentOfType, getImage, getIndexInParent, getNthParent, getNumChildren, getParentsOfType, getUserData, getUserMap, getXPathAttributesIterator, hasDecendantOfAnyType, hasDescendantMatchingXPath, hasDescendantOfAnyType, hasDescendantOfType, hasImageEqualTo, isFindBoundary, isSingleLine, jjtAddChild, jjtGetChild, jjtGetChildIndex, jjtGetFirstToken, jjtGetId, jjtGetLastToken, jjtGetNumChildren, jjtGetParent, jjtSetChildIndex, jjtSetFirstToken, jjtSetLastToken, jjtSetParent, remove, removeChildAtIndex, setDataFlowNode, setImage, setUserData, testingOnlySetBeginColumn, testingOnlySetBeginLine, testingOnlySetEndColumn, testingOnlySetEndLine, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.lang.java.ast.JavaNode
children, childrenAccept, getChild, getParent, getRoot, setScope
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, findDescendantsOfType, getAsDocument, getBeginColumn, getBeginLine, getDataFlowNode, getEndColumn, getEndLine, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfAnyType, getFirstParentOfType, getImage, getIndexInParent, getNthParent, getNumChildren, getParentsOfType, getUserData, getUserMap, getXPathAttributesIterator, getXPathNodeName, hasDescendantMatchingXPath, hasDescendantOfType, hasImageEqualTo, isFindBoundary, jjtAddChild, jjtClose, jjtGetChild, jjtGetChildIndex, jjtGetId, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetChildIndex, jjtSetParent, remove, removeChildAtIndex, setDataFlowNode, setImage, setUserData
-
Methods inherited from interface net.sourceforge.pmd.lang.symboltable.ScopedNode
getScope
-
-
-
-
Constructor Detail
-
ASTFormalParameter
@InternalApi @Deprecated public ASTFormalParameter(int id)
Deprecated.
-
ASTFormalParameter
@InternalApi @Deprecated public ASTFormalParameter(JavaParser p, int id)
Deprecated.
-
-
Method Detail
-
setVarargs
@InternalApi @Deprecated public void setVarargs()
Deprecated.Will be made private in 7.0.0
-
isVarargs
public boolean isVarargs()
Returns true if this node is a varargs parameter.
-
isExplicitReceiverParameter
public boolean isExplicitReceiverParameter()
Returns true if this node is the explicit receiver parameter, e.g. inclass Foo { abstract void foo(@Bar Foo this); }
-
isTypeInferred
public boolean isTypeInferred()
If true, this formal parameter represents one without explicit types. This can appear as part of a lambda expression with java11 using "var".- See Also:
ASTVariableDeclaratorId.isTypeInferred()
-
jjtAccept
public Object jjtAccept(JavaParserVisitor visitor, Object data)
Description copied from interface:JavaNodeCalls back the visitor's visit method corresponding to the runtime type of this Node.- Specified by:
jjtAcceptin interfaceJavaNode- Overrides:
jjtAcceptin classAbstractJavaNode- Parameters:
visitor- Visitor to dispatchdata- Visit data
-
getVariableDeclaratorId
public ASTVariableDeclaratorId getVariableDeclaratorId()
Returns the declarator ID of this formal parameter.
-
hasSuppressWarningsAnnotationFor
public boolean hasSuppressWarningsAnnotationFor(Rule rule)
- Specified by:
hasSuppressWarningsAnnotationForin interfaceCanSuppressWarnings
-
isArray
@Deprecated public boolean isArray()
Deprecated.Returns true if this formal parameter is of an array type. This includes varargs parameters.- Specified by:
isArrayin interfaceDimensionable
-
getArrayDepth
@Deprecated public int getArrayDepth()
Deprecated.- Specified by:
getArrayDepthin interfaceDimensionable
-
getTypeNode
public ASTType getTypeNode()
Returns the type node of this formal parameter. The type of that node is not necessarily the type of the parameter itself, seeASTVariableDeclaratorId.getType().In particular, the type of the returned node doesn't take into account whether this formal parameter is varargs or not.
-
getDecl
@Deprecated protected ASTVariableDeclaratorId getDecl()
Deprecated.
-
getType
public Class<?> getType()
Returns the type of this formal parameter. That type is exactly that of the variable declarator id, which means that the declarator id's type takes into account whether this parameter is varargs or not.- Specified by:
getTypein interfaceTypeNode- Overrides:
getTypein classAbstractJavaAccessTypeNode- Returns:
- The Java Class, may return
null.
-
getTypeDefinition
public JavaTypeDefinition getTypeDefinition()
Description copied from interface:TypeNodeGet the TypeDefinition associated with this node. The Class object contained in the TypeDefinition will always be equal to that which is returned bygetType().- Specified by:
getTypeDefinitionin interfaceTypeNode- Overrides:
getTypeDefinitionin classAbstractJavaAccessTypeNode- Returns:
- The TypeDefinition, may return
null
-
setTypeDefinition
@InternalApi @Deprecated public void setTypeDefinition(JavaTypeDefinition type)
Deprecated.Noop, the type of this node is defined by the type of the declarator id.- Specified by:
setTypeDefinitionin interfaceTypeNode- Overrides:
setTypeDefinitionin classAbstractJavaAccessTypeNode- Parameters:
type- A TypeDefinition object
-
setType
@InternalApi @Deprecated public void setType(Class<?> type)
Deprecated.Noop, the type of this node is defined by the type of the declarator id.- Specified by:
setTypein interfaceTypeNode- Overrides:
setTypein classAbstractJavaAccessTypeNode- Parameters:
type- A Java Class
-
getDeclaredAnnotations
public List<ASTAnnotation> getDeclaredAnnotations()
Description copied from interface:AnnotatableGet all annotations present on this node.- Specified by:
getDeclaredAnnotationsin interfaceAnnotatable- Returns:
- all annotations present on this node.
-
getAnnotation
public ASTAnnotation getAnnotation(String binaryName)
Description copied from interface:AnnotatableReturns a specific annotation on this node, or null if absent.- Specified by:
getAnnotationin interfaceAnnotatable- Parameters:
binaryName- Binary name of the annotation type. Note: for now, canonical names are tolerated, this may be changed in PMD 7.
-
isAnnotationPresent
public boolean isAnnotationPresent(String binaryName)
Description copied from interface:AnnotatableChecks whether the annotation is present on this node.- Specified by:
isAnnotationPresentin interfaceAnnotatable- Parameters:
binaryName- Binary name of the annotation type. Note: for now, canonical names are tolerated, this may be changed in PMD 7.- Returns:
trueif the annotation is present on this node, elsefalse
-
isAnyAnnotationPresent
public boolean isAnyAnnotationPresent(Collection<String> binaryNames)
Description copied from interface:AnnotatableChecks whether any annotation is present on this node.- Specified by:
isAnyAnnotationPresentin interfaceAnnotatable- Parameters:
binaryNames- Collection that contains binary names of annotations. Note: for now, canonical names are tolerated, this may be changed in PMD 7.- Returns:
trueif any annotation is present on this node, elsefalse
-
-