Interface AccessNode
-
- All Superinterfaces:
Annotatable
,GenericNode<JavaNode>
,JavaNode
,JjtreeNode<JavaNode>
,Node
,Reportable
,TextAvailableNode
- All Known Subinterfaces:
ASTAnyTypeDeclaration
,ASTMethodOrConstructorDeclaration
,FinalizableNode
- All Known Implementing Classes:
ASTAnnotationTypeDeclaration
,ASTAnonymousClassDeclaration
,ASTCatchParameter
,ASTClassOrInterfaceDeclaration
,ASTCompactConstructorDeclaration
,ASTConstructorDeclaration
,ASTEnumConstant
,ASTEnumDeclaration
,ASTFieldDeclaration
,ASTFormalParameter
,ASTLambdaParameter
,ASTLocalVariableDeclaration
,ASTMethodDeclaration
,ASTRecordComponent
,ASTRecordDeclaration
,ASTTypePattern
,ASTVariableDeclaratorId
public interface AccessNode extends Annotatable
A node that owns a modifier list.AccessNode
methods take into account the syntactic context of the declaration, e.g.isPublic()
will always return true for a field declared inside an interface, regardless of whether thepublic
modifier was specified explicitly or not. If you want to know whether the modifier was explicitly stated, usehasExplicitModifiers(JModifier, JModifier...)
. TODO make modifiers accessible from XPath * Ideally we'd have two attributes, eg @EffectiveModifiers and @ExplicitModifiers, which would each return a sequence, eg ("public", "static", "final") * Ideally we'd have a way to add attributes that are not necessarily getters on the node. It makes no sense in the Java API to expose those getters on the node, it's more orthogonal to query getModifiers() directly. TODO rename to ModifierOwner, kept out from PR to reduce diff
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AccessNode.Visibility
Represents the visibility of a declaration.
-
Field Summary
-
Fields inherited from interface net.sourceforge.pmd.lang.ast.Node
COORDS_COMPARATOR
-
-
Method Summary
All Methods Instance Methods Default Methods Deprecated Methods Modifier and Type Method Description default NodeStream<ASTAnnotation>
getDeclaredAnnotations()
Returns all annotations present on this node.default AccessNode.Visibility
getEffectiveVisibility()
Returns the "effective" visibility of a member.default @NonNull ASTModifierList
getModifiers()
Returns the node representing the modifier list of this node.default AccessNode.Visibility
getVisibility()
Returns the visibility corresponding to theeffective modifiers
.default boolean
hasExplicitModifiers(JModifier mod1, JModifier... mod)
Returns true if this node has all the given modifiers explicitly written in the source.default boolean
hasModifiers(JModifier mod1, JModifier... mod)
Returns true if this node has all the given modifiers either explicitly written or inferred through context.default boolean
isAbstract()
Deprecated.default boolean
isFinal()
Deprecated.default boolean
isNative()
Deprecated.default boolean
isPackagePrivate()
Deprecated.default boolean
isPrivate()
Deprecated.default boolean
isProtected()
Deprecated.default boolean
isPublic()
Deprecated.default boolean
isStatic()
Deprecated.default boolean
isStrictfp()
Deprecated.default boolean
isSynchronized()
Deprecated.default boolean
isSyntacticallyAbstract()
Deprecated.default boolean
isSyntacticallyFinal()
Deprecated.default boolean
isSyntacticallyPublic()
Deprecated.default boolean
isSyntacticallyStatic()
Deprecated.default boolean
isTransient()
Deprecated.default boolean
isVolatile()
Deprecated.-
Methods inherited from interface net.sourceforge.pmd.lang.java.ast.Annotatable
getAnnotation, isAnnotationPresent, isAnnotationPresent, isAnyAnnotationPresent
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.GenericNode
ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getNthParent, getParent, getPreviousSibling
-
Methods inherited from interface net.sourceforge.pmd.lang.java.ast.JavaNode
getEnclosingType, getRoot, getSymbolTable, getTypeSystem, jjtAccept
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode
getFirstToken, getLastToken, tokens
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
acceptVisitor, ancestors, children, compareLocation, descendants, findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, firstChild, getAstInfo, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfType, getImage, getIndexInParent, getLanguageVersion, getNumChildren, getParentsOfType, getReportLocation, getTextDocument, getUserMap, getXPathAttributesIterator, getXPathNodeName, hasDescendantOfType, hasImageEqualTo, isFindBoundary
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.TextAvailableNode
getOriginalText, getText, getTextRegion
-
-
-
-
Method Detail
-
getDeclaredAnnotations
default NodeStream<ASTAnnotation> getDeclaredAnnotations()
Description copied from interface:Annotatable
Returns all annotations present on this node.- Specified by:
getDeclaredAnnotations
in interfaceAnnotatable
-
getModifiers
default @NonNull ASTModifierList getModifiers()
Returns the node representing the modifier list of this node.
-
getVisibility
default AccessNode.Visibility getVisibility()
Returns the visibility corresponding to theeffective modifiers
. Eg a public method will have visibilitypublic
, a local class will have visibilitylocal
. There cannot be any conflict withhasModifiers(JModifier, JModifier...)
} on well-formed code (e.g. for anyn
,(n.getVisibility() == V_PROTECTED) == n.hasModifiers(PROTECTED)
)TODO a public method of a private class can be considered to be private we could probably add another method later on that takes this into account
-
getEffectiveVisibility
default AccessNode.Visibility getEffectiveVisibility()
Returns the "effective" visibility of a member. This is the minimum visibility of its enclosing type declarations. For example, a public method of a private class is "effectively private".Local declarations keep local visibility, eg a local variable somewhere in an anonymous class doesn't get anonymous visibility.
-
hasModifiers
default boolean hasModifiers(JModifier mod1, JModifier... mod)
Returns true if this node has all the given modifiers either explicitly written or inferred through context.
-
hasExplicitModifiers
default boolean hasExplicitModifiers(JModifier mod1, JModifier... mod)
Returns true if this node has all the given modifiers explicitly written in the source.
-
isFinal
@Deprecated default boolean isFinal()
Deprecated.
-
isAbstract
@Deprecated default boolean isAbstract()
Deprecated.
-
isStrictfp
@Deprecated default boolean isStrictfp()
Deprecated.
-
isSynchronized
@Deprecated default boolean isSynchronized()
Deprecated.
-
isNative
@Deprecated default boolean isNative()
Deprecated.
-
isStatic
@Deprecated default boolean isStatic()
Deprecated.
-
isVolatile
@Deprecated default boolean isVolatile()
Deprecated.
-
isTransient
@Deprecated default boolean isTransient()
Deprecated.
-
isPrivate
@Deprecated default boolean isPrivate()
Deprecated.
-
isPublic
@Deprecated default boolean isPublic()
Deprecated.
-
isProtected
@Deprecated default boolean isProtected()
Deprecated.
-
isPackagePrivate
@Deprecated default boolean isPackagePrivate()
Deprecated.
-
isSyntacticallyAbstract
@Deprecated default boolean isSyntacticallyAbstract()
Deprecated.
-
isSyntacticallyPublic
@Deprecated default boolean isSyntacticallyPublic()
Deprecated.
-
isSyntacticallyStatic
@Deprecated default boolean isSyntacticallyStatic()
Deprecated.
-
isSyntacticallyFinal
@Deprecated default boolean isSyntacticallyFinal()
Deprecated.
-
-