Package net.sourceforge.pmd.lang.java.ast
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.
-
ClassDescriptionMarks nodes that can be annotated.An assignment operator for
ASTAssignmentExpression
.An ambiguous name occurring in any context.Represents an annotation.Represents the list ofmember-value pairs
in anannotation
.The declaration of an annotation type.An anonymous class declaration.An array access expression.An array creation expression.Represents array type dimensions.Represents an array dimension initialized with an expression in an array allocation expression.An array initializer.Represents an array type.Represents an array dimension in an array type, or in an array allocation expression.Represents anassert
statement.An expression that may be assigned by an assignment expression, or incremented or decremented.Represents the type of access of an assignable expression.An assignable expression that has a name, and refers to a symbol.Represents an assignment expression.A block of code.Marker interface for declarations that can occur in a type body, such as field or method declarations.The boolean literal, either "true" or "false".A break statement, that jumps to a named label (or exits the current loop).Represents a type cast expression.A "catch" clause of a try statement.Formal parameter of a catch clause to represent the declared exception variable.Represents a character literal.Represents the body of a class or interface declaration.Represents class and interface declarations.A class literal.Represents a class or interface type, possibly parameterised with type arguments.This defines a compact constructor for a RecordDeclaration (JDK 16 feature).The root node of all Java ASTs.Represents a conditional expression, aka ternary expression.A class instance creation expression.A continue statement, that jumps to the next iteration of an enclosing loop.Represents thedefault
clause of an annotation method.Represents ado ... while
statement.An empty declaration (useless).An empty statement (useless).Body of an enum declaration.Represents an enum constant declaration within an enum type declaration.Represents an enum declaration.Groups method and constructor declarations under a common type.An explicit constructor invocation, occurring at the start of a constructor declaration.Represents an expression, in the most general sense.Result of constant folding an expression.A statement that contains an expression.Represents theextends
clause of a class or interface declaration.A field access expression.Represents a field declaration in the body of a type declaration.The "finally" clause of a try statement.Represents a "foreach"-loop on anIterable
.The initialization clause of a for loop.Formal parameter node for a formal parameter list.A list of formal parameters in a method or constructor declaration.Represents afor
loop (distinct from foreach loops).Update clause of a for statement.A guard for refining a switch case inASTSwitchLabel
s.Represents anif
statement, possibly with anelse
statement.Represents theimplements
clause of a class declaration.ImplicitClassDeclaration ::= ClassBody ClassBody ::= FieldDeclaration* MethodDeclaration BodyDeclaration*Represents an import declaration in a Java file.Represents a binary infix expression.A class or instance initializer.Represents an intersection type.A wrapper around a statement that assigns it a label.A lambda expression.Formal parameter of a lambda expression.The parameter list of a lambda expression.Common supertype for nodes that act as a kind of list of other nodes.A lexical literal.A statement that contains a local class declaration.Represents a local variable declaration.A loop statement.Represents the value of a member of an annotation.Represents an array of member values in an annotation member value.Represents a single pair of member name to value in an annotation.A method invocation expression.A method declaration, in a class or interface declaration.Method or constructor reference expression.List of modifiers of a declaration.A module declaration.A directive of a module declaration.An "exports" directive of a module declaration.The name of a module.An "opens" directive of a module declaration.A "provides" directive of a module declaration.A "requires" directive of a module declaration.A "uses" directive of a module declaration.The null literal.A numeric literal of any type (double, int, long, float, etc).Package declaration at the top of a source file.A pattern for pattern matching constructs likeInstanceOfExpression
or within aASTSwitchLabel
).Wraps aASTPattern
node but presents the interface ofASTExpression
.Contains a potentially empty list of nested Patterns for RecordPattern (Java 21).Represents thepermits
clause of a (sealed) class declaration.Tags thoseexpressions
that are categorised as primary by the JLS.Represents a primitive type.Receiver parameter.Defines the body of a RecordDeclaration (JDK 16 feature).Defines a single component of a RecordDeclaration (JDK 16 feature).Defines the state description of a RecordDeclaration (JDK 16 feature).A record declaration is a special data class type (JDK 16 feature).A record pattern, a Java 21 language feature.Represents a reference type, i.e. a class or interface type, or an array type.A resource of a try-with-resources.A list of resources in a try-with-resources.A return statement in a method or constructor body.Represents a code statement.A list of statement expressions.Represents a string literal.The "super" keyword.A non-fallthrough switch rule, introduced with switch expressions.A node that can appear as the right-hand-side of aSwitchArrowRule
.A branch of aSwitchLike
.A switch expression, as introduced in Java 12.A fallthrough switch branch.Common supertype for switch statements and switch expressions.Represents aswitch
statement.A synchronized statement.The "this" expression.Throws clause of anASTConstructorDeclaration
orASTMethodDeclaration
.Athrow
statement.Marker interface for nodes that can appear on the top-level of a file.Try statement node.Represents a type reference.Represents a list of type arguments.Body of a type declaration.Groups class, enum, record, annotation and interface declarations under a common supertype.Wraps a type node but presents the interface ofASTExpression
.Represents a type parameter declaration of a method, constructor, class or interface declaration.Represents a list of type parameters.A type pattern (JDK16).Represents a unary operation on a value.Represents the type node of a multi-catch statement.An unnamed pattern, a Java 22 language feature.An unqualified reference to a variable (either local, or a field that is in scope).Groups a variable ID and its initializer if it exists.Represents an identifier in the context of variable or parameter declarations (not their use in expressions).Type node to represent the void pseudo-type.Represents awhile
loop.Represents a wildcard type.Ayield
statement in a switch expression.Represents the operator of an infix expression.A method reference or lambda expression.Internal API.Groups method and constructor call, together, as well as explicit constructor invocation statements, and enum constant declarations.Wraps a comment token to provide some utilities.AJavaComment
that has Javadoc content.A node that may own a javadoc comment.Root interface for all Nodes of the Java AST.Adapter for the JavaParser, using the specified grammar version.Token kinds (JavaccToken.kind
) for this language.JavaVisitor<P,R> JavaVisitorBase<P,R> Base implementation ofJavaVisitor
.A Java modifier.A node that uses another method or constructor.A node that owns a modifier list.Represents the visibility of a declaration.Node that may be qualified by an expression, e.g. an instance method call or inner class constructor invocation.Marker interface for those nodes that can be the target of a return statement.A node that declares a corresponding symbol.Deprecated.This implementation has been superseded.A node that has a statically known type.A symbol declaration, whose symbol can declare type parameters.A unary operator, either prefix or postfix.