Package org.eclipse.cdt.core.dom.ast

## Interface IASTNode

All Known Subinterfaces:
  `IASTAlignmentSpecifier`, `IASTArrayDeclarator`, `IASTArrayModifier`, `IASTArraySubscriptExpression`, `IASTASMDeclaration`, `IASTAttribute`, `IASTAttributeList`, `IASTAttributeOwner`, `IASTAttributeSpecifier`, `IASTBinaryExpression`, `IASTBinaryTypeIdExpression`, `IASTBreakStatement`, `IASTCaseStatement`, `IASTCastExpression`, `IASTComment`, `IASTCompositeTypeSpecifier`, `IASTCompoundStatement`, `IASTConditionalExpression`, `IASTContinueStatement`, `IASTDeclaration`, `IASTDeclarationListOwner`, `IASTDeclarationStatement`, `IASTDeclarator`, `IASTDeclSpecifier`, `IASTDefaultStatement`, `IASTDoStatement`, `IASTElaboratedTypeSpecifier`, `IASTEnumerationSpecifier`, `IASTEnumerationSpecifier.IASTEnumerator`, `IASTEqualsInitializer`, `IASTExpression`, `IASTExpressionList`, `IASTExpressionStatement`, `IASTFieldDeclarator`, `IASTFieldReference`, `IASTForStatement`, `IASTFunctionCallExpression`, `IASTFunctionDeclarator`, `IASTFunctionDefinition`, `IASTFunctionStyleMacroParameter`, `IASTGotoStatement`, `IASTIdExpression`, `IASTIfStatement`, `IASTImplicitDestructorName`, `IASTImplicitDestructorNameOwner`, `IASTImplicitName`, `IASTImplicitNameOwner`, `IASTInitializer`, `IASTInitializerClause`, `IASTInitializerExpression`, `IASTInitializerList`, `IASTLabelStatement`, `IASTLiteralExpression`, `IASTName`, `IASTNamedTypeSpecifier`, `IASTNullStatement`, `IASTParameterDeclaration`, `IASTPointer`, `IASTPointerOperator`, `IASTPreprocessorElifStatement`, `IASTPreprocessorElseStatement`, `IASTPreprocessorEndifStatement`, `IASTPreprocessorErrorStatement`, `IASTPreprocessorFunctionStyleMacroDefinition`, `IASTPreprocessorIfdefStatement`, `IASTPreprocessorIfndefStatement`, `IASTPreprocessorIfStatement`, `IASTPreprocessorIncludeStatement`, `IASTPreprocessorMacroDefinition`, `IASTPreprocessorMacroExpansion`, `IASTPreprocessorObjectStyleMacroDefinition`, `IASTPreprocessorPragmaStatement`, `IASTPreprocessorStatement`, `IASTPreprocessorUndefStatement`, `IASTProblem`, `IASTProblemDeclaration`, `IASTProblemExpression`, `IASTProblemStatement`, `IASTProblemTypeId`, `IASTReturnStatement`, `IASTSimpleDeclaration`, `IASTSimpleDeclSpecifier`, `IASTStandardFunctionDeclarator`, `IASTStatement`, `IASTSwitchStatement`, `IASTToken`, `IASTTokenList`, `IASTTranslationUnit`, `IASTTypeId`, `IASTTypeIdExpression`, `IASTTypeIdInitializerExpression`, `IASTUnaryExpression`, `IASTWhileStatement`, `ICASTArrayDesignator`, `ICASTArrayModifier`, `ICASTCompositeTypeSpecifier`, `ICASTDeclSpecifier`, `ICASTDesignatedInitializer`, `ICASTDesignator`, `ICASTElaboratedTypeSpecifier`, `ICASTEnumerationSpecifier`, `ICASTFieldDesignator`, `ICASTKnRFunctionDeclarator`, `ICASTPointer`, `ICASTSimpleDeclSpecifier`, `ICASTTypedefNameSpecifier`, `ICASTTypeIdInitializerExpression`, `ICPPASTAliasDeclaration`, `ICPPASTAlignmentSpecifier`, `ICPPASTAmbiguousTemplateArgument`, `ICPPASTArrayDeclarator`, `ICPPASTArrayDesignator`, `ICPPASTArraySubscriptExpression`, `ICPPASTAttribute`, `ICPPASTAttributeList`, `ICPPASTAttributeSpecifier`, `ICPPASTBinaryExpression`, `ICPPASTCapture`, `ICPPASTCastExpression`, `ICPPASTCatchHandler`, `ICPPASTClassVirtSpecifier`, `ICPPASTCompositeTypeSpecifier`, `ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier`, `ICPPASTCompoundStatement`, `ICPPASTConstructorChainInitializer`, `ICPPASTConstructorInitializer`, `ICPPASTConversionName`, `ICPPASTDeclarator`, `ICPPASTDeclSpecifier`, `ICPPASTDecltypeSpecifier`, `ICPPASTDeleteExpression`, `ICPPASTDesignatedInitializer`, `ICPPASTDesignator`, `ICPPASTElaboratedTypeSpecifier`, `ICPPASTEnumerationSpecifier`, `ICPPASTExplicitTemplateInstantiation`, `ICPPASTExpression`, `ICPPASTExpressionList`, `ICPPASTFieldDeclarator`, `ICPPASTFieldDesignator`, `ICPPASTFieldReference`, `ICPPASTForStatement`, `ICPPASTFunctionCallExpression`, `ICPPASTFunctionDeclarator`, `ICPPASTFunctionDefinition`, `ICPPASTFunctionTryBlockDeclarator`, `ICPPASTFunctionWithTryBlock`, `ICPPASTIfStatement`, `ICPPASTInitCapture`, `ICPPASTInitializerClause`, `ICPPASTInitializerList`, `ICPPASTLambdaExpression`, `ICPPASTLinkageSpecification`, `ICPPASTLiteralExpression`, `ICPPASTName`, `ICPPASTNamedTypeSpecifier`, `ICPPASTNamespaceAlias`, `ICPPASTNamespaceDefinition`, `ICPPASTNameSpecifier`, `ICPPASTNaryTypeIdExpression`, `ICPPASTNewExpression`, `ICPPASTOperatorName`, `ICPPASTPackExpansionExpression`, `ICPPASTParameterDeclaration`, `ICPPASTPointerToMember`, `ICPPASTQualifiedName`, `ICPPASTRangeBasedForStatement`, `ICPPASTReferenceOperator`, `ICPPASTSimpleDeclSpecifier`, `ICPPASTSimpleTypeConstructorExpression`, `ICPPASTSimpleTypeTemplateParameter`, `ICPPASTStaticAssertDeclaration`, `ICPPASTStructuredBindingDeclaration`, `ICPPASTSwitchStatement`, `ICPPASTTemplateDeclaration`, `ICPPASTTemplatedTypeTemplateParameter`, `ICPPASTTemplateId`, `ICPPASTTemplateName`, `ICPPASTTemplateParameter`, `ICPPASTTemplateSpecialization`, `ICPPASTTranslationUnit`, `ICPPASTTryBlockStatement`, `ICPPASTTypeId`, `ICPPASTTypeIdExpression`, `ICPPASTTypenameExpression`, `ICPPASTTypeTransformationSpecifier`, `ICPPASTUnaryExpression`, `ICPPASTUsingDeclaration`, `ICPPASTUsingDirective`, `ICPPASTVirtSpecifier`, `ICPPASTVisibilityLabel`, `ICPPASTWhileStatement`, `IGCCASTArrayRangeDesignator`, `IGCCASTAttributeList`, `IGCCASTAttributeSpecifier`, `IGCCASTSimpleDeclSpecifier`, `IGNUASTCompoundStatementExpression`, `IGNUASTGotoStatement`, `IGNUASTTypeIdExpression`, `IGNUASTUnaryExpression`, `IGPPASTArrayRangeDesignator`, `IGPPASTBinaryExpression`, `IGPPASTDeclSpecifier`, `IGPPASTExplicitTemplateInstantiation`, `IGPPASTPointer`, `IGPPASTPointerToMember`, `IGPPASTSimpleDeclSpecifier`, `IMSASTDeclspecList`

    public interface IASTNode

