dart/ast/ast library
Defines the AST model. The AST (Abstract Syntax Tree) model describes the syntactic (as opposed to semantic) structure of Dart code. The semantic structure of the code is modeled by the element model.
An AST consists of nodes (instances of a subclass of AstNode). The nodes are organized in a tree structure in which the children of a node are the smaller syntactic units from which the node is composed. For example, a binary expression consists of two sub-expressions (the operands) and an operator. The two expressions are represented as nodes. The operator is not represented as a node.
The AST is constructed by the parser based on the sequence of tokens produced by the scanner. Most nodes provide direct access to the tokens used to build the node. For example, the token for the operator in a binary expression can be accessed from the node representing the binary expression.
While any node can theoretically be the root of an AST structure, almost all of the AST structures known to the analyzer have a CompilationUnit as the root of the structure. A compilation unit represents all of the Dart code in a single file.
An AST can be either unresolved or resolved. When an AST is unresolved
certain properties will not have been computed and the accessors for those
properties will return null
. The documentation for those getters should
describe that this is a possibility.
When an AST is resolved, the identifiers in the AST will be associated with the elements that they refer to and every expression in the AST will have a type associated with it.
Classes
- AdjacentStrings
- Two or more string literals that are implicitly concatenated because of being adjacent (separated only by whitespace).
- AnnotatedNode
- An AST node that can be annotated with both a documentation comment and a list of annotations.
- Annotation
- An annotation that can be associated with an AST node.
- ArgumentList
- A list of arguments in the invocation of an executable element (that is, a function, method, or constructor).
- AsExpression
- An as expression.
- AssertInitializer
- An assert in the initializer list of a constructor.
- Assertion
- An assertion, either in a block or in the initializer list of a constructor.
- AssertStatement
- An assert statement.
- AssignmentExpression
- An assignment expression.
- AstNode
- A node in the AST structure for a Dart program.
-
AstVisitor<
R> - An object that can be used to visit an AST structure.
- AwaitExpression
- An await expression.
- BinaryExpression
- A binary (infix) expression.
- Block
- A sequence of statements.
- BlockFunctionBody
- A function body that consists of a block of statements.
- BooleanLiteral
- A boolean literal expression.
- BreakStatement
- A break statement.
- CascadeExpression
- A sequence of cascaded expressions: expressions that share a common target.
- CatchClause
- A catch clause within a try statement.
- ClassDeclaration
- The declaration of a class.
- ClassMember
- A node that declares a name within the scope of a class declarations.
- ClassOrMixinDeclaration
- The declaration of a class or mixin.
- ClassTypeAlias
- A class type alias.
- CollectionElement
- An element in a list, map or set literal.
- Combinator
- A combinator associated with an import or export directive.
- Comment
- A comment within the source code.
- CommentReferableExpression
- An interface for an Expression which can make up a CommentReference.
- CommentReference
- A reference to a Dart element that is found within a documentation comment.
- CompilationUnit
- A compilation unit.
- CompilationUnitMember
- A node that declares one or more names within the scope of a compilation unit.
- CompoundAssignmentExpression
- A potentially compound assignment.
- ConditionalExpression
- A conditional expression.
- Configuration
- A configuration in either an import or export directive.
- ConstructorDeclaration
- A constructor declaration.
- ConstructorFieldInitializer
- The initialization of a field within a constructor's initialization list.
- ConstructorInitializer
- A node that can occur in the initializer list of a constructor declaration.
- ConstructorName
- The name of a constructor.
- ConstructorReference
-
An expression representing a reference to a constructor, e.g. the expression
List.filled
invar x = List.filled;
. - ConstructorReferenceNode
- An AST node that makes reference to a constructor.
- ConstructorSelector
- The name of a constructor being invoked.
- ContinueStatement
- A continue statement.
- Declaration
- A node that represents the declaration of one or more names.
- DeclaredIdentifier
- The declaration of a single identifier.
- DefaultFormalParameter
- A formal parameter with a default value.
- Directive
- A node that represents a directive.
- DoStatement
- A do statement.
- DottedName
- A dotted name, used in a configuration within an import or export directive.
- DoubleLiteral
- A floating point literal expression.
- EmptyFunctionBody
- An empty function body, which can only appear in constructors or abstract methods.
- EmptyStatement
- An empty statement.
- EnumConstantArguments
- The arguments part of an enum constant.
- EnumConstantDeclaration
- The declaration of an enum constant.
- EnumDeclaration
- The declaration of an enumeration.
- ExportDirective
- An export directive.
- Expression
- A node that represents an expression.
- ExpressionFunctionBody
- A function body consisting of a single expression.
- ExpressionStatement
- An expression used as a statement.
- ExtendsClause
- The "extends" clause in a class declaration.
- ExtensionDeclaration
- The declaration of an extension of a type.
- ExtensionOverride
- An override to force resolution to choose a member from a specific extension.
- FieldDeclaration
- The declaration of one or more fields of the same type.
- FieldFormalParameter
- A field formal parameter.
- ForEachParts
- The parts of a for-each loop that control the iteration.
- ForEachPartsWithDeclaration
- The parts of a for-each loop that control the iteration when the loop variable is declared as part of the for loop.
- ForEachPartsWithIdentifier
- The parts of a for-each loop that control the iteration when the loop variable is declared outside of the for loop.
- ForElement
- The basic structure of a for element.
- ForLoopParts
- The parts of a for or for-each loop that control the iteration.
- FormalParameter
- A node representing a parameter to a function.
- FormalParameterList
- The formal parameter list of a method declaration, function declaration, or function type alias.
- ForParts
- The parts of a for loop that control the iteration.
- ForPartsWithDeclarations
- The parts of a for loop that control the iteration when there are one or more variable declarations as part of the for loop.
- ForPartsWithExpression
- The parts of a for loop that control the iteration when there are no variable declarations as part of the for loop.
- ForStatement
- A for or for-each statement.
- FunctionBody
- A node representing the body of a function or method.
- FunctionDeclaration
- A top-level function declaration.
- FunctionDeclarationStatement
- A FunctionDeclaration used as a statement.
- FunctionExpression
- A function expression.
- FunctionExpressionInvocation
- The invocation of a function resulting from evaluating an expression.
- FunctionReference
-
An expression representing a reference to a function, possibly with type
arguments applied to it, e.g. the expression
print
invar x = print;
. - FunctionTypeAlias
- A function type alias.
- FunctionTypedFormalParameter
- A function-typed formal parameter.
- GenericFunctionType
- An anonymous function type.
- GenericTypeAlias
- A generic type alias.
- HideClause
- The "hide" clause in an extension declaration.
- HideCombinator
- A combinator that restricts the names being imported to those that are not in a given list.
- Identifier
- A node that represents an identifier.
- IfElement
- The basic structure of an if element.
- IfStatement
- An if statement.
- ImplementsClause
- The "implements" clause in an class declaration.
- ImplicitCallReference
- An expression representing an implicit 'call' method reference.
- ImportDirective
- An import directive.
- IndexExpression
- An index expression.
- InstanceCreationExpression
- An instance creation expression.
- IntegerLiteral
- An integer literal expression.
- InterpolationElement
- A node within a StringInterpolation.
- InterpolationExpression
- An expression embedded in a string interpolation.
- InterpolationString
- A non-empty substring of an interpolated string.
- InvocationExpression
- The invocation of a function or method; either a FunctionExpressionInvocation or a MethodInvocation.
- IsExpression
- An is expression.
- Label
- A label on either a LabeledStatement or a NamedExpression.
- LabeledStatement
- A statement that has a label associated with them.
- LibraryDirective
- A library directive.
- LibraryIdentifier
- The identifier for a library.
- ListLiteral
- A list literal.
- Literal
- A node that represents a literal expression.
- MapLiteralEntry
- A single key/value pair in a map literal.
- MethodDeclaration
- A method declaration.
- MethodInvocation
- The invocation of either a function or a method.
- MethodReferenceExpression
- An expression that implicitly makes reference to a method.
- MixinDeclaration
- The declaration of a mixin.
- NamedCompilationUnitMember
- A node that declares a single name within the scope of a compilation unit.
- NamedExpression
- An expression that has a name associated with it. They are used in method invocations when there are named parameters.
- NamedType
- A named type, which can optionally include type arguments.
- NamespaceDirective
- A node that represents a directive that impacts the namespace of a library.
- NativeClause
- The "native" clause in an class declaration.
- NativeFunctionBody
- A function body that consists of a native keyword followed by a string literal.
-
NodeList<
E extends AstNode> - A list of AST nodes that have a common parent.
- NormalFormalParameter
- A formal parameter that is required (is not optional).
- NullLiteral
- A null literal expression.
- NullShortableExpression
- Abstract interface for expressions that may participate in null-shorting.
- OnClause
- The "on" clause in a mixin declaration.
- ParenthesizedExpression
- A parenthesized expression.
- PartDirective
- A part directive.
- PartOfDirective
- A part-of directive.
- PostfixExpression
- A postfix unary expression.
- PrefixedIdentifier
- An identifier that is prefixed or an access to an object property where the target of the property access is a simple identifier.
- PrefixExpression
- A prefix unary expression.
- PropertyAccess
- The access of a property of an object.
- RedirectingConstructorInvocation
- The invocation of a constructor in the same class from within a constructor's initialization list.
- RethrowExpression
- A rethrow expression.
- ReturnStatement
- A return statement.
- ScriptTag
- A script tag that can optionally occur at the beginning of a compilation unit.
- SetOrMapLiteral
- A set or map literal.
- ShowClause
- The "show" clause in an extension declaration.
- ShowCombinator
- A combinator that restricts the names being imported to those in a given list.
- ShowHideClauseElement
- A node that can appear in the show or hide clauses.
- ShowHideElement
- A potentially non-type element of a show or a hide clause.
- SimpleFormalParameter
- A simple formal parameter.
- SimpleIdentifier
- A simple identifier.
- SimpleStringLiteral
- A string literal expression that does not contain any interpolations.
- SingleStringLiteral
- A single string literal expression.
- SpreadElement
- A spread element.
- Statement
- A node that represents a statement.
- StringInterpolation
- A string interpolation literal.
- StringLiteral
- A string literal expression.
- SuperConstructorInvocation
- The invocation of a superclass' constructor from within a constructor's initialization list.
- SuperExpression
- A super expression.
- SuperFormalParameter
- A super-initializer formal parameter.
- SwitchCase
- A case in a switch statement.
- SwitchDefault
- The default case in a switch statement.
- SwitchMember
- An element within a switch statement.
- SwitchStatement
- A switch statement.
- SymbolLiteral
- A symbol literal expression.
- ThisExpression
- A this expression.
- ThrowExpression
- A throw expression.
- TopLevelVariableDeclaration
- The declaration of one or more top-level variables of the same type.
- TryStatement
- A try statement.
- TypeAlias
- The declaration of a type alias.
- TypeAnnotation
- A type annotation.
- TypeArgumentList
- A list of type arguments.
- TypedLiteral
- A literal that has a type associated with it.
- TypeLiteral
-
An expression representing a type, e.g. the expression
int
invar x = int;
. - TypeParameter
- A type parameter.
- TypeParameterList
- Type parameters within a declaration.
- UriBasedDirective
- A directive that references a URI.
- VariableDeclaration
- An identifier that has an initial value associated with it.
- VariableDeclarationList
- The declaration of one or more variables of the same type.
- VariableDeclarationStatement
- A list of variables that are being declared in a context where a statement is required.
- WhileStatement
- A while statement.
- WithClause
- The with clause in a class declaration.
- YieldStatement
- A yield statement.