diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart index 26a9af5c403..e00ec2a81a5 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart @@ -19,7 +19,6 @@ import 'package:analysis_server/src/services/completion/dart/contribution_sorter import 'package:analysis_server/src/services/completion/dart/optype.dart'; import 'package:analysis_server/src/services/search/search_engine.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/ast/standard_ast_factory.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; @@ -517,8 +516,7 @@ class ReplacementRange { } } if (token is StringToken) { - SimpleStringLiteral uri = - astFactory.simpleStringLiteral(token, token.lexeme); + SimpleStringLiteral uri = new SimpleStringLiteral(token, token.lexeme); Keyword keyword = token.previous?.keyword; if (keyword == Keyword.IMPORT || keyword == Keyword.EXPORT || diff --git a/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart index a540887fd60..8600be2e9ea 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart @@ -15,7 +15,6 @@ import 'package:analysis_server/src/services/completion/dart/local_declaration_v show LocalDeclarationVisitor; import 'package:analysis_server/src/services/completion/dart/optype.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/ast/standard_ast_factory.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/src/dart/ast/token.dart'; import 'package:analyzer/src/generated/source.dart'; @@ -25,9 +24,8 @@ import '../../../protocol_server.dart' const DYNAMIC = 'dynamic'; -final TypeName NO_RETURN_TYPE = astFactory.typeName( - astFactory.simpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), - null); +final TypeName NO_RETURN_TYPE = new TypeName( + new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), null); /** * Create a new protocol Element for inclusion in a completion suggestion. diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart index cef91def59f..8778f6c22ef 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart @@ -16,7 +16,6 @@ import 'package:analysis_server/src/services/completion/dart/local_declaration_v import 'package:analysis_server/src/services/completion/dart/optype.dart'; import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/ast/standard_ast_factory.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/src/dart/ast/token.dart'; @@ -27,9 +26,8 @@ import '../../../protocol_server.dart' const DYNAMIC = 'dynamic'; -final TypeName NO_RETURN_TYPE = astFactory.typeName( - astFactory.simpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), - null); +final TypeName NO_RETURN_TYPE = new TypeName( + new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), null); /** * Create a new protocol Element for inclusion in a completion suggestion. diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart index adf26c7ab6f..f0c2b3a1192 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart @@ -5,7 +5,6 @@ library services.completion.dart.local.declaration.visitor; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/ast/standard_ast_factory.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/src/dart/ast/token.dart'; @@ -16,8 +15,8 @@ import 'package:analyzer/src/dart/ast/token.dart'; * which catches the exception thrown by [finished()]. */ abstract class LocalDeclarationVisitor extends GeneralizingAstVisitor { - static final TypeName STACKTRACE_TYPE = astFactory.typeName( - astFactory.simpleIdentifier( + static final TypeName STACKTRACE_TYPE = new TypeName( + new SimpleIdentifier( new StringToken(TokenType.IDENTIFIER, 'StackTrace', 0)), null); diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart index 01298f86515..70b2b448e4e 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart @@ -17,7 +17,6 @@ import 'package:analysis_server/src/services/completion/dart/optype.dart'; import 'package:analysis_server/src/services/correction/strings.dart'; import 'package:analysis_server/src/utilities/documentation.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/ast/standard_ast_factory.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; @@ -30,9 +29,8 @@ import '../../../protocol_server.dart' const DYNAMIC = 'dynamic'; -final TypeName NO_RETURN_TYPE = astFactory.typeName( - astFactory.simpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), - null); +final TypeName NO_RETURN_TYPE = new TypeName( + new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), null); /** * Create a new protocol Element for inclusion in a completion suggestion. diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md index 8449bf03c20..e7a9e48b5f4 100644 --- a/pkg/analyzer/CHANGELOG.md +++ b/pkg/analyzer/CHANGELOG.md @@ -2,7 +2,6 @@ * Changed the API for creating BazelWorkspace. It should now be constructed using BazelWorkspace.find(). Note that this might return `null` in the event that the given path is not part of a BazelWorkspace. * Added an AST structure to support asserts in constructor initializers (AssertInitializer). AstVisitor classes must now implement visitAssertInitializer(). * Changed the API for creating PartOfDirective. It now accepts a StringLiteral URI, to accomodate "part of" declarations with a URI string rather than a library name. -* Removed AST constructors. AST nodes should now be created using `astFactory`, located in `package:analyzer/dart/ast/standard_ast_factory.dart`. ## 0.29.0-alpha.0 * Removed `Element.docRange`. diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart index 78b3c0668b5..c36925f0d17 100644 --- a/pkg/analyzer/lib/dart/ast/ast.dart +++ b/pkg/analyzer/lib/dart/ast/ast.dart @@ -40,6 +40,7 @@ import 'package:analyzer/dart/ast/syntactic_entity.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/src/dart/ast/ast.dart'; import 'package:analyzer/src/dart/element/element.dart' show AuxiliaryElements; import 'package:analyzer/src/generated/java_engine.dart'; import 'package:analyzer/src/generated/source.dart' show LineInfo, Source; @@ -59,6 +60,12 @@ import 'package:analyzer/src/generated/utilities_dart.dart'; * Clients may not extend, implement or mix-in this class. */ abstract class AdjacentStrings extends StringLiteral { + /** + * Initialize a newly created list of adjacent strings. To be syntactically + * valid, the list of [strings] must contain at least two elements. + */ + factory AdjacentStrings(List strings) = AdjacentStringsImpl; + /** * Return the strings that are implicitly concatenated. */ @@ -113,6 +120,16 @@ abstract class AnnotatedNode extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class Annotation extends AstNode { + /** + * Initialize a newly created annotation. Both the [period] and the + * [constructorName] can be `null` if the annotation is not referencing a + * named constructor. The [arguments] can be `null` if the annotation is not + * referencing a constructor. + */ + factory Annotation(Token atSign, Identifier name, Token period, + SimpleIdentifier constructorName, ArgumentList arguments) => + new AnnotationImpl(atSign, name, period, constructorName, arguments); + /** * Return the arguments to the constructor being invoked, or `null` if this * annotation is not the invocation of a constructor. @@ -206,6 +223,13 @@ abstract class Annotation extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class ArgumentList extends AstNode { + /** + * Initialize a newly created list of arguments. The list of [arguments] can + * be `null` if there are no arguments. + */ + factory ArgumentList(Token leftParenthesis, List arguments, + Token rightParenthesis) = ArgumentListImpl; + /** * Return the expressions producing the values of the arguments. Although the * language requires that positional arguments appear before named arguments, @@ -259,6 +283,13 @@ abstract class ArgumentList extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class AsExpression extends Expression { + /** + * Initialize a newly created as expression. + */ + factory AsExpression( + Expression expression, Token asOperator, TypeName type) => + new AsExpressionImpl(expression, asOperator, type); + /** * Return the 'as' operator. */ @@ -299,7 +330,21 @@ abstract class AsExpression extends Expression { * * Clients may not extend, implement or mix-in this class. */ -abstract class AssertInitializer implements Assertion, ConstructorInitializer {} +abstract class AssertInitializer implements Assertion, ConstructorInitializer { + /** + * Initialize a newly created assert initializer. The [comma] and [message] + * can be `null` if there is no message. + */ + factory AssertInitializer( + Token assertKeyword, + Token leftParenthesis, + Expression condition, + Token comma, + Expression message, + Token rightParenthesis) => + new AssertInitializerImpl(assertKeyword, leftParenthesis, condition, + comma, message, rightParenthesis); +} /** * An assertion, either in a block or in the initializer list of a constructor. @@ -382,6 +427,21 @@ abstract class Assertion implements AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class AssertStatement implements Assertion, Statement { + /** + * Initialize a newly created assert statement. The [comma] and [message] can + * be `null` if there is no message. + */ + factory AssertStatement( + Token assertKeyword, + Token leftParenthesis, + Expression condition, + Token comma, + Expression message, + Token rightParenthesis, + Token semicolon) => + new AssertStatementImpl(assertKeyword, leftParenthesis, condition, comma, + message, rightParenthesis, semicolon); + /** * Return the semicolon terminating the statement. */ @@ -403,6 +463,13 @@ abstract class AssertStatement implements Assertion, Statement { */ abstract class AssignmentExpression extends Expression implements MethodReferenceExpression { + /** + * Initialize a newly created assignment expression. + */ + factory AssignmentExpression( + Expression leftHandSide, Token operator, Expression rightHandSide) => + new AssignmentExpressionImpl(leftHandSide, operator, rightHandSide); + /** * Return the expression used to compute the left hand side. */ @@ -788,6 +855,12 @@ abstract class AstVisitor { * Clients may not extend, implement or mix-in this class. */ abstract class AwaitExpression extends Expression { + /** + * Initialize a newly created await expression. + */ + factory AwaitExpression(Token awaitKeyword, Expression expression) => + new AwaitExpressionImpl(awaitKeyword, expression); + /** * Return the 'await' keyword. */ @@ -819,6 +892,13 @@ abstract class AwaitExpression extends Expression { */ abstract class BinaryExpression extends Expression implements MethodReferenceExpression { + /** + * Initialize a newly created binary expression. + */ + factory BinaryExpression( + Expression leftOperand, Token operator, Expression rightOperand) => + new BinaryExpressionImpl(leftOperand, operator, rightOperand); + /** * Return the expression used to compute the left operand. */ @@ -861,6 +941,13 @@ abstract class BinaryExpression extends Expression * Clients may not extend, implement or mix-in this class. */ abstract class Block extends Statement { + /** + * Initialize a newly created block of code. + */ + factory Block( + Token leftBracket, List statements, Token rightBracket) => + new BlockImpl(leftBracket, statements, rightBracket); + /** * Return the left curly bracket. */ @@ -896,6 +983,15 @@ abstract class Block extends Statement { * Clients may not extend, implement or mix-in this class. */ abstract class BlockFunctionBody extends FunctionBody { + /** + * Initialize a newly created function body consisting of a block of + * statements. The [keyword] can be `null` if there is no keyword specified + * for the block. The [star] can be `null` if there is no star following the + * keyword (and must be `null` if there is no keyword). + */ + factory BlockFunctionBody(Token keyword, Token star, Block block) => + new BlockFunctionBodyImpl(keyword, star, block); + /** * Return the block representing the body of the function. */ @@ -926,6 +1022,11 @@ abstract class BlockFunctionBody extends FunctionBody { * Clients may not extend, implement or mix-in this class. */ abstract class BooleanLiteral extends Literal { + /** + * Initialize a newly created boolean literal. + */ + factory BooleanLiteral(Token literal, bool value) = BooleanLiteralImpl; + /** * Return the token representing the literal. */ @@ -951,6 +1052,14 @@ abstract class BooleanLiteral extends Literal { * Clients may not extend, implement or mix-in this class. */ abstract class BreakStatement extends Statement { + /** + * Initialize a newly created break statement. The [label] can be `null` if + * there is no label associated with the statement. + */ + factory BreakStatement( + Token breakKeyword, SimpleIdentifier label, Token semicolon) => + new BreakStatementImpl(breakKeyword, label, semicolon); + /** * Return the token representing the 'break' keyword. */ @@ -1019,6 +1128,14 @@ abstract class BreakStatement extends Statement { * Clients may not extend, implement or mix-in this class. */ abstract class CascadeExpression extends Expression { + /** + * Initialize a newly created cascade expression. The list of + * [cascadeSections] must contain at least one element. + */ + factory CascadeExpression( + Expression target, List cascadeSections) => + new CascadeExpressionImpl(target, cascadeSections); + /** * Return the cascade sections sharing the common target. */ @@ -1048,6 +1165,33 @@ abstract class CascadeExpression extends Expression { * Clients may not extend, implement or mix-in this class. */ abstract class CatchClause extends AstNode { + /** + * Initialize a newly created catch clause. The [onKeyword] and + * [exceptionType] can be `null` if the clause will catch all exceptions. The + * [comma] and [stackTraceParameter] can be `null` if the stack trace + * parameter is not defined. + */ + factory CatchClause( + Token onKeyword, + TypeName exceptionType, + Token catchKeyword, + Token leftParenthesis, + SimpleIdentifier exceptionParameter, + Token comma, + SimpleIdentifier stackTraceParameter, + Token rightParenthesis, + Block body) => + new CatchClauseImpl( + onKeyword, + exceptionType, + catchKeyword, + leftParenthesis, + exceptionParameter, + comma, + stackTraceParameter, + rightParenthesis, + body); + /** * Return the body of the catch block. */ @@ -1161,6 +1305,43 @@ abstract class CatchClause extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class ClassDeclaration extends NamedCompilationUnitMember { + /** + * Initialize a newly created class declaration. Either or both of the + * [comment] and [metadata] can be `null` if the class does not have the + * corresponding attribute. The [abstractKeyword] can be `null` if the class + * is not abstract. The [typeParameters] can be `null` if the class does not + * have any type parameters. Any or all of the [extendsClause], [withClause], + * and [implementsClause] can be `null` if the class does not have the + * corresponding clause. The list of [members] can be `null` if the class does + * not have any members. + */ + factory ClassDeclaration( + Comment comment, + List metadata, + Token abstractKeyword, + Token classKeyword, + SimpleIdentifier name, + TypeParameterList typeParameters, + ExtendsClause extendsClause, + WithClause withClause, + ImplementsClause implementsClause, + Token leftBracket, + List members, + Token rightBracket) => + new ClassDeclarationImpl( + comment, + metadata, + abstractKeyword, + classKeyword, + name, + typeParameters, + extendsClause, + withClause, + implementsClause, + leftBracket, + members, + rightBracket); + /** * Return the 'abstract' keyword, or `null` if the keyword was absent. */ @@ -1308,6 +1489,39 @@ abstract class ClassMember extends Declaration {} * Clients may not extend, implement or mix-in this class. */ abstract class ClassTypeAlias extends TypeAlias { + /** + * Initialize a newly created class type alias. Either or both of the + * [comment] and [metadata] can be `null` if the class type alias does not + * have the corresponding attribute. The [typeParameters] can be `null` if the + * class does not have any type parameters. The [abstractKeyword] can be + * `null` if the class is not abstract. The [implementsClause] can be `null` + * if the class does not implement any interfaces. + */ + factory ClassTypeAlias( + Comment comment, + List metadata, + Token keyword, + SimpleIdentifier name, + TypeParameterList typeParameters, + Token equals, + Token abstractKeyword, + TypeName superclass, + WithClause withClause, + ImplementsClause implementsClause, + Token semicolon) => + new ClassTypeAliasImpl( + comment, + metadata, + keyword, + name, + typeParameters, + equals, + abstractKeyword, + superclass, + withClause, + implementsClause, + semicolon); + /** * Return the token for the 'abstract' keyword, or `null` if this is not * defining an abstract class. @@ -1423,6 +1637,15 @@ abstract class Combinator extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class Comment extends AstNode { + /** + * Initialize a newly created comment. The list of [tokens] must contain at + * least one token. The [type] is the type of the comment. The list of + * [references] can be empty if the comment does not contain any embedded + * references. + */ + factory Comment(List tokens, CommentType type, + List references) = CommentImpl; + /** * Return `true` if this is a block comment. */ @@ -1447,6 +1670,32 @@ abstract class Comment extends AstNode { * Return the tokens representing the comment. */ List get tokens; + + /** + * Create a block comment consisting of the given [tokens]. + */ + static Comment createBlockComment(List tokens) => + CommentImpl.createBlockComment(tokens); + + /** + * Create a documentation comment consisting of the given [tokens]. + */ + static Comment createDocumentationComment(List tokens) => + CommentImpl.createDocumentationComment(tokens); + + /** + * Create a documentation comment consisting of the given [tokens] and having + * the given [references] embedded within it. + */ + static Comment createDocumentationCommentWithReferences( + List tokens, List references) => + CommentImpl.createDocumentationCommentWithReferences(tokens, references); + + /** + * Create an end-of-line comment consisting of the given [tokens]. + */ + static Comment createEndOfLineComment(List tokens) => + CommentImpl.createEndOfLineComment(tokens); } /** @@ -1458,6 +1707,13 @@ abstract class Comment extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class CommentReference extends AstNode { + /** + * Initialize a newly created reference to a Dart element. The [newKeyword] + * can be `null` if the reference is not to a constructor. + */ + factory CommentReference(Token newKeyword, Identifier identifier) => + new CommentReferenceImpl(newKeyword, identifier); + /** * Return the identifier being referenced. */ @@ -1506,6 +1762,22 @@ abstract class CommentReference extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class CompilationUnit extends AstNode { + /** + * Initialize a newly created compilation unit to have the given directives + * and declarations. The [scriptTag] can be `null` if there is no script tag + * in the compilation unit. The list of [directives] can be `null` if there + * are no directives in the compilation unit. The list of [declarations] can + * be `null` if there are no declarations in the compilation unit. + */ + factory CompilationUnit( + Token beginToken, + ScriptTag scriptTag, + List directives, + List declarations, + Token endToken) => + new CompilationUnitImpl( + beginToken, scriptTag, directives, declarations, endToken); + /** * Set the first token included in this node's source range to the given * [token]. @@ -1594,6 +1866,14 @@ abstract class CompilationUnitMember extends Declaration {} * Clients may not extend, implement or mix-in this class. */ abstract class ConditionalExpression extends Expression { + /** + * Initialize a newly created conditional expression. + */ + factory ConditionalExpression(Expression condition, Token question, + Expression thenExpression, Token colon, Expression elseExpression) => + new ConditionalExpressionImpl( + condition, question, thenExpression, colon, elseExpression); + /** * Return the token used to separate the then expression from the else * expression. @@ -1669,6 +1949,20 @@ abstract class ConditionalExpression extends Expression { * Clients may not extend, implement or mix-in this class. */ abstract class Configuration extends AstNode { + /** + * Initialize a newly created configuration. + */ + factory Configuration( + Token ifKeyword, + Token leftParenthesis, + DottedName name, + Token equalToken, + StringLiteral value, + Token rightParenthesis, + StringLiteral libraryUri) => + new ConfigurationImpl(ifKeyword, leftParenthesis, name, equalToken, value, + rightParenthesis, libraryUri); + /** * Return the token for the equal operator, or `null` if the condition does * not include an equality test. @@ -1795,6 +2089,50 @@ abstract class Configuration extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class ConstructorDeclaration extends ClassMember { + /** + * Initialize a newly created constructor declaration. The [externalKeyword] + * can be `null` if the constructor is not external. Either or both of the + * [comment] and [metadata] can be `null` if the constructor does not have the + * corresponding attribute. The [constKeyword] can be `null` if the + * constructor cannot be used to create a constant. The [factoryKeyword] can + * be `null` if the constructor is not a factory. The [period] and [name] can + * both be `null` if the constructor is not a named constructor. The + * [separator] can be `null` if the constructor does not have any initializers + * and does not redirect to a different constructor. The list of + * [initializers] can be `null` if the constructor does not have any + * initializers. The [redirectedConstructor] can be `null` if the constructor + * does not redirect to a different constructor. The [body] can be `null` if + * the constructor does not have a body. + */ + factory ConstructorDeclaration( + Comment comment, + List metadata, + Token externalKeyword, + Token constKeyword, + Token factoryKeyword, + Identifier returnType, + Token period, + SimpleIdentifier name, + FormalParameterList parameters, + Token separator, + List initializers, + ConstructorName redirectedConstructor, + FunctionBody body) => + new ConstructorDeclarationImpl( + comment, + metadata, + externalKeyword, + constKeyword, + factoryKeyword, + returnType, + period, + name, + parameters, + separator, + initializers, + redirectedConstructor, + body); + /** * Return the body of the constructor, or `null` if the constructor does not * have a body. @@ -1932,6 +2270,16 @@ abstract class ConstructorDeclaration extends ClassMember { * Clients may not extend, implement or mix-in this class. */ abstract class ConstructorFieldInitializer extends ConstructorInitializer { + /** + * Initialize a newly created field initializer to initialize the field with + * the given name to the value of the given expression. The [thisKeyword] and + * [period] can be `null` if the 'this' keyword was not specified. + */ + factory ConstructorFieldInitializer(Token thisKeyword, Token period, + SimpleIdentifier fieldName, Token equals, Expression expression) => + new ConstructorFieldInitializerImpl( + thisKeyword, period, fieldName, equals, expression); + /** * Return the token for the equal sign between the field name and the * expression. @@ -2011,6 +2359,13 @@ abstract class ConstructorInitializer extends AstNode {} */ abstract class ConstructorName extends AstNode implements ConstructorReferenceNode { + /** + * Initialize a newly created constructor name. The [period] and [name] can be + * `null` if the constructor being named is the unnamed constructor. + */ + factory ConstructorName(TypeName type, Token period, SimpleIdentifier name) => + new ConstructorNameImpl(type, period, name); + /** * Return the name of the constructor, or `null` if the specified constructor * is the unnamed constructor. @@ -2074,6 +2429,14 @@ abstract class ConstructorReferenceNode { * Clients may not extend, implement or mix-in this class. */ abstract class ContinueStatement extends Statement { + /** + * Initialize a newly created continue statement. The [label] can be `null` if + * there is no label associated with the statement. + */ + factory ContinueStatement( + Token continueKeyword, SimpleIdentifier label, Token semicolon) => + new ContinueStatementImpl(continueKeyword, label, semicolon); + /** * Return the token representing the 'continue' keyword. */ @@ -2146,6 +2509,16 @@ abstract class Declaration extends AnnotatedNode { * Clients may not extend, implement or mix-in this class. */ abstract class DeclaredIdentifier extends Declaration { + /** + * Initialize a newly created formal parameter. Either or both of the + * [comment] and [metadata] can be `null` if the declaration does not have the + * corresponding attribute. The [keyword] can be `null` if a type name is + * given. The [type] must be `null` if the keyword is 'var'. + */ + factory DeclaredIdentifier(Comment comment, List metadata, + Token keyword, TypeName type, SimpleIdentifier identifier) => + new DeclaredIdentifierImpl(comment, metadata, keyword, type, identifier); + @override LocalVariableElement get element; @@ -2209,6 +2582,14 @@ abstract class DeclaredIdentifier extends Declaration { * Clients may not extend, implement or mix-in this class. */ abstract class DefaultFormalParameter extends FormalParameter { + /** + * Initialize a newly created default formal parameter. The [separator] and + * [defaultValue] can be `null` if there is no default value. + */ + factory DefaultFormalParameter(NormalFormalParameter parameter, + ParameterKind kind, Token separator, Expression defaultValue) => + new DefaultFormalParameterImpl(parameter, kind, separator, defaultValue); + /** * Return the expression computing the default value for the parameter, or * `null` if there is no default value. @@ -2290,6 +2671,20 @@ abstract class Directive extends AnnotatedNode { * Clients may not extend, implement or mix-in this class. */ abstract class DoStatement extends Statement { + /** + * Initialize a newly created do loop. + */ + factory DoStatement( + Token doKeyword, + Statement body, + Token whileKeyword, + Token leftParenthesis, + Expression condition, + Token rightParenthesis, + Token semicolon) => + new DoStatementImpl(doKeyword, body, whileKeyword, leftParenthesis, + condition, rightParenthesis, semicolon); + /** * Return the body of the loop. */ @@ -2371,6 +2766,11 @@ abstract class DoStatement extends Statement { * Clients may not extend, implement or mix-in this class. */ abstract class DottedName extends AstNode { + /** + * Initialize a newly created dotted name. + */ + factory DottedName(List components) = DottedNameImpl; + /** * Return the components of the identifier. */ @@ -2390,6 +2790,11 @@ abstract class DottedName extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class DoubleLiteral extends Literal { + /** + * Initialize a newly created floating point literal. + */ + factory DoubleLiteral(Token literal, double value) = DoubleLiteralImpl; + /** * Return the token representing the literal. */ @@ -2421,6 +2826,11 @@ abstract class DoubleLiteral extends Literal { * Clients may not extend, implement or mix-in this class. */ abstract class EmptyFunctionBody extends FunctionBody { + /** + * Initialize a newly created function body. + */ + factory EmptyFunctionBody(Token semicolon) = EmptyFunctionBodyImpl; + /** * Return the token representing the semicolon that marks the end of the * function body. @@ -2443,6 +2853,11 @@ abstract class EmptyFunctionBody extends FunctionBody { * Clients may not extend, implement or mix-in this class. */ abstract class EmptyStatement extends Statement { + /** + * Initialize a newly created empty statement. + */ + factory EmptyStatement(Token semicolon) = EmptyStatementImpl; + /** * Return the semicolon terminating the statement. */ @@ -2460,6 +2875,16 @@ abstract class EmptyStatement extends Statement { * Clients may not extend, implement or mix-in this class. */ abstract class EnumConstantDeclaration extends Declaration { + /** + * Initialize a newly created enum constant declaration. Either or both of the + * [comment] and [metadata] can be `null` if the constant does not have the + * corresponding attribute. (Technically, enum constants cannot have metadata, + * but we allow it for consistency.) + */ + factory EnumConstantDeclaration( + Comment comment, List metadata, SimpleIdentifier name) => + new EnumConstantDeclarationImpl(comment, metadata, name); + /** * Return the name of the constant. */ @@ -2480,6 +2905,23 @@ abstract class EnumConstantDeclaration extends Declaration { * Clients may not extend, implement or mix-in this class. */ abstract class EnumDeclaration extends NamedCompilationUnitMember { + /** + * Initialize a newly created enumeration declaration. Either or both of the + * [comment] and [metadata] can be `null` if the declaration does not have the + * corresponding attribute. The list of [constants] must contain at least one + * value. + */ + factory EnumDeclaration( + Comment comment, + List metadata, + Token enumKeyword, + SimpleIdentifier name, + Token leftBracket, + List constants, + Token rightBracket) => + new EnumDeclarationImpl(comment, metadata, enumKeyword, name, leftBracket, + constants, rightBracket); + /** * Return the enumeration constants being declared. */ @@ -2527,7 +2969,24 @@ abstract class EnumDeclaration extends NamedCompilationUnitMember { * * Clients may not extend, implement or mix-in this class. */ -abstract class ExportDirective extends NamespaceDirective {} +abstract class ExportDirective extends NamespaceDirective { + /** + * Initialize a newly created export directive. Either or both of the + * [comment] and [metadata] can be `null` if the directive does not have the + * corresponding attribute. The list of [combinators] can be `null` if there + * are no combinators. + */ + factory ExportDirective( + Comment comment, + List metadata, + Token keyword, + StringLiteral libraryUri, + List configurations, + List combinators, + Token semicolon) => + new ExportDirectiveImpl(comment, metadata, keyword, libraryUri, + configurations, combinators, semicolon); +} /** * A node that represents an expression. @@ -2639,6 +3098,16 @@ abstract class Expression extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class ExpressionFunctionBody extends FunctionBody { + /** + * Initialize a newly created function body consisting of a block of + * statements. The [keyword] can be `null` if the function body is not an + * async function body. + */ + factory ExpressionFunctionBody(Token keyword, Token functionDefinition, + Expression expression, Token semicolon) => + new ExpressionFunctionBodyImpl( + keyword, functionDefinition, expression, semicolon); + /** * Return the expression representing the body of the function. */ @@ -2687,6 +3156,12 @@ abstract class ExpressionFunctionBody extends FunctionBody { * Clients may not extend, implement or mix-in this class. */ abstract class ExpressionStatement extends Statement { + /** + * Initialize a newly created expression statement. + */ + factory ExpressionStatement(Expression expression, Token semicolon) => + new ExpressionStatementImpl(expression, semicolon); + /** * Return the expression that comprises the statement. */ @@ -2718,6 +3193,12 @@ abstract class ExpressionStatement extends Statement { * Clients may not extend, implement or mix-in this class. */ abstract class ExtendsClause extends AstNode { + /** + * Initialize a newly created extends clause. + */ + factory ExtendsClause(Token extendsKeyword, TypeName superclass) => + new ExtendsClauseImpl(extendsKeyword, superclass); + /** * Return the token representing the 'extends' keyword. */ @@ -2748,6 +3229,21 @@ abstract class ExtendsClause extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class FieldDeclaration extends ClassMember { + /** + * Initialize a newly created field declaration. Either or both of the + * [comment] and [metadata] can be `null` if the declaration does not have the + * corresponding attribute. The [staticKeyword] can be `null` if the field is + * not a static field. + */ + factory FieldDeclaration( + Comment comment, + List metadata, + Token staticKeyword, + VariableDeclarationList fieldList, + Token semicolon) => + new FieldDeclarationImpl( + comment, metadata, staticKeyword, fieldList, semicolon); + /** * Return the fields being declared. */ @@ -2795,6 +3291,28 @@ abstract class FieldDeclaration extends ClassMember { * Clients may not extend, implement or mix-in this class. */ abstract class FieldFormalParameter extends NormalFormalParameter { + /** + * Initialize a newly created formal parameter. Either or both of the + * [comment] and [metadata] can be `null` if the parameter does not have the + * corresponding attribute. The [keyword] can be `null` if there is a type. + * The [type] must be `null` if the keyword is 'var'. The [thisKeyword] and + * [period] can be `null` if the keyword 'this' was not provided. The + * [parameters] can be `null` if this is not a function-typed field formal + * parameter. + */ + factory FieldFormalParameter( + Comment comment, + List metadata, + Token keyword, + TypeName type, + Token thisKeyword, + Token period, + SimpleIdentifier identifier, + TypeParameterList typeParameters, + FormalParameterList parameters) => + new FieldFormalParameterImpl(comment, metadata, keyword, type, + thisKeyword, period, identifier, typeParameters, parameters); + /** * Return the token representing either the 'final', 'const' or 'var' keyword, * or `null` if no keyword was used. @@ -2875,6 +3393,54 @@ abstract class FieldFormalParameter extends NormalFormalParameter { * Clients may not extend, implement or mix-in this class. */ abstract class ForEachStatement extends Statement { + /** + * Initialize a newly created for-each statement whose loop control variable + * is declared internally (in the for-loop part). The [awaitKeyword] can be + * `null` if this is not an asynchronous for loop. + */ + factory ForEachStatement.withDeclaration( + Token awaitKeyword, + Token forKeyword, + Token leftParenthesis, + DeclaredIdentifier loopVariable, + Token inKeyword, + Expression iterator, + Token rightParenthesis, + Statement body) => + new ForEachStatementImpl.withDeclaration( + awaitKeyword, + forKeyword, + leftParenthesis, + loopVariable, + inKeyword, + iterator, + rightParenthesis, + body); + + /** + * Initialize a newly created for-each statement whose loop control variable + * is declared outside the for loop. The [awaitKeyword] can be `null` if this + * is not an asynchronous for loop. + */ + factory ForEachStatement.withReference( + Token awaitKeyword, + Token forKeyword, + Token leftParenthesis, + SimpleIdentifier identifier, + Token inKeyword, + Expression iterator, + Token rightParenthesis, + Statement body) => + new ForEachStatementImpl.withReference( + awaitKeyword, + forKeyword, + leftParenthesis, + identifier, + inKeyword, + iterator, + rightParenthesis, + body); + /** * Return the token representing the 'await' keyword, or `null` if there is no * 'await' keyword. @@ -3045,6 +3611,18 @@ abstract class FormalParameter extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class FormalParameterList extends AstNode { + /** + * Initialize a newly created parameter list. The list of [parameters] can be + * `null` if there are no parameters. The [leftDelimiter] and [rightDelimiter] + * can be `null` if there are no optional parameters. + */ + factory FormalParameterList( + Token leftParenthesis, + List parameters, + Token leftDelimiter, + Token rightDelimiter, + Token rightParenthesis) = FormalParameterListImpl; + /** * Return the left square bracket ('[') or left curly brace ('{') introducing * the optional parameters, or `null` if there are no optional parameters. @@ -3118,6 +3696,35 @@ abstract class FormalParameterList extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class ForStatement extends Statement { + /** + * Initialize a newly created for statement. Either the [variableList] or the + * [initialization] must be `null`. Either the [condition] and the list of + * [updaters] can be `null` if the loop does not have the corresponding + * attribute. + */ + factory ForStatement( + Token forKeyword, + Token leftParenthesis, + VariableDeclarationList variableList, + Expression initialization, + Token leftSeparator, + Expression condition, + Token rightSeparator, + List updaters, + Token rightParenthesis, + Statement body) => + new ForStatementImpl( + forKeyword, + leftParenthesis, + variableList, + initialization, + leftSeparator, + condition, + rightSeparator, + updaters, + rightParenthesis, + body); + /** * Return the body of the loop. */ @@ -3298,6 +3905,25 @@ abstract class FunctionBody extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class FunctionDeclaration extends NamedCompilationUnitMember { + /** + * Initialize a newly created function declaration. Either or both of the + * [comment] and [metadata] can be `null` if the function does not have the + * corresponding attribute. The [externalKeyword] can be `null` if the + * function is not an external function. The [returnType] can be `null` if no + * return type was specified. The [propertyKeyword] can be `null` if the + * function is neither a getter or a setter. + */ + factory FunctionDeclaration( + Comment comment, + List metadata, + Token externalKeyword, + TypeName returnType, + Token propertyKeyword, + SimpleIdentifier name, + FunctionExpression functionExpression) => + new FunctionDeclarationImpl(comment, metadata, externalKeyword, + returnType, propertyKeyword, name, functionExpression); + @override ExecutableElement get element; @@ -3362,6 +3988,13 @@ abstract class FunctionDeclaration extends NamedCompilationUnitMember { * Clients may not extend, implement or mix-in this class. */ abstract class FunctionDeclarationStatement extends Statement { + /** + * Initialize a newly created function declaration statement. + */ + factory FunctionDeclarationStatement( + FunctionDeclaration functionDeclaration) = + FunctionDeclarationStatementImpl; + /** * Return the function declaration being wrapped. */ @@ -3383,6 +4016,13 @@ abstract class FunctionDeclarationStatement extends Statement { * Clients may not extend, implement or mix-in this class. */ abstract class FunctionExpression extends Expression { + /** + * Initialize a newly created function declaration. + */ + factory FunctionExpression(TypeParameterList typeParameters, + FormalParameterList parameters, FunctionBody body) => + new FunctionExpressionImpl(typeParameters, parameters, body); + /** * Return the body of the function, or `null` if this is an external function. */ @@ -3440,6 +4080,14 @@ abstract class FunctionExpression extends Expression { * Clients may not extend, implement or mix-in this class. */ abstract class FunctionExpressionInvocation extends InvocationExpression { + /** + * Initialize a newly created function expression invocation. + */ + factory FunctionExpressionInvocation(Expression function, + TypeArgumentList typeArguments, ArgumentList argumentList) => + new FunctionExpressionInvocationImpl( + function, typeArguments, argumentList); + /** * Set the list of arguments to the method to the given [argumentList]. */ @@ -3511,6 +4159,25 @@ abstract class FunctionExpressionInvocation extends InvocationExpression { * Clients may not extend, implement or mix-in this class. */ abstract class FunctionTypeAlias extends TypeAlias { + /** + * Initialize a newly created function type alias. Either or both of the + * [comment] and [metadata] can be `null` if the function does not have the + * corresponding attribute. The [returnType] can be `null` if no return type + * was specified. The [typeParameters] can be `null` if the function has no + * type parameters. + */ + factory FunctionTypeAlias( + Comment comment, + List metadata, + Token keyword, + TypeName returnType, + SimpleIdentifier name, + TypeParameterList typeParameters, + FormalParameterList parameters, + Token semicolon) => + new FunctionTypeAliasImpl(comment, metadata, keyword, returnType, name, + typeParameters, parameters, semicolon); + /** * Return the parameters associated with the function type. */ @@ -3556,6 +4223,23 @@ abstract class FunctionTypeAlias extends TypeAlias { * Clients may not extend, implement or mix-in this class. */ abstract class FunctionTypedFormalParameter extends NormalFormalParameter { + /** + * Initialize a newly created formal parameter. Either or both of the + * [comment] and [metadata] can be `null` if the parameter does not have the + * corresponding attribute. The [returnType] can be `null` if no return type + * was specified. + */ + factory FunctionTypedFormalParameter( + Comment comment, + List metadata, + TypeName returnType, + SimpleIdentifier identifier, + TypeParameterList typeParameters, + FormalParameterList parameters, + {Token question: null}) => + new FunctionTypedFormalParameterImpl(comment, metadata, returnType, + identifier, typeParameters, parameters, question); + /** * Return the parameters of the function-typed parameter. */ @@ -3613,6 +4297,12 @@ abstract class FunctionTypedFormalParameter extends NormalFormalParameter { * Clients may not extend, implement or mix-in this class. */ abstract class HideCombinator extends Combinator { + /** + * Initialize a newly created import show combinator. + */ + factory HideCombinator(Token keyword, List hiddenNames) = + HideCombinatorImpl; + /** * Return the list of names from the library that are hidden by this * combinator. @@ -3677,6 +4367,21 @@ abstract class Identifier extends Expression { * Clients may not extend, implement or mix-in this class. */ abstract class IfStatement extends Statement { + /** + * Initialize a newly created if statement. The [elseKeyword] and + * [elseStatement] can be `null` if there is no else clause. + */ + factory IfStatement( + Token ifKeyword, + Token leftParenthesis, + Expression condition, + Token rightParenthesis, + Statement thenStatement, + Token elseKeyword, + Statement elseStatement) => + new IfStatementImpl(ifKeyword, leftParenthesis, condition, + rightParenthesis, thenStatement, elseKeyword, elseStatement); + /** * Return the condition used to determine which of the statements is executed * next. @@ -3763,6 +4468,12 @@ abstract class IfStatement extends Statement { * Clients may not extend, implement or mix-in this class. */ abstract class ImplementsClause extends AstNode { + /** + * Initialize a newly created implements clause. + */ + factory ImplementsClause(Token implementsKeyword, List interfaces) = + ImplementsClauseImpl; + /** * Return the token representing the 'implements' keyword. */ @@ -3894,6 +4605,38 @@ abstract class ImportDirective extends NamespaceDirective { } return 0; }; + + /** + * Initialize a newly created import directive. Either or both of the + * [comment] and [metadata] can be `null` if the function does not have the + * corresponding attribute. The [deferredKeyword] can be `null` if the import + * is not deferred. The [asKeyword] and [prefix] can be `null` if the import + * does not specify a prefix. The list of [combinators] can be `null` if there + * are no combinators. + */ + factory ImportDirective( + Comment comment, + List metadata, + Token keyword, + StringLiteral libraryUri, + List configurations, + Token deferredKeyword, + Token asKeyword, + SimpleIdentifier prefix, + List combinators, + Token semicolon) => + new ImportDirectiveImpl( + comment, + metadata, + keyword, + libraryUri, + configurations, + deferredKeyword, + asKeyword, + prefix, + combinators, + semicolon); + /** * Return the token representing the 'as' keyword, or `null` if the imported * names are not prefixed. @@ -3938,6 +4681,22 @@ abstract class ImportDirective extends NamespaceDirective { */ abstract class IndexExpression extends Expression implements MethodReferenceExpression { + /** + * Initialize a newly created index expression. + */ + factory IndexExpression.forCascade(Token period, Token leftBracket, + Expression index, Token rightBracket) => + new IndexExpressionImpl.forCascade( + period, leftBracket, index, rightBracket); + + /** + * Initialize a newly created index expression. + */ + factory IndexExpression.forTarget(Expression target, Token leftBracket, + Expression index, Token rightBracket) => + new IndexExpressionImpl.forTarget( + target, leftBracket, index, rightBracket); + /** * Return the auxiliary elements associated with this identifier, or `null` if * this identifier is not in both a getter and setter context. The auxiliary @@ -4056,6 +4815,14 @@ abstract class IndexExpression extends Expression */ abstract class InstanceCreationExpression extends Expression implements ConstructorReferenceNode { + /** + * Initialize a newly created instance creation expression. + */ + factory InstanceCreationExpression(Token keyword, + ConstructorName constructorName, ArgumentList argumentList) => + new InstanceCreationExpressionImpl( + keyword, constructorName, argumentList); + /** * Return the list of arguments to the constructor. */ @@ -4112,6 +4879,11 @@ abstract class InstanceCreationExpression extends Expression * Clients may not extend, implement or mix-in this class. */ abstract class IntegerLiteral extends Literal { + /** + * Initialize a newly created integer literal. + */ + factory IntegerLiteral(Token literal, int value) = IntegerLiteralImpl; + /** * Return the token representing the literal. */ @@ -4154,6 +4926,13 @@ abstract class InterpolationElement extends AstNode {} * Clients may not extend, implement or mix-in this class. */ abstract class InterpolationExpression extends InterpolationElement { + /** + * Initialize a newly created interpolation expression. + */ + factory InterpolationExpression( + Token leftBracket, Expression expression, Token rightBracket) => + new InterpolationExpressionImpl(leftBracket, expression, rightBracket); + /** * Return the expression to be evaluated for the value to be converted into a * string. @@ -4201,6 +4980,13 @@ abstract class InterpolationExpression extends InterpolationElement { * Clients may not extend, implement or mix-in this class. */ abstract class InterpolationString extends InterpolationElement { + /** + * Initialize a newly created string of characters that are part of a string + * interpolation. + */ + factory InterpolationString(Token contents, String value) = + InterpolationStringImpl; + /** * Return the characters that will be added to the string. */ @@ -4308,6 +5094,14 @@ abstract class InvocationExpression extends Expression { * Clients may not extend, implement or mix-in this class. */ abstract class IsExpression extends Expression { + /** + * Initialize a newly created is expression. The [notOperator] can be `null` + * if the sense of the test is not negated. + */ + factory IsExpression(Expression expression, Token isOperator, + Token notOperator, TypeName type) => + new IsExpressionImpl(expression, isOperator, notOperator, type); + /** * Return the expression used to compute the value whose type is being tested. */ @@ -4359,6 +5153,12 @@ abstract class IsExpression extends Expression { * Clients may not extend, implement or mix-in this class. */ abstract class Label extends AstNode { + /** + * Initialize a newly created label. + */ + factory Label(SimpleIdentifier label, Token colon) => + new LabelImpl(label, colon); + /** * Return the colon that separates the label from the statement. */ @@ -4390,6 +5190,12 @@ abstract class Label extends AstNode { * Clients may not extend, implement or mix-in this class. */ abstract class LabeledStatement extends Statement { + /** + * Initialize a newly created labeled statement. + */ + factory LabeledStatement(List