tom_d4rt_astgen library
AST Generator - Converts from Dart analyzer AST to serializable AST
This library depends on the analyzer package. Use this to convert from analyzer AST to the pure serializable AST model.
Classes
- AstBundler
- AstBundlerConfig
- Configuration for AstBundler import resolution behavior.
- AstConverter
- Converts Dart analyzer AST nodes to serializable AST nodes
- BundleTarget
- The platform a bundle is built for, as conditional imports see it.
-
GeneralizingSAstVisitor<
T> - A visitor that adds category-level fallback methods between specific visit methods and visitNode.
- ImportResolution
- Result of resolving a single import URI.
- SAdjacentStrings
- SAnnotatedNode
-
Base class for nodes that have documentation comments and metadata.
Mirrors analyzer's
AnnotatedNode. - SAnnotation
- SArgument
-
An entry of an argument list: an expression or a SNamedArgument.
Mirrors analyzer's
Argument. - SArgumentList
- SAsExpression
- SAssertInitializer
- SAssertStatement
- SAssignedVariablePattern
- An assigned variable pattern that binds to an existing variable.
- SAssignmentExpression
- SAstNode
- Base class for all serializable AST nodes
- SAstNodeFactory
- Factory for deserializing AST nodes
-
SAstVisitor<
T> - A visitor for the serializable AST node hierarchy.
- SAwaitExpression
- SBinaryExpression
- SBlock
- SBlockClassBody
-
A class body in braces. Mirrors analyzer's
BlockClassBody. - SBlockEnumBody
-
An enum body in braces. Mirrors analyzer's
BlockEnumBody. - SBlockFunctionBody
- SBooleanLiteral
- SBreakStatement
- SCascadeExpression
- SCaseClause
-
A
caseclause used in if-case statements. - SCastPattern
-
A cast pattern (e.g.,
pattern as Type). - SCatchClause
- SClassBody
-
The members of a class, mixin, extension or extension type. Mirrors
analyzer's
ClassBody. - SClassDeclaration
-
A class declaration. Mirrors analyzer's
ClassDeclaration. - SClassMember
-
Base class for class members (methods, fields, constructors).
Mirrors analyzer's
ClassMember. - SClassNamePart
-
The name of a class-like declaration with its type parameters:
Foo<T>, or for an extension type its primary constructorFoo<T>(int it). Mirrors analyzer'sClassNamePart. - SCollectionElement
-
Base class for collection elements (expressions, spread, if/for elements, map entries).
Mirrors analyzer's
CollectionElement. - SCombinator
-
Base class for show/hide combinators on directives.
Mirrors analyzer's
Combinator. - SComment
- SCompilationUnit
- A complete Dart compilation unit (file)
- SCompilationUnitMember
-
Base class for compilation unit members (top-level declarations).
Mirrors analyzer's
CompilationUnitMember. - SConditionalExpression
- SConfiguration
-
One conditional branch of an import or export directive:
if (dart.library.io) 'io.dart', or with an explicit test value,if (dart.library.io == 'true') 'io.dart'. - SConstantPattern
-
A constant expression pattern (e.g.,
case 42:,case const Foo():). - SConstructorDeclaration
- SConstructorFieldInitializer
- SConstructorInitializer
-
Base class for constructor initializers.
Mirrors analyzer's
ConstructorInitializer. - SConstructorName
- SConstructorReference
-
A constructor reference expression:
MyClass.neworMyClass<T>.named - SContinueStatement
- SDartPattern
-
Base class for Dart patterns (Dart 3 pattern matching).
Mirrors analyzer's
DartPattern. - SDeclaration
-
Base class for all declarations.
Mirrors analyzer's
Declaration. - SDeclaredIdentifier
- Declared identifier in a for-each loop
- SDeclaredVariablePattern
-
A declared variable pattern (e.g.,
var x,int x,final String name). - SDirective
-
Base class for all directives (import, export, part, library).
Mirrors analyzer's
Directive. - SDoStatement
- SDottedName
-
A dotted name — the left-hand side of a configuration's condition, as in
dart.library.io. - SDoubleLiteral
- SEmptyClassBody
-
The body
;of a class-like declaration without members. Mirrors analyzer'sEmptyClassBody. - SEmptyEnumBody
-
The body
;of an enum without constants or members (invalid code). Mirrors analyzer'sEmptyEnumBody. - SEmptyFunctionBody
- SEmptyStatement
- SEnumBody
-
The constants and members of an enum. Mirrors analyzer's
EnumBody. - SEnumConstantDeclaration
- SEnumDeclaration
-
An enum declaration. Mirrors analyzer's
EnumDeclaration. - SExportDirective
- SExpression
-
Base class for all expressions. Extends CollectionElement because
expressions can appear in collection literals.
Mirrors analyzer's
Expression. - SExpressionFunctionBody
- SExpressionStatement
- SExtendsClause
- SExtensionCallFact
- An extension member access: the receiver's static type, the extension it resolves to and the extension's type arguments (all type references are indices into SStaticFacts.types).
- SExtensionDeclaration
-
An extension declaration. Mirrors analyzer's
ExtensionDeclaration. - SExtensionTypeDeclaration
-
An extension type declaration, such as
extension type const Foo<T>(int it) implements int { ... }. Mirrors analyzer'sExtensionTypeDeclaration. - SFactsStamp
- What a facts table was computed against: the Dart SDK and the versions of the packages its types come from.
- SFactType
- A type in a facts table: a structured reference the runtime resolves to its own runtime type (by library URI and name), interned in SStaticFacts.types.
- SFieldDeclaration
- SFieldFormalParameter
-
A field-initializing parameter:
this.x. Mirrors analyzer'sFieldFormalParameter. - SForEachParts
-
Base class for for-each loop parts.
Mirrors analyzer's
ForEachParts. - SForEachPartsWithDeclaration
- For-each loop parts with a declaration
- SForEachPartsWithIdentifier
- For-each loop parts with an identifier
- SForEachPartsWithPattern
- For-each loop parts with a pattern destructuring on each element.
- SForEachStatement
- SForElement
- SForLoopParts
-
Base class for for-loop parts.
Mirrors analyzer's
ForLoopParts. - SFormalParameter
-
Base class for formal parameters. Mirrors analyzer's
FormalParameter, which holds every parameter's fields itself: the kind subclasses (SRegularFormalParameter, SFieldFormalParameter, SSuperFormalParameter) add nothing but their kind. - SFormalParameterDefaultClause
-
The default clause of an optional parameter:
= value(or: valuein old named-parameter syntax). Mirrors analyzer'sFormalParameterDefaultClause. - SFormalParameterList
- SForParts
-
Base class for traditional for-loop parts.
Mirrors analyzer's
ForParts. - SForPartsWithDeclarations
- For loop parts for standard for loops
- SForPartsWithExpression
- For loop parts with an expression initializer
- SForStatement
- SFunctionBody
-
Base class for function bodies.
Mirrors analyzer's
FunctionBody. - SFunctionDeclaration
- SFunctionDeclarationStatement
- SFunctionExpression
- SFunctionExpressionInvocation
- SFunctionReference
-
A function reference expression:
myFunc<int>(tear-off with type args) - SFunctionTypedFormalParameterSuffix
-
What follows the name of a function-typed parameter:
<T>(params)?inint cb<T>(T x)?. Mirrors analyzer'sFunctionTypedFormalParameterSuffix; the parameter'stypeis then the function's return type. - SGenericFunctionType
- SGuardedPattern
-
A pattern with an optional
whenguard clause. - SHideCombinator
- SIdentifier
-
Base class for identifiers (simple and prefixed).
Mirrors analyzer's
Identifier. - SIfElement
- SIfStatement
- SImplementsClause
- SImportDirective
- SIndexExpression
- SInstanceCreationExpression
- SIntegerLiteral
- SInterpolationElement
-
Base class for string interpolation elements.
Mirrors analyzer's
InterpolationElement. - SInterpolationExpression
- SInterpolationString
- SInvocationExpression
-
Base class for invocation expressions (method calls, function calls).
Mirrors analyzer's
InvocationExpression. - SIsExpression
- SLabel
-
A label declaration:
name:before a statement or switch member. Mirrors analyzer'sLabel. - SLabeledStatement
- SLabelReference
-
The label a
breakorcontinuenames. Mirrors analyzer'sLabelReference. - SLibraryDirective
- SListLiteral
- SListPattern
-
A list destructuring pattern (e.g.,
[a, b, ...rest]). - SLiteral
-
Base class for all literals.
Mirrors analyzer's
Literal. - SLogicalAndPattern
-
A logical AND pattern (e.g.,
pattern1 && pattern2). - SLogicalOrPattern
-
A logical OR pattern (e.g.,
pattern1 || pattern2). - SMapLiteralEntry
- SMapPattern
-
A map destructuring pattern (e.g.,
{'key': valuePattern}). - SMapPatternEntry
-
A single entry in a map pattern (e.g.,
key: valuePattern). - SMethodDeclaration
- SMethodInvocation
- SMixinDeclaration
-
A mixin declaration. Mirrors analyzer's
MixinDeclaration. - SNamedArgument
-
A named argument:
name: expression. Mirrors analyzer'sNamedArgument. - SNamedType
- SNamespaceDirective
-
Base class for namespace directives (import, export).
Mirrors analyzer's
NamespaceDirective. - SNameWithTypeParameters
-
A plain class name part:
Foo<T>. Mirrors analyzer'sNameWithTypeParameters. - SNativeFunctionBody
- SNullAssertPattern
-
A null-assert pattern (e.g.,
pattern!). - SNullAwareElement
-
Represents a null-aware element in a collection literal (
?expr). - SNullCheckPattern
-
A null-check pattern (e.g.,
pattern?). - SNullLiteral
- SObjectPattern
-
An object destructuring pattern (e.g.,
MyType(field: pattern)). - SOnClause
- SParenthesizedExpression
- SParenthesizedPattern
-
A parenthesized pattern (e.g.,
(pattern)). - SPartDirective
- SPartOfDirective
- SPatternAssignment
-
A pattern assignment expression:
(a, b) = expr - SPatternField
- A field in an object or record pattern.
- SPatternFieldName
- A field name identifier in a pattern field (null name for shorthand).
- SPatternVariableDeclaration
-
A pattern variable declaration (e.g.,
var (a, b) = expr). - SPatternVariableDeclarationStatement
-
A pattern variable declaration statement:
var (a, b) = expr; - SPostfixExpression
- SPrefixedIdentifier
- SPrefixExpression
- SPrimaryConstructorDeclaration
-
A primary constructor as a class name part:
const Foo<T>.named(int it). Mirrors analyzer'sPrimaryConstructorDeclaration. - SPropertyAccess
- SRecordLiteral
- SRecordLiteralField
-
A field of a record literal: an expression or a
SRecordLiteralNamedField. Mirrors analyzer's
RecordLiteralField. - SRecordLiteralNamedField
-
A named field of a record literal:
name: expression. Mirrors analyzer'sRecordLiteralNamedField. - SRecordPattern
-
A record destructuring pattern (e.g.,
(pattern, name: pattern)). - SRecordTypeAnnotation
- SRecordTypeField
-
A single field of a record type ANNOTATION —
intorString labelin(int, {String label}). - SRedirectingConstructorInvocation
- SRegularFormalParameter
-
A parameter declared by name:
int x,[int x = 0],{required int x},int cb(String s). Mirrors analyzer'sRegularFormalParameter. - SRelationalPattern
-
A relational pattern (e.g.,
< 5,>= 10). - SRestPatternElement
-
A rest element in a list or map pattern (e.g.,
...subPattern). - SRethrowExpression
- SReturnStatement
- SSetOrMapLiteral
- SShowCombinator
- SSimpleIdentifier
- SSimpleStringLiteral
- SSingleStringLiteral
-
Base class for single string literals (non-adjacent).
Mirrors analyzer's
SingleStringLiteral. - SSpreadElement
- SStatement
-
Base class for all statements.
Mirrors analyzer's
Statement. - SStaticFact
- One fact about one node.
- SStaticFacts
- A bundle's facts table. See the library comment.
- SStaticFactsBuilder
- Builds an SStaticFacts table, interning its types.
- SStringInterpolation
- SStringLiteral
-
Base class for string literals.
Mirrors analyzer's
StringLiteral. - SSuperConstructorInvocation
- SSuperExpression
- SSuperFormalParameter
-
A super-forwarding parameter:
super.x. Mirrors analyzer'sSuperFormalParameter. - SSwitchCase
- SSwitchDefault
- SSwitchExpression
-
A switch expression:
switch (expr) { case1 => val1, ... } - SSwitchExpressionCase
-
A case in a switch expression (e.g.,
pattern => expression). - SSwitchMember
-
Base class for switch case/default members.
Mirrors analyzer's
SwitchMember. - SSwitchPatternCase
- A Dart 3.0 switch statement case with pattern matching.
- SSwitchStatement
- SSymbolLiteral
- StaticResolver
- Static lexical resolver (plan_3 §4.4 / §9 S1–S2), operating directly on the serializable mirror AST.
- SThisExpression
- SThrowExpression
- SToken
- Serializable token representation
- STopLevelVariableDeclaration
- STryStatement
- STypeAnnotation
-
Base class for type annotations.
Mirrors analyzer's
TypeAnnotation. - STypeArgumentList
- STypeArgumentsFact
- The inferred type arguments of a generic call, an instance creation or a collection literal that does not write them (indices into SStaticFacts.types).
- STypedefDeclaration
- STypedLiteral
-
Base class for typed literals (list, set/map).
Mirrors analyzer's
TypedLiteral. - STypeParameter
- STypeParameterList
- SUriBasedDirective
-
Base class for uri-based directives (import, export, part).
Mirrors analyzer's
UriBasedDirective. - SVariableDeclaration
- SVariableDeclarationList
- SVariableDeclarationStatement
- SVariablePattern
-
Base class for variable patterns.
Mirrors analyzer's
VariablePattern. - SWhenClause
-
A
whenclause that guards a pattern with a boolean expression. - SWhileStatement
- SWildcardPattern
-
A wildcard pattern
_, optionally typed (e.g.,int _,var _). - SWithClause
- SYieldStatement
Enums
- ImportAction
- Outcome of resolving a single import URI.
- SFactTypeKind
- The kind of an SFactType.
Mixins
- SFunctionBodyOwner
- Mixin for declarations with a function body
- SNamedDeclaration
- Mixin for named declarations
Functions
-
opensLexicalFrame(
SAstNode node) → bool -
Does
nodeopen a new runtimeEnvironmentframe?
Typedefs
- FileAccessValidator = bool Function(String canonicalPath)
-
Creates
AstBundles from Dart source code by parsing the entry point and recursively resolving all imports.