Klasse ASTNode

java.lang.Object
org.aspectj.org.eclipse.jdt.core.dom.ASTNode
Bekannte direkte Unterklassen:
AbstractTagElement, AbstractTextElement, AnonymousClassDeclaration, BodyDeclaration, CatchClause, Comment, CompilationUnit, Dimension, Expression, ImportDeclaration, MemberRef, MemberValuePair, MethodRef, MethodRefParameter, Modifier, ModuleDeclaration, ModuleDirective, ModuleModifier, PackageDeclaration, PatternNode, PointcutDesignator, Statement, TagProperty, Type, TypeParameter, VariableDeclaration

public abstract class ASTNode extends Object
Abstract superclass of all Abstract Syntax Tree (AST) node types.

An AST node represents a Java source code construct, such as a name, type, expression, statement, or declaration.

Each AST node belongs to a unique AST instance, called the owning AST. The children of an AST node always have the same owner as their parent node. If a node from one AST is to be added to a different AST, the subtree must be cloned first to ensure that the added nodes have the correct owning AST.

When an AST node is part of an AST, it has a unique parent node. Clients can navigate upwards, from child to parent, as well as downwards, from parent to child. Newly created nodes are unparented. When an unparented node is set as a child of a node (using a setCHILD method), its parent link is set automatically and the parent link of the former child is set to null. For nodes with properties that include a list of children (for example, Block whose statements property is a list of statements), adding or removing an element to/for the list property automatically updates the parent links. These lists support the List.set method; however, the constraint that the same node cannot appear more than once means that this method cannot be used to swap elements without first removing the node.

ASTs must not contain cycles. All operations that could create a cycle detect this possibility and fail.

ASTs do not contain "holes" (missing subtrees). If a node is required to have a certain property, a syntactically plausible initial value is always supplied.

The hierarchy of AST node types has some convenient groupings marked by abstract superclasses:

  • expressions - Expression
  • names - Name (a sub-kind of expression)
  • statements - Statement
  • types - Type
  • type body declarations - BodyDeclaration

Abstract syntax trees may be hand constructed by clients, using the newTYPE factory methods (see AST) to create new nodes, and the various setCHILD methods to connect them together.

The class ASTParser parses a string containing a Java source code and returns an abstract syntax tree for it. The resulting nodes carry source ranges relating the node back to the original source characters. The source range covers the construct as a whole.

Each AST node carries bit flags, which may convey additional information about the node. For instance, the parser uses a flag to indicate a syntax error. Newly created nodes have no flags set.

Each AST node is capable of carrying an open-ended collection of client-defined properties. Newly created nodes have none. getProperty and setProperty are used to access these properties.

AST nodes are thread-safe for readers provided there are no active writers. If one thread is modifying an AST, including creating new nodes or cloning existing ones, it is not safe for another thread to read, visit, write, create, or clone any of the nodes on the same AST. When synchronization is required, consider using the common AST object that owns the node; that is, use synchronize (node.getAST()) {...}.

ASTs also support the visitor pattern; see the class ASTVisitor for details. The NodeFinder class can be used to find a specific node inside a tree.

Compilation units created by ASTParser from a source document can be serialized after arbitrary modifications with minimal loss of original formatting. See CompilationUnit.recordModifications() for details. See also ASTRewrite for an alternative way to describe and serialize changes to a read-only AST.