This is the root node in the physical AST. A physical node represents a chunk of text in the source program. Classes implementing this interface are not thread safe. Even 'get' methods may cause changes to the underlying object.

Restriction:
  This interface is not intended to be implemented by clients.
Restriction:
  This interface is not intended to be extended by clients.

### Nested Class Summary

Nested Classes
`static class` `IASTNode.CopyStyle`

### Field Summary

Fields
`static IASTNode[]` `EMPTY_NODE_ARRAY`

### Method Summary

All Methods Instance Methods Abstract Methods
`boolean` `accept​(ASTVisitor visitor)` Abstract method to be overridden by all subclasses.
`boolean` `contains​(IASTNode node)` Returns whether this node contains the given one.
`IASTNode` `copy()` Returns a mutable copy of the tree rooted at this node.
`IASTNode` `copy​(IASTNode.CopyStyle style)` Returns a mutable copy of the tree rooted at this node.
`IASTNode[]` `getChildren()` Returns the children of this node.
`String` `getContainingFilename()` Lightweight check for understanding what file we are in.
`IASTFileLocation` `getFileLocation()` Computes a file location for the node.
`IToken` `getLeadingSyntax()` Returns the tokens that can be found between this node and its left sibling (or the beginning of the parent, if there is no left sibling).
`IASTNodeLocation[]` `getNodeLocations()` Returns the location of this node.
`IASTNode` `getOriginalNode()` If the node is a copy of some other node, returns the original node.
`IASTNode` `getParent()` Returns the parent node of this node in the tree.
`ASTNodeProperty` `getPropertyInParent()` Describes relationship between this child node and it's parent.
`String` `getRawSignature()` Returns the raw signature of the IASTNode before it is processed by the preprocessor.
`IToken` `getSyntax()` Returns the tokens that make up this node.
`IToken` `getTrailingSyntax()` Returns the tokens that can be found between this node and its right sibling (or the end of the parent, if there is no right sibling).
`IASTTranslationUnit` `getTranslationUnit()` Returns the translation unit (master) node that is the ancestor of all nodes in this AST.
`boolean` `isActive()` Returns false if this node was parsed in an inactive code branch.
`boolean` `isFrozen()` Returns true if this node is frozen, false otherwise.
`boolean` `isPartOfTranslationUnitFile()` Lightweight check to see whether this node is part of the root file.
`void` `setParent​(IASTNode node)` Sets the parent node of this node in the tree.
`void` `setPropertyInParent​(ASTNodeProperty property)` Sets the parent property of the node.

