Package net.sourceforge.pmd.lang.java.ast
Contains the classes and interfaces modelling the Java AST.
Note: from 6.16.0 on, the following usages have been deprecated:
- Manual instantiation of nodes. Nodes should only be obtained from the parser, which for rules, means that never need to instantiate node themselves. Those constructors have been made package private with 7.0.0.
- Subclassing of base node classes, or usage of their type.
Version 7.0.0 will bring a new set of abstractions that will
be public API, but the base classes are and will stay internal.
You should not couple your code to them.
In the meantime you should use interfaces like
JavaNode
orNode
, or the other published interfaces in this package, to refer to nodes generically. - Setters found in any node class or interface. Rules should consider the AST immutable. Those setters have been made package private with 7.0.0.
-
Interface Summary Interface Description Annotatable Marks nodes that can be annotated.ASTAssignableExpr An expression that may be assigned by an assignment expression, or incremented or decremented.ASTAssignableExpr.ASTNamedReferenceExpr An assignable expression that has a name, and refers to a symbol.ASTBodyDeclaration Marker interface for declarations that can occur in a type body, such as field or method declarations.ASTExecutableDeclaration Groups method and constructor declarations under a common type.ASTExpression Represents an expression, in the most general sense.ASTLiteral A lexical literal.ASTLoopStatement A loop statement.ASTMemberValue Represents the value of a member of an annotation.ASTPattern A pattern for pattern matching constructs likeInstanceOfExpression
or within aASTSwitchLabel
).ASTPrimaryExpression Tags thoseexpressions
that are categorised as primary by the JLS.ASTReferenceType Represents a reference type, i.e.ASTStatement Represents a code statement.ASTSwitchArrowRHS A node that can appear as the right-hand-side of aSwitchArrowRule
.ASTSwitchBranch A branch of aSwitchLike
.ASTSwitchLike Common supertype for switch statements and switch expressions.ASTTopLevelDeclaration Marker interface for nodes that can appear on the top-level of a file.ASTType Represents a type reference.ASTTypeDeclaration Groups class, enum, record, annotation and interface declarations under a common supertype.FunctionalExpression A method reference or lambda expression.InvocationNode Groups method and constructor call, together, as well as explicit constructor invocation statements, and enum constant declarations.JavadocCommentOwner A node that may own a javadoc comment.JavaNode Root interface for all Nodes of the Java AST.JavaVisitor<P,R> MethodUsage A node that uses another method or constructor.ModifierOwner A node that owns a modifier list.QualifiableExpression Node that may be qualified by an expression, e.g.SymbolDeclaratorNode A node that declares a corresponding symbol.TypeNode A node that has a statically known type.TypeParamOwnerNode A symbol declaration, whose symbol can declare type parameters. -
Class Summary Class Description AbstractPackageNameModuleDirective ASTAmbiguousName An ambiguous name occurring in any context.ASTAnnotation Represents an annotation.ASTAnnotationMemberList Represents the list ofmember-value pairs
in anannotation
.ASTAnnotationTypeBody ASTAnnotationTypeDeclaration The declaration of an annotation type.ASTAnonymousClassDeclaration An anonymous class declaration.ASTArgumentList ASTArrayAccess An array access expression.ASTArrayAllocation An array creation expression.ASTArrayDimensions Represents array type dimensions.ASTArrayDimExpr Represents an array dimension initialized with an expression in an array allocation expression.ASTArrayInitializer An array initializer.ASTArrayType Represents an array type.ASTArrayTypeDim Represents an array dimension in an array type, or in an array allocation expression.ASTAssertStatement Represents anassert
statement.ASTAssignmentExpression Represents an assignment expression.ASTBlock A block of code.ASTBooleanLiteral The boolean literal, either "true" or "false".ASTBreakStatement A break statement, that jumps to a named label (or exits the current loop).ASTCastExpression Represents a type cast expression.ASTCatchClause A "catch" clause of a try statement.ASTCatchParameter Formal parameter of a catch clause to represent the declared exception variable.ASTCharLiteral Represents a character literal.ASTClassBody Represents the body of a class or interface declaration.ASTClassDeclaration Represents class and interface declarations.ASTClassLiteral A class literal.ASTClassType Represents a class or interface type, possibly parameterised with type arguments.ASTCompactConstructorDeclaration This defines a compact constructor for a RecordDeclaration (JDK 16 feature).ASTCompilationUnit The root node of all Java ASTs.ASTConditionalExpression Represents a conditional expression, aka ternary expression.ASTConstructorCall A class instance creation expression.ASTConstructorDeclaration ASTContinueStatement A continue statement, that jumps to the next iteration of an enclosing loop.ASTDefaultValue Represents thedefault
clause of an annotation method.ASTDoStatement Represents ado ... while
statement.ASTEmptyDeclaration An empty declaration (useless).ASTEmptyStatement An empty statement (useless).ASTEnumBody Body of an enum declaration.ASTEnumConstant Represents an enum constant declaration within an enum type declaration.ASTEnumDeclaration Represents an enum declaration.ASTExplicitConstructorInvocation An explicit constructor invocation, occurring at the start of a constructor declaration.ASTExpressionStatement A statement that contains an expression.ASTExtendsList Represents theextends
clause of a class or interface declaration.ASTFieldAccess A field access expression.ASTFieldDeclaration Represents a field declaration in the body of a type declaration.ASTFinallyClause The "finally" clause of a try statement.ASTForeachStatement Represents a "foreach"-loop on anIterable
.ASTForInit The initialization clause of a for loop.ASTFormalParameter Formal parameter node for a formal parameter list.ASTFormalParameters A list of formal parameters in a method or constructor declaration.ASTForStatement Represents afor
loop (distinct from foreach loops).ASTForUpdate Update clause of a for statement.ASTGuard A guard for refining a switch case inASTSwitchLabel
s.ASTIfStatement Represents anif
statement, possibly with anelse
statement.ASTImplementsList Represents theimplements
clause of a class declaration.ASTImportDeclaration Represents an import declaration in a Java file.ASTInfixExpression Represents a binary infix expression.ASTInitializer A class or instance initializer.ASTIntersectionType Represents an intersection type.ASTLabeledStatement A wrapper around a statement that assigns it a label.ASTLambdaExpression A lambda expression.ASTLambdaParameter Formal parameter of a lambda expression.ASTLambdaParameterList The parameter list of a lambda expression.ASTList<N extends JavaNode> Common supertype for nodes that act as a kind of list of other nodes.ASTLocalClassStatement A statement that contains a local class declaration.ASTLocalVariableDeclaration Represents a local variable declaration.ASTMemberValueArrayInitializer Represents an array of member values in an annotation member value.ASTMemberValuePair Represents a single pair of member name to value in an annotation.ASTMethodCall A method invocation expression.ASTMethodDeclaration A method declaration, in a class or interface declaration.ASTMethodReference Method or constructor reference expression.ASTModifierList List of modifiers of a declaration.ASTModuleDeclaration A module declaration.ASTModuleDirective A directive of a module declaration.ASTModuleExportsDirective An "exports" directive of a module declaration.ASTModuleName The name of a module.ASTModuleOpensDirective An "opens" directive of a module declaration.ASTModuleProvidesDirective A "provides" directive of a module declaration.ASTModuleRequiresDirective A "requires" directive of a module declaration.ASTModuleUsesDirective A "uses" directive of a module declaration.ASTNullLiteral The null literal.ASTNumericLiteral A numeric literal of any type (double, int, long, float, etc).ASTPackageDeclaration Package declaration at the top of a source file.ASTPatternExpression Wraps aASTPattern
node but presents the interface ofASTExpression
.ASTPatternList Contains a potentially empty list of nested Patterns for RecordPattern (Java 21).ASTPermitsList Represents thepermits
clause of a (sealed) class declaration.ASTPrimitiveType Represents a primitive type.ASTReceiverParameter Receiver parameter.ASTRecordBody Defines the body of a RecordDeclaration (JDK 16 feature).ASTRecordComponent Defines a single component of a RecordDeclaration (JDK 16 feature).ASTRecordComponentList Defines the state description of a RecordDeclaration (JDK 16 feature).ASTRecordDeclaration A record declaration is a special data class type (JDK 16 feature).ASTRecordPattern A record pattern, a Java 21 language feature.ASTResource A resource of a try-with-resources.ASTResourceList A list of resources in a try-with-resources.ASTReturnStatement A return statement in a method or constructor body.ASTStatementExpressionList A list of statement expressions.ASTStringLiteral Represents a string literal.ASTSuperExpression The "super" keyword.ASTSwitchArrowBranch A non-fallthrough switch rule, introduced with switch expressions.ASTSwitchExpression A switch expression, as introduced in Java 12.ASTSwitchFallthroughBranch A fallthrough switch branch.ASTSwitchLabel ASTSwitchStatement Represents aswitch
statement.ASTSynchronizedStatement A synchronized statement.ASTTemplate The template of aASTTemplateExpression
.ASTTemplateExpression A string template expression.ASTTemplateFragment This is a Java 21/22 Preview feature.ASTThisExpression The "this" expression.ASTThrowsList Throws clause of anASTConstructorDeclaration
orASTMethodDeclaration
.ASTThrowStatement Athrow
statement.ASTTryStatement Try statement node.ASTTypeArguments Represents a list of type arguments.ASTTypeBody Body of a type declaration.ASTTypeExpression Wraps a type node but presents the interface ofASTExpression
.ASTTypeParameter Represents a type parameter declaration of a method, constructor, class or interface declaration.ASTTypeParameters Represents a list of type parameters.ASTTypePattern A type pattern (JDK16).ASTUnaryExpression Represents a unary operation on a value.ASTUnionType Represents the type node of a multi-catch statement.ASTUnnamedPattern An unnamed pattern, a Java 22 language feature.ASTVariableAccess An unqualified reference to a variable (either local, or a field that is in scope).ASTVariableDeclarator Groups a variable ID and its initializer if it exists.ASTVariableId Represents an identifier in the context of variable or parameter declarations (not their use in expressions).ASTVoidType Type node to represent the void pseudo-type.ASTWhileStatement Represents awhile
loop.ASTWildcardType Represents a wildcard type.ASTYieldStatement Ayield
statement in a switch expression.InternalApiBridge Internal API.JavaComment Wraps a comment token to provide some utilities.JavadocComment AJavaComment
that has Javadoc content.JavaParser Adapter for the JavaParser, using the specified grammar version.JavaTokenKinds Token kinds (JavaccToken.kind
) for this language.JavaVisitorBase<P,R> Base implementation ofJavaVisitor
.SyntacticJavaTokenizerFactory Deprecated. This implementation has been superseded. -
Enum Summary Enum Description AssignmentOp An assignment operator forASTAssignmentExpression
.ASTAssignableExpr.AccessType Represents the type of access of an assignable expression.BinaryOp Represents the operator of an infix expression.JModifier A Java modifier.ModifierOwner.Visibility Represents the visibility of a declaration.UnaryOp A unary operator, either prefix or postfix.