Class ASTFormalParameter
- java.lang.Object
-
- net.sourceforge.pmd.lang.ast.AbstractNode
-
- net.sourceforge.pmd.lang.java.ast.AbstractJavaNode
-
- net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessNode
-
- net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessTypeNode
-
- net.sourceforge.pmd.lang.java.ast.ASTFormalParameter
-
- All Implemented Interfaces:
net.sourceforge.pmd.lang.ast.Node,AccessNode,Annotatable,CanSuppressWarnings,Dimensionable,JavaNode,TypeNode,net.sourceforge.pmd.lang.symboltable.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
-
-
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(java.lang.String annotQualifiedName)Get specific annotaion on this node.intgetArrayDepth()Deprecated.protected ASTVariableDeclaratorIdgetDecl()Deprecated.java.util.List<ASTAnnotation>getDeclaredAnnotations()Get all annotations present on this node.java.lang.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(net.sourceforge.pmd.Rule rule)booleanisAnnotationPresent(java.lang.String annotQualifiedName)Checks whether the annotation is present on this node.booleanisAnyAnnotationPresent(java.util.Collection<java.lang.String> annotQualifiedNames)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 explit types.booleanisVarargs()Returns true if this node is a varargs parameter.java.lang.ObjectjjtAccept(JavaParserVisitor visitor, java.lang.Object data)Calls back the visitor's visit method corresponding to the runtime type of this Node.voidsetType(java.lang.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, getScope, getXPathNodeName, jjtClose, jjtOpen, setScope
-
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, getNthParent, getParentsOfType, getUserData, 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
childrenAccept, setScope
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, getAsDocument, getBeginColumn, getBeginLine, getDataFlowNode, getEndColumn, getEndLine, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfAnyType, getFirstParentOfType, getImage, getNthParent, getParentsOfType, getUserData, getXPathAttributesIterator, getXPathNodeName, hasDescendantMatchingXPath, hasDescendantOfType, hasImageEqualTo, isFindBoundary, jjtAddChild, jjtClose, jjtGetChild, jjtGetChildIndex, jjtGetId, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetChildIndex, jjtSetParent, remove, removeChildAtIndex, setDataFlowNode, setImage, setUserData
-
-
-
-
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 explit types. This can appear as part of a lambda expression with java11 using "var".- See Also:
ASTVariableDeclaratorId.isTypeInferred()
-
jjtAccept
public java.lang.Object jjtAccept(JavaParserVisitor visitor, java.lang.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(net.sourceforge.pmd.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 java.lang.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(java.lang.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 java.util.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(java.lang.String annotQualifiedName)
Description copied from interface:AnnotatableGet specific annotaion on this node.- Specified by:
getAnnotationin interfaceAnnotatable- Parameters:
annotQualifiedName- qulified name of the annotation.- Returns:
ASTAnnotaionnode if the annotation is present on this node, elsenull
-
isAnnotationPresent
public boolean isAnnotationPresent(java.lang.String annotQualifiedName)
Description copied from interface:AnnotatableChecks whether the annotation is present on this node.- Specified by:
isAnnotationPresentin interfaceAnnotatable- Parameters:
annotQualifiedName- qulified name of the annotation.- Returns:
trueif the annotation is present on this node, elsefalse
-
isAnyAnnotationPresent
public boolean isAnyAnnotationPresent(java.util.Collection<java.lang.String> annotQualifiedNames)
Description copied from interface:AnnotatableChecks whether any annotation is present on this node.- Specified by:
isAnyAnnotationPresentin interfaceAnnotatable- Parameters:
annotQualifiedNames- collection that cotains qulified name of annotations.- Returns:
trueif any annotation is present on this node, elsefalse
-
-