### Field Detail

#### EMPTY_NODE_ARRAY

    static final IASTNode[] EMPTY_NODE_ARRAY

### Method Detail

#### getTranslationUnit

    IASTTranslationUnit getTranslationUnit()

Returns the translation unit (master) node that is the ancestor of all nodes in this AST.

Returns:
  `IASTTranslationUnit`

#### getNodeLocations

    IASTNodeLocation[] getNodeLocations()

Returns the location of this node. In cases not involving macro expansions, the IASTNodeLocation[] result will only have one element in it, and it will be an `IASTFileLocation`.

Where the node is completely generated within a macro expansion, IASTNodeLocation[] result will have one element in it, and it will be an `IASTMacroExpansionLocation`.

Nodes that span file context into a macro expansion (and potentially out of the macro expansion again) result in an IASTNodeLocation[] result that is of length > 1.

We do not provide meaningful node locations for nested macro references (see `IASTPreprocessorMacroExpansion.getNestedMacroReferences()`). For those, the file location of the enclosing explicit macro reference is returned. You can however compute their image-location using `IASTName.getImageLocation()`

#### getFileLocation

    IASTFileLocation getFileLocation()

Computes a file location for the node. When the node actually resides in a macro-expansion the location of the expansion is returned. In case the node spans multiple files the location will be in a common root file and will contain the appropriate include directives.

The method may return `null` in case the node does not have a file-location. This is for instance the case for built-in macro names or empty names for anonymous type declarations.

Returns:
  the mapped file location or `null`.

#### getContainingFilename

    String getContainingFilename()

Lightweight check for understanding what file we are in.

Returns:
  `String` absolute path

#### isPartOfTranslationUnitFile

    boolean isPartOfTranslationUnitFile()

Lightweight check to see whether this node is part of the root file.

Since:
  5.0

#### getParent

    IASTNode getParent()

Returns the parent node of this node in the tree.

#### getChildren

    IASTNode[] getChildren()

Returns the children of this node.

Since:
  5.1

#### setParent

    void setParent​(IASTNode node)

Sets the parent node of this node in the tree.

Parameters:
  `node` - `IASTNode`

#### getPropertyInParent

    ASTNodeProperty getPropertyInParent()

Describes relationship between this child node and it's parent.

Returns:
  `ASTNodeProperty`

#### setPropertyInParent

    void setPropertyInParent​(ASTNodeProperty property)

Sets the parent property of the node.

Parameters:
  `property` -

#### accept

    boolean accept​(ASTVisitor visitor)

Abstract method to be overridden by all subclasses. Necessary for visitation of the tree using an `ASTVisitor`.

Parameters:
  `visitor` -
Returns:
  continue on (true) or quit (false)

#### getRawSignature

    String getRawSignature()

Returns the raw signature of the IASTNode before it is processed by the preprocessor. Example:

     #define ONE 1
     int x=ONE; // getRawSignature() for this declaration would return "int x=ONE;"

Returns:
  the raw signature of the IASTNode before it is processed by the preprocessor