Seit:
2.0
Siehe auch:
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final int
    Node type constant indicating a node of type AnnotationTypeDeclaration.
    static final int
    Node type constant indicating a node of type AnnotationTypeMemberDeclaration.
    static final int
    Node type constant indicating a node of type AnonymousClassDeclaration.
    static final int
    Node type constant indicating a node of type ArrayAccess.
    static final int
    Node type constant indicating a node of type ArrayCreation.
    static final int
    Node type constant indicating a node of type ArrayInitializer.
    static final int
    Node type constant indicating a node of type ArrayType.
    static final int
    Node type constant indicating a node of type AssertStatement.
    static final int
    Node type constant indicating a node of type Assignment.
    static final int
    Node type constant indicating a node of type Block.
    static final int
    Node type constant indicating a node of type BlockComment.
    static final int
    Node type constant indicating a node of type BooleanLiteral.
    static final int
    Node type constant indicating a node of type BreakStatement.
    static final int
    Node type constant indicating a node of type CaseDefaultExpression.
    static final int
    Node type constant indicating a node of type CastExpression.
    static final int
    Node type constant indicating a node of type CatchClause.
    static final int
    Node type constant indicating a node of type CharacterLiteral.
    static final int
    Node type constant indicating a node of type ClassInstanceCreation.
    static final int
    Node type constant indicating a node of type CompilationUnit.
    static final int
    Node type constant indicating a node of type ConditionalExpression.
    static final int
    Node type constant indicating a node of type ConstructorInvocation.
    static final int
    Node type constant indicating a node of type ContinueStatement.
    static final int
    Node type constant indicating a node of type CreationReference.
    static final int
    Node type constant indicating a node of type Dimension.
    static final int
    Node type constant indicating a node of type DoStatement.
    static final int
    Node type constant indicating a node of type EmptyStatement.
    static final int
    Node type constant indicating a node of type EnhancedForStatement.
    static final int
    Node type constant indicating a node of type EnhancedForWithRecordPattern.
    static final int
    Node type constant indicating a node of type EnumConstantDeclaration.
    static final int
    Node type constant indicating a node of type EnumDeclaration.
    static final int
    Node type constant indicating a node of type ExportsDirective.
    static final int
    Node type constant indicating a node of type ExpressionMethodReference.
    static final int
    Node type constant indicating a node of type ExpressionStatement.
    static final int
    Node type constant indicating a node of type FieldAccess.
    static final int
    Node type constant indicating a node of type FieldDeclaration.
    static final int
    Node type constant indicating a node of type ForStatement.
    static final int
    Node type constant indicating a node of type GuardedPattern.
    static final int
    Node type constant indicating a node of type IfStatement.
    static final int
    Node type constant indicating a node of type ImportDeclaration.
    static final int
    Node type constant indicating a node of type InfixExpression.
    static final int
    Node type constant indicating a node of type Initializer.
    static final int
    Node type constant indicating a node of type InstanceofExpression.
    static final int
    Node type constant indicating a node of type IntersectionType.
    static final int
    Node type constant indicating a node of type Javadoc.
    static final int
    Node type constant indicating a node of type JavaDocRegion.
    static final int
    Node type constant indicating a node of type TextElement.
    static final int
    Node type constant indicating a node of type LabeledStatement.
    static final int
    Node type constant indicating a node of type LambdaExpression.
    static final int
    Node type constant indicating a node of type LineComment.
    static final int
    Flag constant (bit mask, value 1) indicating that there is something not quite right with this AST node.
    static final int
    Node type constant indicating a node of type MarkerAnnotation.
    static final int
    Node type constant indicating a node of type MemberRef.
    static final int
    Node type constant indicating a node of type MemberValuePair.
    static final int
    Node type constant indicating a node of type MethodDeclaration.
    static final int
    Node type constant indicating a node of type MethodInvocation.
    static final int
    Node type constant indicating a node of type MethodRef.
    static final int
    Node type constant indicating a node of type MethodRefParameter.
    static final int
    Node type constant indicating a node of type Modifier.
    static final int
    Node type constant indicating a node of type ModuleDeclaration.
    static final int
    Node type constant indicating a node of type ModuleModifier.
    static final int
    Node type constant indicating a node of type ModuleQualifiedName.
    static final int
    Node type constant indicating a node of type NameQualifiedType.
    static final int
    Node type constant indicating a node of type NormalAnnotation.
    static final int
    Node type constant indicating a node of type NullLiteral.
    static final int
    Node type constant indicating a node of type NullPattern.
    static final int
    Node type constant indicating a node of type NumberLiteral.
    static final int
    Node type constant indicating a node of type OpensDirective.
    static final int
    Flag constant (bit mask, value 2) indicating that this is a node that was created by the parser (as opposed to one created by another party).
    static final int
    Node type constant indicating a node of type PackageDeclaration.
    static final int
    Node type constant indicating a node of type ParameterizedType.
    static final int
    Node type constant indicating a node of type ParenthesizedExpression.
    static final int
    Node type constant indicating a node of type PatternInstanceofExpression.
    static final int
    Node type constant indicating a node of type PostfixExpression.
    static final int
    Node type constant indicating a node of type PrefixExpression.
    static final int
    Node type constant indicating a node of type PrimitiveType.
    static final int
    Flag constant (bit mask, value 4) indicating that this node is unmodifiable.
    static final int
    Node type constant indicating a node of type ProvidesDirective.
    static final int
    Node type constant indicating a node of type QualifiedName.
    static final int
    Node type constant indicating a node of type QualifiedType.
    static final int
    Node type constant indicating a node of type RecordDeclaration.
    static final int
    Node type constant indicating a node of type RecordPattern.
    static final int
    Flag constant (bit mask, value 8) indicating that this node or a part of this node is recovered from source that contains a syntax error detected in the vicinity.
    static final int
    Node type constant indicating a node of type RequiresDirective.
    static final int
    Node type constant indicating a node of type ReturnStatement.
    static final int
    Node type constant indicating a node of type SimpleName.
    static final int
    Node type constant indicating a node of type SimpleType.
    static final int
    Node type constant indicating a node of type SingleMemberAnnotation.
    static final int
    Node type constant indicating a node of type SingleVariableDeclaration.
    static final int
    Node type constant indicating a node of type StringLiteral.
    static final int
    Node type constant indicating a node of type SuperConstructorInvocation.
    static final int
    Node type constant indicating a node of type SuperFieldAccess.
    static final int
    Node type constant indicating a node of type SuperMethodInvocation.
    static final int
    Node type constant indicating a node of type SuperMethhodReference.
    static final int
    Node type constant indicating a node of type SwitchCase.
    static final int
    Node type constant indicating a node of type SwitchExpression.
    static final int
    Node type constant indicating a node of type SwitchStatement.
    static final int
    Node type constant indicating a node of type SynchronizedStatement.
    static final int
    Node type constant indicating a node of type TagElement.
    static final int
    Node type constant indicating a node of type TagProperty.
    static final int
    Node type constant indicating a node of type TextBlock.
    static final int
    Node type constant indicating a node of type TextElement.
    static final int
    Node type constant indicating a node of type ThisExpression.
    static final int
    Node type constant indicating a node of type ThrowStatement.
    static final int
    Node type constant indicating a node of type TryStatement.
    static final int
    Node type constant indicating a node of type TypeDeclaration.
    static final int
    Node type constant indicating a node of type TypeDeclarationStatement.
    static final int
    Node type constant indicating a node of type TypeLiteral.
    static final int
    Node type constant indicating a node of type TypeMethodReference.
    static final int
    Node type constant indicating a node of type TypeParameter.
    static final int
    Node type constant indicating a node of type TypePattern.
    static final int
    Node type constant indicating a node of type UnionType.
    static final int
    Node type constant indicating a node of type UsesDirective.
    static final int
    Node type constant indicating a node of type VariableDeclarationExpression.
    static final int
    Node type constant indicating a node of type VariableDeclarationFragment.
    static final int
    Node type constant indicating a node of type VariableDeclarationStatement.
    static final int
    Node type constant indicating a node of type WhileStatement.
    static final int
    Node type constant indicating a node of type WildcardType.
    static final int
    Node type constant indicating a node of type YieldStatement.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    final void
    accept(ASTVisitor visitor)
    Accepts the given visitor on a visit of the current node.
    static ASTNode
    copySubtree(AST target, ASTNode node)
    Returns a deep copy of the subtree of AST nodes rooted at the given node.
    static List
    copySubtrees(AST target, List nodes)
    Returns a deep copy of the subtrees of AST nodes rooted at the given list of nodes.
    final void
    Removes this node from its parent.
    final boolean
    The ASTNode implementation of this Object method uses object identity (==).
    final AST
    Returns this node's AST.
    final int
    Returns the flags associated with this node.
    final int
    Returns the length in characters of the original source file indicating where the source fragment corresponding to this node ends.
    Returns the location of this node within its parent, or null if this is a root node.
    final int
    Returns an integer value identifying the type of this concrete AST node.
    final ASTNode
    Returns this node's parent node, or null if this is the root node.
    final Object
    getProperty(String propertyName)
    Returns the value of the named property of this node, or null if none.
    final ASTNode
    Returns the root node at or above this node; returns this node if it is a root.
    final int
    Returns the character index into the original source file indicating where the source fragment corresponding to this node begins.
    final Object
    Returns the value of the given structural property for this node.
    final int
     
    static Class
    nodeClassForType(int nodeType)
    Returns the node class for the corresponding node type.
    final Map
    Returns an unmodifiable table of the properties of this node with non-null values.
    final void
    setFlags(int flags)
    Sets the flags associated with this node to the given value.
    final void
    setProperty(String propertyName, Object data)
    Sets the named property of this node to the given value, or to null to clear it.
    final void
    setSourceRange(int startPosition, int length)
    Sets the source range of the original source file where the source fragment corresponding to this node was found.
    final void
    Sets the value of the given structural property for this node.
    final List
    Returns a list of structural property descriptors for nodes of the same type as this node.
    final int
    Returns an estimate of the memory footprint in bytes of the entire subtree rooted at this node.
    final boolean
    subtreeMatch(ASTMatcher matcher, Object other)
    Returns whether the subtree rooted at the given node matches the given other object as decided by the given matcher.
    final String
    Returns a string representation of this node suitable for debugging purposes only.

    Von Klasse geerbte Methoden java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Felddetails

    • ANONYMOUS_CLASS_DECLARATION

      public static final int ANONYMOUS_CLASS_DECLARATION
      Node type constant indicating a node of type AnonymousClassDeclaration.
      Siehe auch:
    • ARRAY_ACCESS

      public static final int ARRAY_ACCESS
      Node type constant indicating a node of type ArrayAccess.
      Siehe auch:
    • ARRAY_CREATION

      public static final int ARRAY_CREATION
      Node type constant indicating a node of type ArrayCreation.
      Siehe auch:
    • ARRAY_INITIALIZER

      public static final int ARRAY_INITIALIZER
      Node type constant indicating a node of type ArrayInitializer.
      Siehe auch:
    • ARRAY_TYPE

      public static final int ARRAY_TYPE
      Node type constant indicating a node of type ArrayType.
      Siehe auch:
    • ASSERT_STATEMENT

      public static final int ASSERT_STATEMENT
      Node type constant indicating a node of type AssertStatement.
      Siehe auch:
    • ASSIGNMENT

      public static final int ASSIGNMENT
      Node type constant indicating a node of type Assignment.
      Siehe auch:
    • BLOCK

      public static final int BLOCK
      Node type constant indicating a node of type Block.
      Siehe auch:
    • BOOLEAN_LITERAL

      public static final int BOOLEAN_LITERAL
      Node type constant indicating a node of type BooleanLiteral.
      Siehe auch:
    • BREAK_STATEMENT

      public static final int BREAK_STATEMENT
      Node type constant indicating a node of type BreakStatement.
      Siehe auch:
    • CAST_EXPRESSION

      public static final int CAST_EXPRESSION
      Node type constant indicating a node of type CastExpression.
      Siehe auch:
    • CATCH_CLAUSE

      public static final int CATCH_CLAUSE
      Node type constant indicating a node of type CatchClause.
      Siehe auch:
    • CHARACTER_LITERAL

      public static final int CHARACTER_LITERAL
      Node type constant indicating a node of type CharacterLiteral.
      Siehe auch:
    • CLASS_INSTANCE_CREATION

      public static final int CLASS_INSTANCE_CREATION
      Node type constant indicating a node of type ClassInstanceCreation.
      Siehe auch:
    • COMPILATION_UNIT

      public static final int COMPILATION_UNIT
      Node type constant indicating a node of type CompilationUnit.
      Siehe auch:
    • CONDITIONAL_EXPRESSION

      public static final int CONDITIONAL_EXPRESSION
      Node type constant indicating a node of type ConditionalExpression.
      Siehe auch:
    • CONSTRUCTOR_INVOCATION

      public static final int CONSTRUCTOR_INVOCATION
      Node type constant indicating a node of type ConstructorInvocation.
      Siehe auch:
    • CONTINUE_STATEMENT

      public static final int CONTINUE_STATEMENT
      Node type constant indicating a node of type ContinueStatement.
      Siehe auch:
    • DO_STATEMENT

      public static final int DO_STATEMENT
      Node type constant indicating a node of type DoStatement.
      Siehe auch:
    • EMPTY_STATEMENT

      public static final int EMPTY_STATEMENT
      Node type constant indicating a node of type EmptyStatement.
      Siehe auch:
    • EXPRESSION_STATEMENT

      public static final int EXPRESSION_STATEMENT
      Node type constant indicating a node of type ExpressionStatement.
      Siehe auch:
    • FIELD_ACCESS

      public static final int FIELD_ACCESS
      Node type constant indicating a node of type FieldAccess.
      Siehe auch:
    • FIELD_DECLARATION

      public static final int FIELD_DECLARATION
      Node type constant indicating a node of type FieldDeclaration.
      Siehe auch:
    • FOR_STATEMENT

      public static final int FOR_STATEMENT
      Node type constant indicating a node of type ForStatement.
      Siehe auch:
    • IF_STATEMENT

      public static final int IF_STATEMENT
      Node type constant indicating a node of type IfStatement.
      Siehe auch:
    • IMPORT_DECLARATION

      public static final int IMPORT_DECLARATION
      Node type constant indicating a node of type ImportDeclaration.
      Siehe auch:
    • INFIX_EXPRESSION

      public static final int INFIX_EXPRESSION
      Node type constant indicating a node of type InfixExpression.
      Siehe auch:
    • INITIALIZER

      public static final int INITIALIZER
      Node type constant indicating a node of type Initializer.
      Siehe auch:
    • JAVADOC

      public static final int JAVADOC
      Node type constant indicating a node of type Javadoc.
      Siehe auch:
    • LABELED_STATEMENT

      public static final int LABELED_STATEMENT
      Node type constant indicating a node of type LabeledStatement.
      Siehe auch:
    • METHOD_DECLARATION

      public static final int METHOD_DECLARATION
      Node type constant indicating a node of type MethodDeclaration.
      Siehe auch:
    • METHOD_INVOCATION

      public static final int METHOD_INVOCATION
      Node type constant indicating a node of type MethodInvocation.
      Siehe auch:
    • NULL_LITERAL

      public static final int NULL_LITERAL
      Node type constant indicating a node of type NullLiteral.
      Siehe auch:
    • NUMBER_LITERAL

      public static final int NUMBER_LITERAL
      Node type constant indicating a node of type NumberLiteral.
      Siehe auch:
    • PACKAGE_DECLARATION

      public static final int PACKAGE_DECLARATION
      Node type constant indicating a node of type PackageDeclaration.
      Siehe auch:
    • PARENTHESIZED_EXPRESSION

      public static final int PARENTHESIZED_EXPRESSION
      Node type constant indicating a node of type ParenthesizedExpression.
      Siehe auch:
    • POSTFIX_EXPRESSION

      public static final int POSTFIX_EXPRESSION
      Node type constant indicating a node of type PostfixExpression.
      Siehe auch:
    • PREFIX_EXPRESSION

      public static final int PREFIX_EXPRESSION
      Node type constant indicating a node of type PrefixExpression.
      Siehe auch:
    • PRIMITIVE_TYPE

      public static final int PRIMITIVE_TYPE
      Node type constant indicating a node of type PrimitiveType.
      Siehe auch:
    • QUALIFIED_NAME

      public static final int QUALIFIED_NAME
      Node type constant indicating a node of type QualifiedName.
      Siehe auch:
    • RETURN_STATEMENT

      public static final int RETURN_STATEMENT
      Node type constant indicating a node of type ReturnStatement.
      Siehe auch:
    • SIMPLE_NAME

      public static final int SIMPLE_NAME
      Node type constant indicating a node of type SimpleName.
      Siehe auch:
    • SIMPLE_TYPE

      public static final int SIMPLE_TYPE
      Node type constant indicating a node of type SimpleType.
      Siehe auch:
    • SINGLE_VARIABLE_DECLARATION

      public static final int SINGLE_VARIABLE_DECLARATION
      Node type constant indicating a node of type SingleVariableDeclaration.
      Siehe auch:
    • STRING_LITERAL

      public static final int STRING_LITERAL
      Node type constant indicating a node of type StringLiteral.
      Siehe auch:
    • SUPER_CONSTRUCTOR_INVOCATION

      public static final int SUPER_CONSTRUCTOR_INVOCATION
      Node type constant indicating a node of type SuperConstructorInvocation.
      Siehe auch:
    • SUPER_FIELD_ACCESS

      public static final int SUPER_FIELD_ACCESS
      Node type constant indicating a node of type SuperFieldAccess.
      Siehe auch:
    • SUPER_METHOD_INVOCATION

      public static final int SUPER_METHOD_INVOCATION
      Node type constant indicating a node of type SuperMethodInvocation.
      Siehe auch:
    • SWITCH_CASE

      public static final int SWITCH_CASE
      Node type constant indicating a node of type SwitchCase.
      Siehe auch:
    • SWITCH_STATEMENT

      public static final int SWITCH_STATEMENT
      Node type constant indicating a node of type SwitchStatement.
      Siehe auch:
    • SYNCHRONIZED_STATEMENT

      public static final int SYNCHRONIZED_STATEMENT
      Node type constant indicating a node of type SynchronizedStatement.
      Siehe auch:
    • THIS_EXPRESSION

      public static final int THIS_EXPRESSION
      Node type constant indicating a node of type ThisExpression.
      Siehe auch:
    • THROW_STATEMENT

      public static final int THROW_STATEMENT
      Node type constant indicating a node of type ThrowStatement.
      Siehe auch:
    • TRY_STATEMENT

      public static final int TRY_STATEMENT
      Node type constant indicating a node of type TryStatement.
      Siehe auch:
    • TYPE_DECLARATION

      public static final int TYPE_DECLARATION
      Node type constant indicating a node of type TypeDeclaration.
      Siehe auch:
    • TYPE_DECLARATION_STATEMENT

      public static final int TYPE_DECLARATION_STATEMENT
      Node type constant indicating a node of type TypeDeclarationStatement.
      Siehe auch:
    • TYPE_LITERAL

      public static final int TYPE_LITERAL
      Node type constant indicating a node of type TypeLiteral.
      Siehe auch:
    • VARIABLE_DECLARATION_EXPRESSION

      public static final int VARIABLE_DECLARATION_EXPRESSION
      Node type constant indicating a node of type VariableDeclarationExpression.
      Siehe auch:
    • VARIABLE_DECLARATION_FRAGMENT

      public static final int VARIABLE_DECLARATION_FRAGMENT
      Node type constant indicating a node of type VariableDeclarationFragment.
      Siehe auch:
    • VARIABLE_DECLARATION_STATEMENT

      public static final int VARIABLE_DECLARATION_STATEMENT
      Node type constant indicating a node of type VariableDeclarationStatement.
      Siehe auch:
    • WHILE_STATEMENT

      public static final int WHILE_STATEMENT
      Node type constant indicating a node of type WhileStatement.
      Siehe auch:
    • INSTANCEOF_EXPRESSION

      public static final int INSTANCEOF_EXPRESSION
      Node type constant indicating a node of type InstanceofExpression.
      Siehe auch:
    • LINE_COMMENT

      public static final int LINE_COMMENT
      Node type constant indicating a node of type LineComment.
      Seit:
      3.0
      Siehe auch:
    • BLOCK_COMMENT

      public static final int BLOCK_COMMENT
      Node type constant indicating a node of type BlockComment.
      Seit:
      3.0
      Siehe auch:
    • TAG_ELEMENT

      public static final int TAG_ELEMENT
      Node type constant indicating a node of type TagElement.
      Seit:
      3.0
      Siehe auch:
    • TEXT_ELEMENT

      public static final int TEXT_ELEMENT
      Node type constant indicating a node of type TextElement.
      Seit:
      3.0
      Siehe auch:
    • MEMBER_REF

      public static final int MEMBER_REF
      Node type constant indicating a node of type MemberRef.
      Seit:
      3.0
      Siehe auch:
    • METHOD_REF

      public static final int METHOD_REF
      Node type constant indicating a node of type MethodRef.
      Seit:
      3.0
      Siehe auch:
    • METHOD_REF_PARAMETER

      public static final int METHOD_REF_PARAMETER
      Node type constant indicating a node of type MethodRefParameter.
      Seit:
      3.0
      Siehe auch:
    • ENHANCED_FOR_STATEMENT

      public static final int ENHANCED_FOR_STATEMENT
      Node type constant indicating a node of type EnhancedForStatement.
      Seit:
      3.1
      Siehe auch:
    • ENUM_DECLARATION

      public static final int ENUM_DECLARATION
      Node type constant indicating a node of type EnumDeclaration.
      Seit:
      3.1
      Siehe auch:
    • ENUM_CONSTANT_DECLARATION

      public static final int ENUM_CONSTANT_DECLARATION
      Node type constant indicating a node of type EnumConstantDeclaration.
      Seit:
      3.1
      Siehe auch:
    • TYPE_PARAMETER

      public static final int TYPE_PARAMETER
      Node type constant indicating a node of type TypeParameter.
      Seit:
      3.1
      Siehe auch:
    • PARAMETERIZED_TYPE

      public static final int PARAMETERIZED_TYPE
      Node type constant indicating a node of type ParameterizedType.
      Seit:
      3.1
      Siehe auch:
    • QUALIFIED_TYPE

      public static final int QUALIFIED_TYPE
      Node type constant indicating a node of type QualifiedType.
      Seit:
      3.1
      Siehe auch:
    • WILDCARD_TYPE

      public static final int WILDCARD_TYPE
      Node type constant indicating a node of type WildcardType.
      Seit:
      3.1
      Siehe auch:
    • NORMAL_ANNOTATION

      public static final int NORMAL_ANNOTATION
      Node type constant indicating a node of type NormalAnnotation.
      Seit:
      3.1
      Siehe auch:
    • MARKER_ANNOTATION

      public static final int MARKER_ANNOTATION
      Node type constant indicating a node of type MarkerAnnotation.
      Seit:
      3.1
      Siehe auch:
    • SINGLE_MEMBER_ANNOTATION

      public static final int SINGLE_MEMBER_ANNOTATION
      Node type constant indicating a node of type SingleMemberAnnotation.
      Seit:
      3.1
      Siehe auch:
    • MEMBER_VALUE_PAIR

      public static final int MEMBER_VALUE_PAIR
      Node type constant indicating a node of type MemberValuePair.
      Seit:
      3.1
      Siehe auch:
    • ANNOTATION_TYPE_DECLARATION

      public static final int ANNOTATION_TYPE_DECLARATION
      Node type constant indicating a node of type AnnotationTypeDeclaration.
      Seit:
      3.1
      Siehe auch:
    • ANNOTATION_TYPE_MEMBER_DECLARATION

      public static final int ANNOTATION_TYPE_MEMBER_DECLARATION
      Node type constant indicating a node of type AnnotationTypeMemberDeclaration.
      Seit:
      3.1
      Siehe auch:
    • MODIFIER

      public static final int MODIFIER
      Node type constant indicating a node of type Modifier.
      Seit:
      3.1
      Siehe auch:
    • UNION_TYPE

      public static final int UNION_TYPE
      Node type constant indicating a node of type UnionType.
      Seit:
      3.7.1
      Siehe auch:
    • DIMENSION

      public static final int DIMENSION
      Node type constant indicating a node of type Dimension.
      Seit:
      3.10
      Siehe auch:
    • LAMBDA_EXPRESSION

      public static final int LAMBDA_EXPRESSION
      Node type constant indicating a node of type LambdaExpression.
      Seit:
      3.10
      Siehe auch:
    • INTERSECTION_TYPE

      public static final int INTERSECTION_TYPE
      Node type constant indicating a node of type IntersectionType.
      Seit:
      3.10
      Siehe auch:
    • NAME_QUALIFIED_TYPE

      public static final int NAME_QUALIFIED_TYPE
      Node type constant indicating a node of type NameQualifiedType.
      Seit:
      3.10
      Siehe auch:
    • CREATION_REFERENCE

      public static final int CREATION_REFERENCE
      Node type constant indicating a node of type CreationReference.
      Seit:
      3.10
      Siehe auch:
    • EXPRESSION_METHOD_REFERENCE

      public static final int EXPRESSION_METHOD_REFERENCE
      Node type constant indicating a node of type ExpressionMethodReference.
      Seit:
      3.10
      Siehe auch:
    • SUPER_METHOD_REFERENCE

      public static final int SUPER_METHOD_REFERENCE
      Node type constant indicating a node of type SuperMethhodReference.
      Seit:
      3.10
      Siehe auch:
    • TYPE_METHOD_REFERENCE

      public static final int TYPE_METHOD_REFERENCE
      Node type constant indicating a node of type TypeMethodReference.
      Seit:
      3.10
      Siehe auch:
    • MODULE_DECLARATION

      public static final int MODULE_DECLARATION
      Node type constant indicating a node of type ModuleDeclaration.
      Seit:
      3.14
      Siehe auch:
    • REQUIRES_DIRECTIVE

      public static final int REQUIRES_DIRECTIVE
      Node type constant indicating a node of type RequiresDirective.
      Seit:
      3.14
      Siehe auch:
    • EXPORTS_DIRECTIVE

      public static final int EXPORTS_DIRECTIVE
      Node type constant indicating a node of type ExportsDirective.
      Seit:
      3.14
      Siehe auch:
    • OPENS_DIRECTIVE

      public static final int OPENS_DIRECTIVE
      Node type constant indicating a node of type OpensDirective.
      Seit:
      3.14
      Siehe auch:
    • USES_DIRECTIVE

      public static final int USES_DIRECTIVE
      Node type constant indicating a node of type UsesDirective.
      Seit:
      3.14
      Siehe auch:
    • PROVIDES_DIRECTIVE

      public static final int PROVIDES_DIRECTIVE
      Node type constant indicating a node of type ProvidesDirective.
      Seit:
      3.14
      Siehe auch:
    • MODULE_MODIFIER

      public static final int MODULE_MODIFIER
      Node type constant indicating a node of type ModuleModifier.
      Seit:
      3.14
      Siehe auch:
    • SWITCH_EXPRESSION

      public static final int SWITCH_EXPRESSION
      Node type constant indicating a node of type SwitchExpression.
      Seit:
      3.18
      Siehe auch:
    • YIELD_STATEMENT

      public static final int YIELD_STATEMENT
      Node type constant indicating a node of type YieldStatement.
      Seit:
      3.20
      Siehe auch:
    • TEXT_BLOCK

      public static final int TEXT_BLOCK
      Node type constant indicating a node of type TextBlock.
      Seit:
      3.20
      Siehe auch:
    • RECORD_DECLARATION

      public static final int RECORD_DECLARATION
      Node type constant indicating a node of type RecordDeclaration.
      Seit:
      3.22
      Siehe auch:
    • PATTERN_INSTANCEOF_EXPRESSION

      public static final int PATTERN_INSTANCEOF_EXPRESSION
      Node type constant indicating a node of type PatternInstanceofExpression.
      Seit:
      3.26
      Siehe auch:
    • MODULE_QUALIFIED_NAME

      public static final int MODULE_QUALIFIED_NAME
      Node type constant indicating a node of type ModuleQualifiedName.
      Seit:
      3.24
      Siehe auch:
    • TYPE_PATTERN

      public static final int TYPE_PATTERN
      Node type constant indicating a node of type TypePattern.
      Seit:
      3.28
      Siehe auch:
    • GUARDED_PATTERN

      public static final int GUARDED_PATTERN
      Node type constant indicating a node of type GuardedPattern.
      Seit:
      3.28
      Siehe auch:
    • NULL_PATTERN

      public static final int NULL_PATTERN
      Node type constant indicating a node of type NullPattern.
      Seit:
      3.28
      Siehe auch:
    • CASE_DEFAULT_EXPRESSION

      public static final int CASE_DEFAULT_EXPRESSION
      Node type constant indicating a node of type CaseDefaultExpression.
      Seit:
      3.28
      Siehe auch:
    • TAG_PROPERTY

      public static final int TAG_PROPERTY
      Node type constant indicating a node of type TagProperty.
      Seit:
      3.30
      Siehe auch:
    • JAVADOC_REGION

      public static final int JAVADOC_REGION
      Node type constant indicating a node of type JavaDocRegion.
      Seit:
      3.30
      Siehe auch:
    • JAVADOC_TEXT_ELEMENT

      public static final int JAVADOC_TEXT_ELEMENT
      Node type constant indicating a node of type TextElement.
      Seit:
      3.31
      Siehe auch:
    • RECORD_PATTERN

      public static final int RECORD_PATTERN
      Node type constant indicating a node of type RecordPattern.
      Seit:
      3.32
      Siehe auch:
    • ENHANCED_FOR_WITH_RECORD_PATTERN

      public static final int ENHANCED_FOR_WITH_RECORD_PATTERN
      Node type constant indicating a node of type EnhancedForWithRecordPattern.
      Seit:
      3.34
      Siehe auch:
    • MALFORMED

      public static final int MALFORMED
      Flag constant (bit mask, value 1) indicating that there is something not quite right with this AST node.

      The standard parser (ASTParser) sets this flag on a node to indicate a syntax error detected in the vicinity.

      Siehe auch:
    • ORIGINAL

      public static final int ORIGINAL
      Flag constant (bit mask, value 2) indicating that this is a node that was created by the parser (as opposed to one created by another party).

      The standard parser (ASTParser) sets this flag on the nodes it creates.

      Seit:
      3.0
      Siehe auch:
    • PROTECT

      public static final int PROTECT
      Flag constant (bit mask, value 4) indicating that this node is unmodifiable. When a node is marked unmodifiable, the following operations result in a runtime exception:
      • Change a simple property of this node.
      • Add or remove a child node from this node.
      • Parent (or reparent) this node.

      The standard parser (ASTParser) does not set this flag on the nodes it creates. However, clients may set this flag on a node to prevent further modification of the its structural properties.

      Seit:
      3.0
      Siehe auch:
    • RECOVERED

      public static final int RECOVERED
      Flag constant (bit mask, value 8) indicating that this node or a part of this node is recovered from source that contains a syntax error detected in the vicinity.

      The standard parser (ASTParser) sets this flag on a node to indicate a recovered node.

      Seit:
      3.2
      Siehe auch:
  • Methodendetails

    • nodeClassForType

      public static Class nodeClassForType(int nodeType)
      Returns the node class for the corresponding node type.
      Parameter:
      nodeType - AST node type
      Gibt zurück:
      the corresponding ASTNode subclass
      Löst aus:
      IllegalArgumentException - if nodeType is not a legal AST node type
      Seit:
      3.0
      Siehe auch:
    • getAST

      public final AST getAST()
      Returns this node's AST.

      Note that the relationship between an AST node and its owing AST does not change over the lifetime of a node.

      Gibt zurück:
      the AST that owns this node
    • getParent

      public final ASTNode getParent()
      Returns this node's parent node, or null if this is the root node.

      Note that the relationship between an AST node and its parent node may change over the lifetime of a node.

      Gibt zurück:
      the parent of this node, or null if none
    • getLocationInParent

      public final StructuralPropertyDescriptor getLocationInParent()
      Returns the location of this node within its parent, or null if this is a root node.
       ASTNode node = ...;
       ASTNode parent = node.getParent();
       StructuralPropertyDescriptor location = node.getLocationInParent();
       assert (parent != null) == (location != null);
       if ((location != null) Ungültige Eingabe: "&"Ungültige Eingabe: "&" location.isChildProperty())
          assert parent.getStructuralProperty(location) == node;
       if ((location != null) Ungültige Eingabe: "&"Ungültige Eingabe: "&" location.isChildListProperty())
          assert ((List) parent.getStructuralProperty(location)).contains(node);
       

      Note that the relationship between an AST node and its parent node may change over the lifetime of a node.

      Gibt zurück:
      the location of this node in its parent, or null if this node has no parent
      Seit:
      3.0
    • getRoot

      public final ASTNode getRoot()
      Returns the root node at or above this node; returns this node if it is a root.
      Gibt zurück:
      the root node at or above this node
    • getStructuralProperty

      public final Object getStructuralProperty(StructuralPropertyDescriptor property)
      Returns the value of the given structural property for this node. The value returned depends on the kind of property:
      Parameter:
      property - the property
      Gibt zurück:
      the value, or null if none
      Löst aus:
      RuntimeException - if this node does not have the given property
      Seit:
      3.0
    • setStructuralProperty

      public final void setStructuralProperty(StructuralPropertyDescriptor property, Object value)
      Sets the value of the given structural property for this node. The value passed depends on the kind of property:
      Parameter:
      property - the property
      value - the property value
      Löst aus:
      RuntimeException - if this node does not have the given property, or if the given property cannot be set
      Seit:
      3.0
    • structuralPropertiesForType

      public final List structuralPropertiesForType()
      Returns a list of structural property descriptors for nodes of the same type as this node. Clients must not modify the result.

      Note that property descriptors are a meta-level mechanism for manipulating ASTNodes in a generic way. They are unrelated to get/setProperty.

      Gibt zurück:
      a list of property descriptors (element type: StructuralPropertyDescriptor)
      Seit:
      3.0
    • delete

      public final void delete()
      Removes this node from its parent. Has no effect if this node is unparented. If this node appears as an element of a child list property of its parent, then this node is removed from the list using List.remove. If this node appears as the value of a child property of its parent, then this node is detached from its parent by passing null to the appropriate setter method; this operation fails if this node is in a mandatory property.
      Seit:
      3.0
    • getProperty

      public final Object getProperty(String propertyName)
      Returns the value of the named property of this node, or null if none.
      Parameter:
      propertyName - the property name
      Gibt zurück:
      the property value, or null if none
      Siehe auch:
    • setProperty

      public final void setProperty(String propertyName, Object data)
      Sets the named property of this node to the given value, or to null to clear it.

      Clients should employ property names that are sufficiently unique to avoid inadvertent conflicts with other clients that might also be setting properties on the same node.

      Note that modifying a property is not considered a modification to the AST itself. This is to allow clients to decorate existing nodes with their own properties without jeopardizing certain things (like the validity of bindings), which rely on the underlying tree remaining static.

      Parameter:
      propertyName - the property name
      data - the new property value, or null if none
      Löst aus:
      IllegalArgumentException - if the given property name is null
      Siehe auch:
    • properties

      public final Map properties()
      Returns an unmodifiable table of the properties of this node with non-null values.
      Gibt zurück:
      the table of property values keyed by property name (key type: String; value type: Object)
    • getFlags

      public final int getFlags()
      Returns the flags associated with this node.

      No flags are associated with newly created nodes.

      The flags are the bitwise-or of individual flags. The following flags are currently defined:

      • MALFORMED - indicates node is syntactically malformed
      • ORIGINAL - indicates original node created by ASTParser
      • PROTECT - indicates node is protected from further modification
      • RECOVERED - indicates node or a part of this node is recovered from source that contains a syntax error
      Other bit positions are reserved for future use.
      Gibt zurück:
      the bitwise-or of individual flags
      Siehe auch:
    • setFlags

      public final void setFlags(int flags)
      Sets the flags associated with this node to the given value.

      The flags are the bitwise-or of individual flags. The following flags are currently defined:

      • MALFORMED - indicates node is syntactically malformed
      • ORIGINAL - indicates original node created by ASTParser
      • PROTECT - indicates node is protected from further modification
      • RECOVERED - indicates node or a part of this node is recovered from source that contains a syntax error
      Other bit positions are reserved for future use.

      Note that the flags are not considered a structural property of the node, and can be changed even if the node is marked as protected.

      Parameter:
      flags - the bitwise-or of individual flags
      Siehe auch:
    • getNodeType

      public final int getNodeType()
      Returns an integer value identifying the type of this concrete AST node. The values are small positive integers, suitable for use in switch statements.

      For each concrete node type there is a unique node type constant (name and value). The unique node type constant for a concrete node type such as CastExpression is ASTNode.CAST_EXPRESSION.

      Gibt zurück:
      one of the node type constants
    • equals

      public final boolean equals(Object obj)
      The ASTNode implementation of this Object method uses object identity (==). Use subtreeMatch to compare two subtrees for equality.
      Setzt außer Kraft:
      equals in Klasse Object
      Parameter:
      obj -
      Gibt zurück:
      Siehe auch:
    • hashCode

      public final int hashCode()
      Setzt außer Kraft:
      hashCode in Klasse Object
    • subtreeMatch

      public final boolean subtreeMatch(ASTMatcher matcher, Object other)
      Returns whether the subtree rooted at the given node matches the given other object as decided by the given matcher.
      Parameter:
      matcher - the matcher
      other - the other object, or null
      Gibt zurück:
      true if the subtree matches, or false if they do not match
    • copySubtree

      public static ASTNode copySubtree(AST target, ASTNode node)
      Returns a deep copy of the subtree of AST nodes rooted at the given node. The resulting nodes are owned by the given AST, which may be different from the ASTs of the given node. Even if the given node has a parent, the result node will be unparented.

      Source range information on the original nodes is automatically copied to the new nodes. Client properties (properties) are not carried over.

      The node's AST and the target AST must support the same API level.

      Parameter:
      target - the AST that is to own the nodes in the result
      node - the node to copy, or null if none
      Gibt zurück:
      the copied node, or null if node is null
    • copySubtrees

      public static List copySubtrees(AST target, List nodes)
      Returns a deep copy of the subtrees of AST nodes rooted at the given list of nodes. The resulting nodes are owned by the given AST, which may be different from the ASTs of the nodes in the list. Even if the nodes in the list have parents, the nodes in the result will be unparented.

      Source range information on the original nodes is automatically copied to the new nodes. Client properties (properties) are not carried over.

      Parameter:
      target - the AST that is to own the nodes in the result
      nodes - the list of nodes to copy (element type: ASTNode)
      Gibt zurück:
      the list of copied subtrees (element type: ASTNode)
    • accept

      public final void accept(ASTVisitor visitor)
      Accepts the given visitor on a visit of the current node.
      Parameter:
      visitor - the visitor object
      Löst aus:
      IllegalArgumentException - if the visitor is null
    • getStartPosition

      public final int getStartPosition()
      Returns the character index into the original source file indicating where the source fragment corresponding to this node begins.

      The parser supplies useful well-defined source ranges to the nodes it creates. See ASTParser.setKind(int) for details on precisely where source ranges begin and end.

      Gibt zurück:
      the 0-based character index, or -1 if no source position information is recorded for this node
      Siehe auch:
    • getLength

      public final int getLength()
      Returns the length in characters of the original source file indicating where the source fragment corresponding to this node ends.

      The parser supplies useful well-defined source ranges to the nodes it creates. See ASTParser.setKind(int) methods for details on precisely where source ranges begin and end.

      Gibt zurück:
      a (possibly 0) length, or 0 if no source position information is recorded for this node
      Siehe auch:
    • setSourceRange

      public final void setSourceRange(int startPosition, int length)
      Sets the source range of the original source file where the source fragment corresponding to this node was found.

      See ASTParser.setKind(int) for details on precisely where source ranges are supposed to begin and end.

      Parameter:
      startPosition - a 0-based character index, or -1 if no source position information is available for this node
      length - a (possibly 0) length, or 0 if no source position information is recorded for this node
      Siehe auch:
    • toString

      public final String toString()
      Returns a string representation of this node suitable for debugging purposes only.
      Setzt außer Kraft:
      toString in Klasse Object
      Gibt zurück:
      a debug string
    • subtreeBytes

      public final int subtreeBytes()
      Returns an estimate of the memory footprint in bytes of the entire subtree rooted at this node.
      Gibt zurück:
      the size of this subtree in bytes