Class ASTMethodDeclaration
- java.lang.Object
-
- All Implemented Interfaces:
Node
,QualifiableNode
,SignedNode<ASTMethodOrConstructorDeclaration>
,DFAGraphMethod
,AccessNode
,Annotatable
,ASTMethodOrConstructorDeclaration
,JavaNode
,JavaQualifiableNode
,MethodLikeNode
,ScopedNode
public class ASTMethodDeclaration extends AbstractMethodOrConstructorDeclaration implements DFAGraphMethod
Method declaration node.MethodDeclaration := [ TypeParameters() ] (TypeAnnotation())* ResultType() MethodDeclarator() [ "throws" NameList() ] ( Block() | ";" )
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sourceforge.pmd.lang.java.ast.MethodLikeNode
MethodLikeNode.MethodLikeKind
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Constructor Description ASTMethodDeclaration(int id)
Deprecated.ASTMethodDeclaration(JavaParser p, int id)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ASTAnnotation
getAnnotation(String annotQualifiedName)
Get specific annotaion on this node.int
getArity()
Returns the number of formal parameters expected by this method (excluding any receiver parameter).ASTBlock
getBlock()
Deprecated.UsegetBody()
ASTBlock
getBody()
Returns the block defined by this method, or null if the method is abstract.List<ASTAnnotation>
getDeclaredAnnotations()
Get all annotations present on this node.ASTFormalParameters
getFormalParameters()
MethodLikeNode.MethodLikeKind
getKind()
Returns a token indicating whether this node is a lambda expression or a method or constructor declaration.ASTMethodDeclarator
getMethodDeclarator()
Deprecated.Method declarator nodes will be removed with 7.0.0String
getMethodName()
Deprecated.UsegetName()
String
getName()
Returns the simple name of the method.ASTResultType
getResultType()
Returns the result type node of the method.ASTNameList
getThrows()
Returns the exception names listed in thethrows
clause of this method declaration, or null if there are none.boolean
isAbstract()
Returns true if this method is abstract, so doesn't declare a body.boolean
isAnnotationPresent(String annotQualifiedName)
Checks whether the annotation is present on this node.boolean
isAnyAnnotationPresent(Collection<String> annotQualifiedNames)
Checks whether any annotation is present on this node.boolean
isInterfaceMember()
Returns true if this method declaration is a member of an interface type.boolean
isPublic()
Returns true if this method has public visibility.boolean
isSyntacticallyAbstract()
Returns true if this method is explicitly modified by theabstract
modifier.boolean
isSyntacticallyPublic()
Returns true if this method is explicitly modified by thepublic
modifier.boolean
isVoid()
Returns true if the result type of this method isvoid
.Object
jjtAccept(JavaParserVisitor visitor, Object data)
Calls back the visitor's visit method corresponding to the runtime type of this Node.-
Methods inherited from class net.sourceforge.pmd.lang.java.ast.AbstractMethodOrConstructorDeclaration
getSignature
-
Methods inherited from class net.sourceforge.pmd.lang.java.ast.AbstractMethodLikeNode
getQualifiedName, setQualifiedName
-
Methods inherited from class net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessNode
getModifiers, isDefault, isFinal, isNative, isPackagePrivate, isPrivate, isProtected, 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.AccessNode
getModifiers, isDefault, isFinal, isNative, isPackagePrivate, isPrivate, isProtected, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, setAbstract, setDefault, setFinal, setModifiers, setNative, setPrivate, setProtected, setPublic, setStatic, setStrictfp, setSynchronized, setTransient, setVolatile
-
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.java.ast.MethodLikeNode
getQualifiedName
-
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
-
ASTMethodDeclaration
@InternalApi @Deprecated public ASTMethodDeclaration(int id)
Deprecated.
-
ASTMethodDeclaration
@InternalApi @Deprecated public ASTMethodDeclaration(JavaParser p, int id)
Deprecated.
-
-
Method Detail
-
jjtAccept
public Object jjtAccept(JavaParserVisitor visitor, Object data)
Description copied from interface:JavaNode
Calls back the visitor's visit method corresponding to the runtime type of this Node.- Specified by:
jjtAccept
in interfaceJavaNode
- Overrides:
jjtAccept
in classAbstractJavaNode
- Parameters:
visitor
- Visitor to dispatchdata
- Visit data
-
getMethodName
@Deprecated @DeprecatedAttribute(replaceWith="@Name") public String getMethodName()
Deprecated.UsegetName()
Returns the simple name of the method.
-
getName
public String getName()
Returns the simple name of the method.- Specified by:
getName
in interfaceDFAGraphMethod
-
isSyntacticallyPublic
public boolean isSyntacticallyPublic()
Returns true if this method is explicitly modified by thepublic
modifier.
-
isSyntacticallyAbstract
public boolean isSyntacticallyAbstract()
Returns true if this method is explicitly modified by theabstract
modifier.
-
isPublic
public boolean isPublic()
Returns true if this method has public visibility. Non-private interface members are implicitly public, whether they declare thepublic
modifier or not.- Specified by:
isPublic
in interfaceAccessNode
- Overrides:
isPublic
in classAbstractJavaAccessNode
-
isAbstract
public boolean isAbstract()
Returns true if this method is abstract, so doesn't declare a body. Interface members are implicitly abstract, whether they declare theabstract
modifier or not. Default interface methods are not abstract though, consistently with the standard reflection API.- Specified by:
isAbstract
in interfaceAccessNode
- Overrides:
isAbstract
in classAbstractJavaAccessNode
-
isInterfaceMember
public boolean isInterfaceMember()
Returns true if this method declaration is a member of an interface type.
-
isVoid
public boolean isVoid()
Returns true if the result type of this method isvoid
.
-
getResultType
public ASTResultType getResultType()
Returns the result type node of the method.
-
getBlock
@Deprecated public ASTBlock getBlock()
Deprecated.UsegetBody()
Returns the block defined by this method, or null if the method is abstract.
-
getBody
public ASTBlock getBody()
Returns the block defined by this method, or null if the method is abstract.
-
getArity
public int getArity()
Returns the number of formal parameters expected by this method (excluding any receiver parameter). A varargs parameter counts as one.
-
getThrows
public ASTNameList getThrows()
Returns the exception names listed in thethrows
clause of this method declaration, or null if there are none.
-
getKind
public MethodLikeNode.MethodLikeKind getKind()
Description copied from interface:MethodLikeNode
Returns a token indicating whether this node is a lambda expression or a method or constructor declaration. Can be used to downcast safely to a subinterface or an implementing class.- Specified by:
getKind
in interfaceMethodLikeNode
- Returns:
- The kind of method-like
-
getFormalParameters
public ASTFormalParameters getFormalParameters()
-
getMethodDeclarator
@Deprecated public ASTMethodDeclarator getMethodDeclarator()
Deprecated.Method declarator nodes will be removed with 7.0.0Returns the method declarator. Never null.
-
getDeclaredAnnotations
public List<ASTAnnotation> getDeclaredAnnotations()
Description copied from interface:Annotatable
Get all annotations present on this node.- Specified by:
getDeclaredAnnotations
in interfaceAnnotatable
- Returns:
- all annotations present on this node.
-
getAnnotation
public ASTAnnotation getAnnotation(String annotQualifiedName)
Description copied from interface:Annotatable
Get specific annotaion on this node.- Specified by:
getAnnotation
in interfaceAnnotatable
- Parameters:
annotQualifiedName
- qulified name of the annotation.- Returns:
ASTAnnotaion
node if the annotation is present on this node, elsenull
-
isAnnotationPresent
public boolean isAnnotationPresent(String annotQualifiedName)
Description copied from interface:Annotatable
Checks whether the annotation is present on this node.- Specified by:
isAnnotationPresent
in interfaceAnnotatable
- Parameters:
annotQualifiedName
- qulified name of the annotation.- Returns:
true
if the annotation is present on this node, elsefalse
-
isAnyAnnotationPresent
public boolean isAnyAnnotationPresent(Collection<String> annotQualifiedNames)
Description copied from interface:Annotatable
Checks whether any annotation is present on this node.- Specified by:
isAnyAnnotationPresent
in interfaceAnnotatable
- Parameters:
annotQualifiedNames
- collection that cotains qulified name of annotations.- Returns:
true
if any annotation is present on this node, elsefalse
-
-