#### contains

    boolean contains​(IASTNode node)

Returns whether this node contains the given one. The decision is made purely on location information and therefore the method is fast.

Parameters:
  `node` - the node to check
Returns:
  whether this node contains the given one.
Since:
  4.0

#### getLeadingSyntax

    IToken getLeadingSyntax()
                     throws ExpansionOverlapsBoundaryException,
                            UnsupportedOperationException

Returns the tokens that can be found between this node and its left sibling (or the beginning of the parent, if there is no left sibling). The tokens are obtained from the lexer, no preprocessing is performed. The offsets of the tokens are relative to the file-offset of this node.

Examples looking at the condition of if-statements:

     #define IF      if
     #define IF_P    if (
     #define IF_P_T  if (true
     #define SEMI_IF ; if
     #define IF_COND if (true)
     void test() {
        if (true) {}       // leading syntax: 'if ('
        IF (true) {}       // leading syntax: 'IF ('
        IF_P true) {}      // leading syntax: 'IF_P'
        IF_P_T ) {}        // throws ExpansionOverlapsBoundaryException
        SEMI_IF (true) {}  // throws ExpansionOverlapsBoundaryException
        IF_COND            // throws ExpansionOverlapsBoundaryException

Returns:
  a chain of tokens or `null`, if there are none.
Throws:
  `ExpansionOverlapsBoundaryException` - if one of the boundaries of the leading syntax is overlapped by a macro-expansion.
  `UnsupportedOperationException` - if invoked on preprocessor nodes, or nodes that are not part of a translation unit.
Since:
  5.1

#### getTrailingSyntax

    IToken getTrailingSyntax()
                      throws ExpansionOverlapsBoundaryException,
                             UnsupportedOperationException

Returns the tokens that can be found between this node and its right sibling (or the end of the parent, if there is no right sibling). The tokens are obtained from the lexer, no preprocessing is performed. The offsets of the tokens are relative to the file-offset of the end of this node.

For examples see `getLeadingSyntax()`.

Returns:
  a chain of tokens or `null`, if there are none.
Throws:
  `ExpansionOverlapsBoundaryException` - if one of the boundaries of the trailing syntax is overlapped by a macro-expansion.
  `UnsupportedOperationException` - if invoked on preprocessor nodes, or nodes that are not part of a translation unit.
Since:
  5.1

#### getSyntax

    IToken getSyntax()
              throws ExpansionOverlapsBoundaryException

Returns the tokens that make up this node. The tokens are obtained from the lexer, no preprocessing is performed. The offsets of the tokens are relative to the file-offset of the beginning of this node.

For examples see `getLeadingSyntax()`.

Returns:
  a chain of tokens or `null`, if there are none.
Throws:
  `ExpansionOverlapsBoundaryException` - if one of the boundaries of the node is overlapped by a macro-expansion.
  `UnsupportedOperationException` - if invoked on preprocessor nodes, or nodes that are not part of a translation unit.
Since:
  5.1

#### isFrozen

    boolean isFrozen()

Returns true if this node is frozen, false otherwise. If the node is frozen then any attempt to call a method that changes the node's state will result in an IllegalStateException.

Since:
  5.1

#### isActive

    boolean isActive()

Returns false if this node was parsed in an inactive code branch.

Since:
  5.1

#### copy

    IASTNode copy()

Returns a mutable copy of the tree rooted at this node. The following postconditions hold:

     copy.getParent() == null
     copy.getPropertyInParent() == null
     copy.isFrozen() == false

Preprocessor nodes do not currently support being copied. Implicit name nodes are not copied, instead they can be regenerated if required.

Calling this method is equivalent to `copy(CopyStyle.withoutLocations)`.

Throws:
  `UnsupportedOperationException` - if this node or one of its descendants does not support copying
Since:
  5.1

#### copy

    IASTNode copy​(IASTNode.CopyStyle style)

Returns a mutable copy of the tree rooted at this node. The following postconditions hold:

     copy.getParent() == null
     copy.getPropertyInParent() == null
     copy.isFrozen() == false

Preprocessor nodes do not currently support being copied. Implicit name nodes are not copied, instead they can be regenerated if required.

Parameters:
  `style` - `IASTNode.CopyStyle` create a copy with or without locations. Please see `IASTNode.CopyStyle` for restrictions on copies with Locations.
Throws:
  `UnsupportedOperationException` - if this node or one of its descendants does not support copying
Since:
  5.3

#### getOriginalNode

    IASTNode getOriginalNode()

If the node is a copy of some other node, returns the original node. Otherwise returns the node itself.

Since:
  5.4