Transition analyzer and analysis_server to new astFactory.

This is the same as 1d028eed8d (which
was reverted) except that it doesn't remove the old AST factory
constructors (which broke dev_compiler).  The removal of old AST
factory constructors will be done in a follow-up CL so that if it
unexpectedly breaks any other clients we will be able to revert it
without reverting this CL.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2536373008 .
This commit is contained in:
Paul Berry 2016-12-01 10:56:21 -08:00
parent 2d289c2df6
commit 0c31815f1c
19 changed files with 1100 additions and 971 deletions

View file

@ -19,6 +19,7 @@ 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';
@ -516,7 +517,8 @@ class ReplacementRange {
}
}
if (token is StringToken) {
SimpleStringLiteral uri = new SimpleStringLiteral(token, token.lexeme);
SimpleStringLiteral uri =
astFactory.simpleStringLiteral(token, token.lexeme);
Keyword keyword = token.previous?.keyword;
if (keyword == Keyword.IMPORT ||
keyword == Keyword.EXPORT ||

View file

@ -15,6 +15,7 @@ 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';
@ -24,8 +25,9 @@ import '../../../protocol_server.dart'
const DYNAMIC = 'dynamic';
final TypeName NO_RETURN_TYPE = new TypeName(
new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), null);
final TypeName NO_RETURN_TYPE = astFactory.typeName(
astFactory.simpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)),
null);
/**
* Create a new protocol Element for inclusion in a completion suggestion.

View file

@ -16,6 +16,7 @@ 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';
@ -26,8 +27,9 @@ import '../../../protocol_server.dart'
const DYNAMIC = 'dynamic';
final TypeName NO_RETURN_TYPE = new TypeName(
new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), null);
final TypeName NO_RETURN_TYPE = astFactory.typeName(
astFactory.simpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)),
null);
/**
* Create a new protocol Element for inclusion in a completion suggestion.

View file

@ -5,6 +5,7 @@
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';
@ -15,8 +16,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 = new TypeName(
new SimpleIdentifier(
static final TypeName STACKTRACE_TYPE = astFactory.typeName(
astFactory.simpleIdentifier(
new StringToken(TokenType.IDENTIFIER, 'StackTrace', 0)),
null);

View file

@ -17,6 +17,7 @@ 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';
@ -29,8 +30,9 @@ import '../../../protocol_server.dart'
const DYNAMIC = 'dynamic';
final TypeName NO_RETURN_TYPE = new TypeName(
new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)), null);
final TypeName NO_RETURN_TYPE = astFactory.typeName(
astFactory.simpleIdentifier(new StringToken(TokenType.IDENTIFIER, '', 0)),
null);
/**
* Create a new protocol Element for inclusion in a completion suggestion.

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,7 @@ import 'package:analyzer/src/generated/type_system.dart'
import 'package:analyzer/src/generated/utilities_collection.dart';
import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind;
import 'package:analyzer/src/task/dart.dart';
import 'package:analyzer/dart/ast/standard_ast_factory.dart';
/**
* Helper class encapsulating the methods for evaluating constants and
@ -717,7 +718,7 @@ class ConstantEvaluationEngine {
superclass.lookUpConstructor(superName, constructor.library);
if (superConstructor != null) {
if (superArguments == null) {
superArguments = new NodeList<Expression>(null);
superArguments = astFactory.nodeList/*<Expression>*/(null);
}
evaluateSuperConstructorCall(node, fieldMap, superConstructor,

View file

@ -5,6 +5,7 @@
import 'dart:collection';
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';
@ -962,8 +963,8 @@ class InheritanceManager {
int numOfPositionalParameters,
List<String> namedParameters) {
DynamicTypeImpl dynamicType = DynamicTypeImpl.instance;
SimpleIdentifier nameIdentifier =
new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, name, 0));
SimpleIdentifier nameIdentifier = astFactory
.simpleIdentifier(new StringToken(TokenType.IDENTIFIER, name, 0));
ExecutableElementImpl executable;
ExecutableElement elementToMerge = elementArrayToMerge[0];
if (elementToMerge is MethodElement) {

File diff suppressed because it is too large Load diff

View file

@ -5,9 +5,9 @@
library analyzer.src.generated.testing.ast_test_factory;
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/ast.dart';
import 'package:analyzer/src/generated/testing/token_factory.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
@ -25,14 +25,14 @@ import 'package:analyzer/src/generated/utilities_dart.dart';
*/
class AstTestFactory {
static AdjacentStrings adjacentStrings(List<StringLiteral> strings) =>
new AdjacentStrings(strings);
astFactory.adjacentStrings(strings);
static Annotation annotation(Identifier name) => new Annotation(
static Annotation annotation(Identifier name) => astFactory.annotation(
TokenFactory.tokenFromType(TokenType.AT), name, null, null, null);
static Annotation annotation2(Identifier name,
SimpleIdentifier constructorName, ArgumentList arguments) =>
new Annotation(
astFactory.annotation(
TokenFactory.tokenFromType(TokenType.AT),
name,
constructorName == null
@ -42,16 +42,16 @@ class AstTestFactory {
arguments);
static ArgumentList argumentList([List<Expression> arguments]) =>
new ArgumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
astFactory.argumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN));
static AsExpression asExpression(Expression expression, TypeName type) =>
new AsExpression(
astFactory.asExpression(
expression, TokenFactory.tokenFromKeyword(Keyword.AS), type);
static AssertStatement assertStatement(Expression condition,
[Expression message]) =>
new AssertStatement(
astFactory.assertStatement(
TokenFactory.tokenFromKeyword(Keyword.ASSERT),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
condition,
@ -62,19 +62,19 @@ class AstTestFactory {
static AssignmentExpression assignmentExpression(Expression leftHandSide,
TokenType operator, Expression rightHandSide) =>
new AssignmentExpression(
astFactory.assignmentExpression(
leftHandSide, TokenFactory.tokenFromType(operator), rightHandSide);
static BlockFunctionBody asyncBlockFunctionBody(
[List<Statement> statements]) =>
new BlockFunctionBody(
astFactory.blockFunctionBody(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"),
null,
block(statements));
static ExpressionFunctionBody asyncExpressionFunctionBody(
Expression expression) =>
new ExpressionFunctionBody(
astFactory.expressionFunctionBody(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"),
TokenFactory.tokenFromType(TokenType.FUNCTION),
expression,
@ -82,50 +82,49 @@ class AstTestFactory {
static BlockFunctionBody asyncGeneratorBlockFunctionBody(
[List<Statement> statements]) =>
new BlockFunctionBody(
astFactory.blockFunctionBody(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"),
TokenFactory.tokenFromType(TokenType.STAR),
block(statements));
static AwaitExpression awaitExpression(Expression expression) =>
new AwaitExpression(
astFactory.awaitExpression(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "await"),
expression);
static BinaryExpression binaryExpression(Expression leftOperand,
TokenType operator, Expression rightOperand) =>
new BinaryExpression(
astFactory.binaryExpression(
leftOperand, TokenFactory.tokenFromType(operator), rightOperand);
static Block block([List<Statement> statements]) => new Block(
static Block block([List<Statement> statements]) => astFactory.block(
TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET),
statements,
TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET));
static BlockFunctionBody blockFunctionBody(Block block) =>
new BlockFunctionBody(null, null, block);
astFactory.blockFunctionBody(null, null, block);
static BlockFunctionBody blockFunctionBody2([List<Statement> statements]) =>
new BlockFunctionBody(null, null, block(statements));
astFactory.blockFunctionBody(null, null, block(statements));
static BooleanLiteral booleanLiteral(bool value) => new BooleanLiteral(
static BooleanLiteral booleanLiteral(bool value) => astFactory.booleanLiteral(
value
? TokenFactory.tokenFromKeyword(Keyword.TRUE)
: TokenFactory.tokenFromKeyword(Keyword.FALSE),
value);
static BreakStatement breakStatement() => new BreakStatement(
static BreakStatement breakStatement() => astFactory.breakStatement(
TokenFactory.tokenFromKeyword(Keyword.BREAK),
null,
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static BreakStatement breakStatement2(String label) => new BreakStatement(
TokenFactory.tokenFromKeyword(Keyword.BREAK),
identifier3(label),
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static BreakStatement breakStatement2(String label) =>
astFactory.breakStatement(TokenFactory.tokenFromKeyword(Keyword.BREAK),
identifier3(label), TokenFactory.tokenFromType(TokenType.SEMICOLON));
static IndexExpression cascadedIndexExpression(Expression index) =>
new IndexExpression.forCascade(
astFactory.indexExpressionForCascade(
TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD),
TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET),
index,
@ -133,7 +132,7 @@ class AstTestFactory {
static MethodInvocation cascadedMethodInvocation(String methodName,
[List<Expression> arguments]) =>
new MethodInvocation(
astFactory.methodInvocation(
null,
TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD),
identifier3(methodName),
@ -141,14 +140,14 @@ class AstTestFactory {
argumentList(arguments));
static PropertyAccess cascadedPropertyAccess(String propertyName) =>
new PropertyAccess(
astFactory.propertyAccess(
null,
TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD),
identifier3(propertyName));
static CascadeExpression cascadeExpression(Expression target,
[List<Expression> cascadeSections]) =>
new CascadeExpression(target, cascadeSections);
astFactory.cascadeExpression(target, cascadeSections);
static CatchClause catchClause(String exceptionParameter,
[List<Statement> statements]) =>
@ -171,7 +170,7 @@ class AstTestFactory {
static CatchClause catchClause5(TypeName exceptionType,
String exceptionParameter, String stackTraceParameter,
[List<Statement> statements]) =>
new CatchClause(
astFactory.catchClause(
exceptionType == null
? null
: TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "on"),
@ -200,7 +199,7 @@ class AstTestFactory {
WithClause withClause,
ImplementsClause implementsClause,
[List<ClassMember> members]) =>
new ClassDeclaration(
astFactory.classDeclaration(
null,
null,
abstractKeyword == null
@ -223,7 +222,7 @@ class AstTestFactory {
TypeName superclass,
WithClause withClause,
ImplementsClause implementsClause) =>
new ClassTypeAlias(
astFactory.classTypeAlias(
null,
null,
TokenFactory.tokenFromKeyword(Keyword.CLASS),
@ -267,7 +266,7 @@ class AstTestFactory {
String scriptTag,
List<Directive> directives,
List<CompilationUnitMember> declarations) =>
new CompilationUnit(
astFactory.compilationUnit(
TokenFactory.tokenFromType(TokenType.EOF),
scriptTag == null ? null : AstTestFactory.scriptTag(scriptTag),
directives == null ? new List<Directive>() : directives,
@ -278,7 +277,7 @@ class AstTestFactory {
static ConditionalExpression conditionalExpression(Expression condition,
Expression thenExpression, Expression elseExpression) =>
new ConditionalExpression(
astFactory.conditionalExpression(
condition,
TokenFactory.tokenFromType(TokenType.QUESTION),
thenExpression,
@ -290,7 +289,7 @@ class AstTestFactory {
String name,
FormalParameterList parameters,
List<ConstructorInitializer> initializers) =>
new ConstructorDeclaration(
astFactory.constructorDeclaration(
null,
null,
TokenFactory.tokenFromKeyword(Keyword.EXTERNAL),
@ -317,7 +316,7 @@ class AstTestFactory {
FormalParameterList parameters,
List<ConstructorInitializer> initializers,
FunctionBody body) =>
new ConstructorDeclaration(
astFactory.constructorDeclaration(
null,
null,
null,
@ -342,7 +341,7 @@ class AstTestFactory {
static ConstructorFieldInitializer constructorFieldInitializer(
bool prefixedWithThis, String fieldName, Expression expression) =>
new ConstructorFieldInitializer(
astFactory.constructorFieldInitializer(
prefixedWithThis ? TokenFactory.tokenFromKeyword(Keyword.THIS) : null,
prefixedWithThis
? TokenFactory.tokenFromType(TokenType.PERIOD)
@ -352,13 +351,13 @@ class AstTestFactory {
expression);
static ConstructorName constructorName(TypeName type, String name) =>
new ConstructorName(
astFactory.constructorName(
type,
name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD),
name == null ? null : identifier3(name));
static ContinueStatement continueStatement([String label]) =>
new ContinueStatement(
astFactory.continueStatement(
TokenFactory.tokenFromKeyword(Keyword.CONTINUE),
label == null ? null : identifier3(label),
TokenFactory.tokenFromType(TokenType.SEMICOLON));
@ -369,7 +368,7 @@ class AstTestFactory {
static DeclaredIdentifier declaredIdentifier2(
Keyword keyword, TypeName type, String identifier) =>
new DeclaredIdentifier(
astFactory.declaredIdentifier(
null,
null,
keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
@ -385,11 +384,11 @@ class AstTestFactory {
static Comment documentationComment(
List<Token> tokens, List<CommentReference> references) {
return new Comment(tokens, CommentType.DOCUMENTATION, references);
return astFactory.documentationComment(tokens, references);
}
static DoStatement doStatement(Statement body, Expression condition) =>
new DoStatement(
astFactory.doStatement(
TokenFactory.tokenFromKeyword(Keyword.DO),
body,
TokenFactory.tokenFromKeyword(Keyword.WHILE),
@ -398,18 +397,18 @@ class AstTestFactory {
TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static DoubleLiteral doubleLiteral(double value) =>
new DoubleLiteral(TokenFactory.tokenFromString(value.toString()), value);
static DoubleLiteral doubleLiteral(double value) => astFactory.doubleLiteral(
TokenFactory.tokenFromString(value.toString()), value);
static EmptyFunctionBody emptyFunctionBody() =>
new EmptyFunctionBody(TokenFactory.tokenFromType(TokenType.SEMICOLON));
static EmptyFunctionBody emptyFunctionBody() => astFactory
.emptyFunctionBody(TokenFactory.tokenFromType(TokenType.SEMICOLON));
static EmptyStatement emptyStatement() =>
new EmptyStatement(TokenFactory.tokenFromType(TokenType.SEMICOLON));
static EmptyStatement emptyStatement() => astFactory
.emptyStatement(TokenFactory.tokenFromType(TokenType.SEMICOLON));
static EnumDeclaration enumDeclaration(
SimpleIdentifier name, List<EnumConstantDeclaration> constants) =>
new EnumDeclaration(
astFactory.enumDeclaration(
null,
null,
TokenFactory.tokenFromKeyword(Keyword.ENUM),
@ -424,7 +423,7 @@ class AstTestFactory {
List<EnumConstantDeclaration> constants =
new List<EnumConstantDeclaration>(count);
for (int i = 0; i < count; i++) {
constants[i] = new EnumConstantDeclaration(
constants[i] = astFactory.enumConstantDeclaration(
null, null, identifier3(constantNames[i]));
}
return enumDeclaration(identifier3(name), constants);
@ -432,7 +431,7 @@ class AstTestFactory {
static ExportDirective exportDirective(List<Annotation> metadata, String uri,
[List<Combinator> combinators]) =>
new ExportDirective(
astFactory.exportDirective(
null,
metadata,
TokenFactory.tokenFromKeyword(Keyword.EXPORT),
@ -446,22 +445,22 @@ class AstTestFactory {
exportDirective(null, uri, combinators);
static ExpressionFunctionBody expressionFunctionBody(Expression expression) =>
new ExpressionFunctionBody(
astFactory.expressionFunctionBody(
null,
TokenFactory.tokenFromType(TokenType.FUNCTION),
expression,
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static ExpressionStatement expressionStatement(Expression expression) =>
new ExpressionStatement(
astFactory.expressionStatement(
expression, TokenFactory.tokenFromType(TokenType.SEMICOLON));
static ExtendsClause extendsClause(TypeName type) =>
new ExtendsClause(TokenFactory.tokenFromKeyword(Keyword.EXTENDS), type);
static ExtendsClause extendsClause(TypeName type) => astFactory.extendsClause(
TokenFactory.tokenFromKeyword(Keyword.EXTENDS), type);
static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword,
TypeName type, List<VariableDeclaration> variables) =>
new FieldDeclaration(
astFactory.fieldDeclaration(
null,
null,
isStatic ? TokenFactory.tokenFromKeyword(Keyword.STATIC) : null,
@ -475,7 +474,7 @@ class AstTestFactory {
static FieldFormalParameter fieldFormalParameter(
Keyword keyword, TypeName type, String identifier,
[FormalParameterList parameterList]) =>
new FieldFormalParameter(
astFactory.fieldFormalParameter(
null,
null,
keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
@ -491,7 +490,7 @@ class AstTestFactory {
static ForEachStatement forEachStatement(DeclaredIdentifier loopVariable,
Expression iterator, Statement body) =>
new ForEachStatement.withDeclaration(
astFactory.forEachStatementWithDeclaration(
null,
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
@ -503,7 +502,7 @@ class AstTestFactory {
static ForEachStatement forEachStatement2(
SimpleIdentifier identifier, Expression iterator, Statement body) =>
new ForEachStatement.withReference(
astFactory.forEachStatementWithReference(
null,
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
@ -515,7 +514,7 @@ class AstTestFactory {
static FormalParameterList formalParameterList(
[List<FormalParameter> parameters]) =>
new FormalParameterList(
astFactory.formalParameterList(
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
parameters,
null,
@ -524,7 +523,7 @@ class AstTestFactory {
static ForStatement forStatement(Expression initialization,
Expression condition, List<Expression> updaters, Statement body) =>
new ForStatement(
astFactory.forStatement(
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
null,
@ -538,7 +537,7 @@ class AstTestFactory {
static ForStatement forStatement2(VariableDeclarationList variableList,
Expression condition, List<Expression> updaters, Statement body) =>
new ForStatement(
astFactory.forStatement(
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
variableList,
@ -552,7 +551,7 @@ class AstTestFactory {
static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword,
String name, FunctionExpression functionExpression) =>
new FunctionDeclaration(
astFactory.functionDeclaration(
null,
null,
null,
@ -566,21 +565,21 @@ class AstTestFactory {
Keyword keyword,
String name,
FunctionExpression functionExpression) =>
new FunctionDeclarationStatement(
astFactory.functionDeclarationStatement(
functionDeclaration(type, keyword, name, functionExpression));
static FunctionExpression functionExpression() =>
new FunctionExpression(null, formalParameterList(), blockFunctionBody2());
static FunctionExpression functionExpression() => astFactory
.functionExpression(null, formalParameterList(), blockFunctionBody2());
static FunctionExpression functionExpression2(
FormalParameterList parameters, FunctionBody body) =>
new FunctionExpression(null, parameters, body);
astFactory.functionExpression(null, parameters, body);
static FunctionExpression functionExpression3(
TypeParameterList typeParameters,
FormalParameterList parameters,
FunctionBody body) =>
new FunctionExpression(typeParameters, parameters, body);
astFactory.functionExpression(typeParameters, parameters, body);
static FunctionExpressionInvocation functionExpressionInvocation(
Expression function,
@ -591,37 +590,39 @@ class AstTestFactory {
Expression function,
[TypeArgumentList typeArguments,
List<Expression> arguments]) =>
new FunctionExpressionInvocation(
astFactory.functionExpressionInvocation(
function, typeArguments, argumentList(arguments));
static FunctionTypedFormalParameter functionTypedFormalParameter(
TypeName returnType, String identifier,
[List<FormalParameter> parameters]) =>
new FunctionTypedFormalParameter(null, null, returnType,
astFactory.functionTypedFormalParameter(null, null, returnType,
identifier3(identifier), null, formalParameterList(parameters));
static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) =>
new HideCombinator(TokenFactory.tokenFromString("hide"), identifiers);
astFactory.hideCombinator(
TokenFactory.tokenFromString("hide"), identifiers);
static HideCombinator hideCombinator2(List<String> identifiers) =>
new HideCombinator(
astFactory.hideCombinator(
TokenFactory.tokenFromString("hide"), identifierList(identifiers));
static PrefixedIdentifier identifier(
SimpleIdentifier prefix, SimpleIdentifier identifier) =>
new PrefixedIdentifier(
astFactory.prefixedIdentifier(
prefix, TokenFactory.tokenFromType(TokenType.PERIOD), identifier);
static SimpleIdentifier identifier3(String lexeme) => new SimpleIdentifier(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, lexeme));
static SimpleIdentifier identifier3(String lexeme) =>
astFactory.simpleIdentifier(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, lexeme));
static PrefixedIdentifier identifier4(
String prefix, SimpleIdentifier identifier) =>
new PrefixedIdentifier(identifier3(prefix),
astFactory.prefixedIdentifier(identifier3(prefix),
TokenFactory.tokenFromType(TokenType.PERIOD), identifier);
static PrefixedIdentifier identifier5(String prefix, String identifier) =>
new PrefixedIdentifier(
astFactory.prefixedIdentifier(
identifier3(prefix),
TokenFactory.tokenFromType(TokenType.PERIOD),
identifier3(identifier));
@ -641,7 +642,7 @@ class AstTestFactory {
static IfStatement ifStatement2(Expression condition, Statement thenStatement,
Statement elseStatement) =>
new IfStatement(
astFactory.ifStatement(
TokenFactory.tokenFromKeyword(Keyword.IF),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
condition,
@ -653,13 +654,13 @@ class AstTestFactory {
elseStatement);
static ImplementsClause implementsClause(List<TypeName> types) =>
new ImplementsClause(
astFactory.implementsClause(
TokenFactory.tokenFromKeyword(Keyword.IMPLEMENTS), types);
static ImportDirective importDirective(
List<Annotation> metadata, String uri, bool isDeferred, String prefix,
[List<Combinator> combinators]) =>
new ImportDirective(
astFactory.importDirective(
null,
metadata,
TokenFactory.tokenFromKeyword(Keyword.IMPORT),
@ -681,7 +682,7 @@ class AstTestFactory {
importDirective(null, uri, false, prefix, combinators);
static IndexExpression indexExpression(Expression array, Expression index) =>
new IndexExpression.forTarget(
astFactory.indexExpressionForTarget(
array,
TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET),
index,
@ -690,7 +691,7 @@ class AstTestFactory {
static InstanceCreationExpression instanceCreationExpression(
Keyword keyword, ConstructorName name,
[List<Expression> arguments]) =>
new InstanceCreationExpression(
astFactory.instanceCreationExpression(
keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
name,
argumentList(arguments));
@ -705,7 +706,7 @@ class AstTestFactory {
[List<Expression> arguments]) =>
instanceCreationExpression(
keyword,
new ConstructorName(
astFactory.constructorName(
type,
identifier == null
? null
@ -713,44 +714,48 @@ class AstTestFactory {
identifier == null ? null : identifier3(identifier)),
arguments);
static IntegerLiteral integer(int value) => new IntegerLiteral(
static IntegerLiteral integer(int value) => astFactory.integerLiteral(
TokenFactory.tokenFromTypeAndString(TokenType.INT, value.toString()),
value);
static InterpolationExpression interpolationExpression(
Expression expression) =>
new InterpolationExpression(
astFactory.interpolationExpression(
TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION),
expression,
TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET));
static InterpolationExpression interpolationExpression2(String identifier) =>
new InterpolationExpression(
astFactory.interpolationExpression(
TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_IDENTIFIER),
identifier3(identifier),
null);
static InterpolationString interpolationString(
String contents, String value) =>
new InterpolationString(TokenFactory.tokenFromString(contents), value);
astFactory.interpolationString(
TokenFactory.tokenFromString(contents), value);
static IsExpression isExpression(
Expression expression, bool negated, TypeName type) =>
new IsExpression(expression, TokenFactory.tokenFromKeyword(Keyword.IS),
negated ? TokenFactory.tokenFromType(TokenType.BANG) : null, type);
astFactory.isExpression(
expression,
TokenFactory.tokenFromKeyword(Keyword.IS),
negated ? TokenFactory.tokenFromType(TokenType.BANG) : null,
type);
static Label label(SimpleIdentifier label) =>
new Label(label, TokenFactory.tokenFromType(TokenType.COLON));
astFactory.label(label, TokenFactory.tokenFromType(TokenType.COLON));
static Label label2(String label) => AstTestFactory.label(identifier3(label));
static LabeledStatement labeledStatement(
List<Label> labels, Statement statement) =>
new LabeledStatement(labels, statement);
astFactory.labeledStatement(labels, statement);
static LibraryDirective libraryDirective(
List<Annotation> metadata, LibraryIdentifier libraryName) =>
new LibraryDirective(
astFactory.libraryDirective(
null,
metadata,
TokenFactory.tokenFromKeyword(Keyword.LIBRARY),
@ -763,10 +768,10 @@ class AstTestFactory {
static LibraryIdentifier libraryIdentifier(
List<SimpleIdentifier> components) =>
new LibraryIdentifier(components);
astFactory.libraryIdentifier(components);
static LibraryIdentifier libraryIdentifier2(List<String> components) {
return new LibraryIdentifier(identifierList(components));
return astFactory.libraryIdentifier(identifierList(components));
}
static List list(List<Object> elements) {
@ -779,7 +784,7 @@ class AstTestFactory {
static ListLiteral listLiteral2(
Keyword keyword, TypeArgumentList typeArguments,
[List<Expression> elements]) =>
new ListLiteral(
astFactory.listLiteral(
keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
typeArguments,
TokenFactory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET),
@ -788,7 +793,7 @@ class AstTestFactory {
static MapLiteral mapLiteral(Keyword keyword, TypeArgumentList typeArguments,
[List<MapLiteralEntry> entries]) =>
new MapLiteral(
astFactory.mapLiteral(
keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
typeArguments,
TokenFactory.tokenFromType(TokenType.OPEN_CURLY_BRACKET),
@ -799,11 +804,11 @@ class AstTestFactory {
mapLiteral(null, null, entries);
static MapLiteralEntry mapLiteralEntry(String key, Expression value) =>
new MapLiteralEntry(
astFactory.mapLiteralEntry(
string2(key), TokenFactory.tokenFromType(TokenType.COLON), value);
static MapLiteralEntry mapLiteralEntry2(Expression key, Expression value) =>
new MapLiteralEntry(
astFactory.mapLiteralEntry(
key, TokenFactory.tokenFromType(TokenType.COLON), value);
static MethodDeclaration methodDeclaration(
@ -813,7 +818,7 @@ class AstTestFactory {
Keyword operator,
SimpleIdentifier name,
FormalParameterList parameters) =>
new MethodDeclaration(
astFactory.methodDeclaration(
null,
null,
TokenFactory.tokenFromKeyword(Keyword.EXTERNAL),
@ -834,7 +839,7 @@ class AstTestFactory {
SimpleIdentifier name,
FormalParameterList parameters,
FunctionBody body) =>
new MethodDeclaration(
astFactory.methodDeclaration(
null,
null,
null,
@ -856,7 +861,7 @@ class AstTestFactory {
TypeParameterList typeParameters,
FormalParameterList parameters,
FunctionBody body) =>
new MethodDeclaration(
astFactory.methodDeclaration(
null,
null,
null,
@ -878,7 +883,7 @@ class AstTestFactory {
String name,
FormalParameterList parameters,
FunctionBody body}) =>
new MethodDeclaration(
astFactory.methodDeclaration(
null,
null,
external ? TokenFactory.tokenFromKeyword(Keyword.EXTERNAL) : null,
@ -894,7 +899,7 @@ class AstTestFactory {
static MethodInvocation methodInvocation(Expression target, String methodName,
[List<Expression> arguments,
TokenType operator = TokenType.PERIOD]) =>
new MethodInvocation(
astFactory.methodInvocation(
target,
target == null ? null : TokenFactory.tokenFromType(operator),
identifier3(methodName),
@ -909,7 +914,7 @@ class AstTestFactory {
Expression target, String methodName, TypeArgumentList typeArguments,
[List<Expression> arguments,
TokenType operator = TokenType.PERIOD]) =>
new MethodInvocation(
astFactory.methodInvocation(
target,
target == null ? null : TokenFactory.tokenFromType(operator),
identifier3(methodName),
@ -917,7 +922,7 @@ class AstTestFactory {
argumentList(arguments));
static NamedExpression namedExpression(Label label, Expression expression) =>
new NamedExpression(label, expression);
astFactory.namedExpression(label, expression);
static NamedExpression namedExpression2(
String label, Expression expression) =>
@ -925,7 +930,7 @@ class AstTestFactory {
static DefaultFormalParameter namedFormalParameter(
NormalFormalParameter parameter, Expression expression) =>
new DefaultFormalParameter(
astFactory.defaultFormalParameter(
parameter,
ParameterKind.NAMED,
expression == null
@ -933,27 +938,28 @@ class AstTestFactory {
: TokenFactory.tokenFromType(TokenType.COLON),
expression);
static NativeClause nativeClause(String nativeCode) => new NativeClause(
TokenFactory.tokenFromString("native"), string2(nativeCode));
static NativeClause nativeClause(String nativeCode) =>
astFactory.nativeClause(
TokenFactory.tokenFromString("native"), string2(nativeCode));
static NativeFunctionBody nativeFunctionBody(String nativeMethodName) =>
new NativeFunctionBody(
astFactory.nativeFunctionBody(
TokenFactory.tokenFromString("native"),
string2(nativeMethodName),
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static NullLiteral nullLiteral() =>
new NullLiteral(TokenFactory.tokenFromKeyword(Keyword.NULL));
astFactory.nullLiteral(TokenFactory.tokenFromKeyword(Keyword.NULL));
static ParenthesizedExpression parenthesizedExpression(
Expression expression) =>
new ParenthesizedExpression(
astFactory.parenthesizedExpression(
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
expression,
TokenFactory.tokenFromType(TokenType.CLOSE_PAREN));
static PartDirective partDirective(List<Annotation> metadata, String url) =>
new PartDirective(
astFactory.partDirective(
null,
metadata,
TokenFactory.tokenFromKeyword(Keyword.PART),
@ -968,7 +974,7 @@ class AstTestFactory {
static PartOfDirective partOfDirective2(
List<Annotation> metadata, LibraryIdentifier libraryName) =>
new PartOfDirective(
astFactory.partOfDirective(
null,
metadata,
TokenFactory.tokenFromKeyword(Keyword.PART),
@ -979,7 +985,7 @@ class AstTestFactory {
static DefaultFormalParameter positionalFormalParameter(
NormalFormalParameter parameter, Expression expression) =>
new DefaultFormalParameter(
astFactory.defaultFormalParameter(
parameter,
ParameterKind.POSITIONAL,
expression == null ? null : TokenFactory.tokenFromType(TokenType.EQ),
@ -987,20 +993,22 @@ class AstTestFactory {
static PostfixExpression postfixExpression(
Expression expression, TokenType operator) =>
new PostfixExpression(expression, TokenFactory.tokenFromType(operator));
astFactory.postfixExpression(
expression, TokenFactory.tokenFromType(operator));
static PrefixExpression prefixExpression(
TokenType operator, Expression expression) =>
new PrefixExpression(TokenFactory.tokenFromType(operator), expression);
astFactory.prefixExpression(
TokenFactory.tokenFromType(operator), expression);
static PropertyAccess propertyAccess(
Expression target, SimpleIdentifier propertyName) =>
new PropertyAccess(
astFactory.propertyAccess(
target, TokenFactory.tokenFromType(TokenType.PERIOD), propertyName);
static PropertyAccess propertyAccess2(Expression target, String propertyName,
[TokenType operator = TokenType.PERIOD]) =>
new PropertyAccess(target, TokenFactory.tokenFromType(operator),
astFactory.propertyAccess(target, TokenFactory.tokenFromType(operator),
identifier3(propertyName));
static RedirectingConstructorInvocation redirectingConstructorInvocation(
@ -1010,7 +1018,7 @@ class AstTestFactory {
static RedirectingConstructorInvocation redirectingConstructorInvocation2(
String constructorName,
[List<Expression> arguments]) =>
new RedirectingConstructorInvocation(
astFactory.redirectingConstructorInvocation(
TokenFactory.tokenFromKeyword(Keyword.THIS),
constructorName == null
? null
@ -1018,23 +1026,24 @@ class AstTestFactory {
constructorName == null ? null : identifier3(constructorName),
argumentList(arguments));
static RethrowExpression rethrowExpression() =>
new RethrowExpression(TokenFactory.tokenFromKeyword(Keyword.RETHROW));
static RethrowExpression rethrowExpression() => astFactory
.rethrowExpression(TokenFactory.tokenFromKeyword(Keyword.RETHROW));
static ReturnStatement returnStatement() => returnStatement2(null);
static ReturnStatement returnStatement2(Expression expression) =>
new ReturnStatement(TokenFactory.tokenFromKeyword(Keyword.RETURN),
astFactory.returnStatement(TokenFactory.tokenFromKeyword(Keyword.RETURN),
expression, TokenFactory.tokenFromType(TokenType.SEMICOLON));
static ScriptTag scriptTag(String scriptTag) =>
new ScriptTag(TokenFactory.tokenFromString(scriptTag));
astFactory.scriptTag(TokenFactory.tokenFromString(scriptTag));
static ShowCombinator showCombinator(List<SimpleIdentifier> identifiers) =>
new ShowCombinator(TokenFactory.tokenFromString("show"), identifiers);
astFactory.showCombinator(
TokenFactory.tokenFromString("show"), identifiers);
static ShowCombinator showCombinator2(List<String> identifiers) =>
new ShowCombinator(
astFactory.showCombinator(
TokenFactory.tokenFromString("show"), identifierList(identifiers));
static SimpleFormalParameter simpleFormalParameter(
@ -1043,7 +1052,7 @@ class AstTestFactory {
static SimpleFormalParameter simpleFormalParameter2(
Keyword keyword, TypeName type, String parameterName) =>
new SimpleFormalParameter(
astFactory.simpleFormalParameter(
null,
null,
keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
@ -1058,10 +1067,10 @@ class AstTestFactory {
simpleFormalParameter2(null, type, parameterName);
static StringInterpolation string([List<InterpolationElement> elements]) =>
new StringInterpolation(elements);
astFactory.stringInterpolation(elements);
static SimpleStringLiteral string2(String content) => new SimpleStringLiteral(
TokenFactory.tokenFromString("'$content'"), content);
static SimpleStringLiteral string2(String content) => astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'$content'"), content);
static SuperConstructorInvocation superConstructorInvocation(
[List<Expression> arguments]) =>
@ -1069,14 +1078,14 @@ class AstTestFactory {
static SuperConstructorInvocation superConstructorInvocation2(String name,
[List<Expression> arguments]) =>
new SuperConstructorInvocation(
astFactory.superConstructorInvocation(
TokenFactory.tokenFromKeyword(Keyword.SUPER),
name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD),
name == null ? null : identifier3(name),
argumentList(arguments));
static SuperExpression superExpression() =>
new SuperExpression(TokenFactory.tokenFromKeyword(Keyword.SUPER));
astFactory.superExpression(TokenFactory.tokenFromKeyword(Keyword.SUPER));
static SwitchCase switchCase(
Expression expression, List<Statement> statements) =>
@ -1084,20 +1093,23 @@ class AstTestFactory {
static SwitchCase switchCase2(List<Label> labels, Expression expression,
List<Statement> statements) =>
new SwitchCase(labels, TokenFactory.tokenFromKeyword(Keyword.CASE),
astFactory.switchCase(labels, TokenFactory.tokenFromKeyword(Keyword.CASE),
expression, TokenFactory.tokenFromType(TokenType.COLON), statements);
static SwitchDefault switchDefault(
List<Label> labels, List<Statement> statements) =>
new SwitchDefault(labels, TokenFactory.tokenFromKeyword(Keyword.DEFAULT),
TokenFactory.tokenFromType(TokenType.COLON), statements);
astFactory.switchDefault(
labels,
TokenFactory.tokenFromKeyword(Keyword.DEFAULT),
TokenFactory.tokenFromType(TokenType.COLON),
statements);
static SwitchDefault switchDefault2(List<Statement> statements) =>
switchDefault(new List<Label>(), statements);
static SwitchStatement switchStatement(
Expression expression, List<SwitchMember> members) =>
new SwitchStatement(
astFactory.switchStatement(
TokenFactory.tokenFromKeyword(Keyword.SWITCH),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
expression,
@ -1112,38 +1124,38 @@ class AstTestFactory {
identifierList.add(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, component));
}
return new SymbolLiteral(
return astFactory.symbolLiteral(
TokenFactory.tokenFromType(TokenType.HASH), identifierList);
}
static BlockFunctionBody syncBlockFunctionBody(
[List<Statement> statements]) =>
new BlockFunctionBody(
astFactory.blockFunctionBody(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "sync"),
null,
block(statements));
static BlockFunctionBody syncGeneratorBlockFunctionBody(
[List<Statement> statements]) =>
new BlockFunctionBody(
astFactory.blockFunctionBody(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "sync"),
TokenFactory.tokenFromType(TokenType.STAR),
block(statements));
static ThisExpression thisExpression() =>
new ThisExpression(TokenFactory.tokenFromKeyword(Keyword.THIS));
astFactory.thisExpression(TokenFactory.tokenFromKeyword(Keyword.THIS));
static ThrowExpression throwExpression() => throwExpression2(null);
static ThrowExpression throwExpression2(Expression expression) =>
new ThrowExpression(
astFactory.throwExpression(
TokenFactory.tokenFromKeyword(Keyword.THROW), expression);
static TopLevelVariableDeclaration topLevelVariableDeclaration(
Keyword keyword,
TypeName type,
List<VariableDeclaration> variables) =>
new TopLevelVariableDeclaration(
astFactory.topLevelVariableDeclaration(
null,
null,
variableDeclarationList(keyword, type, variables),
@ -1151,7 +1163,7 @@ class AstTestFactory {
static TopLevelVariableDeclaration topLevelVariableDeclaration2(
Keyword keyword, List<VariableDeclaration> variables) =>
new TopLevelVariableDeclaration(
astFactory.topLevelVariableDeclaration(
null,
null,
variableDeclarationList(keyword, null, variables),
@ -1166,7 +1178,7 @@ class AstTestFactory {
static TryStatement tryStatement3(
Block body, List<CatchClause> catchClauses, Block finallyClause) =>
new TryStatement(
astFactory.tryStatement(
TokenFactory.tokenFromKeyword(Keyword.TRY),
body,
catchClauses,
@ -1177,7 +1189,7 @@ class AstTestFactory {
static FunctionTypeAlias typeAlias(TypeName returnType, String name,
TypeParameterList typeParameters, FormalParameterList parameters) =>
new FunctionTypeAlias(
astFactory.functionTypeAlias(
null,
null,
TokenFactory.tokenFromKeyword(Keyword.TYPEDEF),
@ -1191,7 +1203,7 @@ class AstTestFactory {
if (typeNames == null || typeNames.length == 0) {
return null;
}
return new TypeArgumentList(TokenFactory.tokenFromType(TokenType.LT),
return astFactory.typeArgumentList(TokenFactory.tokenFromType(TokenType.LT),
typeNames, TokenFactory.tokenFromType(TokenType.GT));
}
@ -1211,16 +1223,16 @@ class AstTestFactory {
}
static TypeName typeName3(Identifier name, [List<TypeName> arguments]) =>
new TypeName(name, typeArgumentList(arguments));
astFactory.typeName(name, typeArgumentList(arguments));
static TypeName typeName4(String name, [List<TypeName> arguments]) =>
new TypeName(identifier3(name), typeArgumentList(arguments));
astFactory.typeName(identifier3(name), typeArgumentList(arguments));
static TypeParameter typeParameter(String name) =>
new TypeParameter(null, null, identifier3(name), null, null);
astFactory.typeParameter(null, null, identifier3(name), null, null);
static TypeParameter typeParameter2(String name, TypeName bound) =>
new TypeParameter(null, null, identifier3(name),
astFactory.typeParameter(null, null, identifier3(name),
TokenFactory.tokenFromKeyword(Keyword.EXTENDS), bound);
static TypeParameterList typeParameterList([List<String> typeNames]) {
@ -1231,21 +1243,23 @@ class AstTestFactory {
typeParameters.add(typeParameter(typeName));
}
}
return new TypeParameterList(TokenFactory.tokenFromType(TokenType.LT),
typeParameters, TokenFactory.tokenFromType(TokenType.GT));
return astFactory.typeParameterList(
TokenFactory.tokenFromType(TokenType.LT),
typeParameters,
TokenFactory.tokenFromType(TokenType.GT));
}
static VariableDeclaration variableDeclaration(String name) =>
new VariableDeclaration(identifier3(name), null, null);
astFactory.variableDeclaration(identifier3(name), null, null);
static VariableDeclaration variableDeclaration2(
String name, Expression initializer) =>
new VariableDeclaration(identifier3(name),
astFactory.variableDeclaration(identifier3(name),
TokenFactory.tokenFromType(TokenType.EQ), initializer);
static VariableDeclarationList variableDeclarationList(Keyword keyword,
TypeName type, List<VariableDeclaration> variables) =>
new VariableDeclarationList(
astFactory.variableDeclarationList(
null,
null,
keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
@ -1260,7 +1274,7 @@ class AstTestFactory {
Keyword keyword,
TypeName type,
List<VariableDeclaration> variables) =>
new VariableDeclarationStatement(
astFactory.variableDeclarationStatement(
variableDeclarationList(keyword, type, variables),
TokenFactory.tokenFromType(TokenType.SEMICOLON));
@ -1269,7 +1283,7 @@ class AstTestFactory {
variableDeclarationStatement(keyword, null, variables);
static WhileStatement whileStatement(Expression condition, Statement body) =>
new WhileStatement(
astFactory.whileStatement(
TokenFactory.tokenFromKeyword(Keyword.WHILE),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
condition,
@ -1277,17 +1291,17 @@ class AstTestFactory {
body);
static WithClause withClause(List<TypeName> types) =>
new WithClause(TokenFactory.tokenFromKeyword(Keyword.WITH), types);
astFactory.withClause(TokenFactory.tokenFromKeyword(Keyword.WITH), types);
static YieldStatement yieldEachStatement(Expression expression) =>
new YieldStatement(
astFactory.yieldStatement(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"),
TokenFactory.tokenFromType(TokenType.STAR),
expression,
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static YieldStatement yieldStatement(Expression expression) =>
new YieldStatement(
astFactory.yieldStatement(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"),
null,
expression,

View file

@ -7,6 +7,7 @@ library summary_resynthesizer;
import 'dart:collection';
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';
@ -588,9 +589,9 @@ class _ConstExprBuilder {
InterpolationElement _newInterpolationElement(Expression expr) {
if (expr is SimpleStringLiteral) {
return new InterpolationString(expr.literal, expr.value);
return astFactory.interpolationString(expr.literal, expr.value);
} else {
return new InterpolationExpression(
return astFactory.interpolationExpression(
TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION),
expr,
TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET));
@ -714,7 +715,7 @@ class _ConstExprBuilder {
typeArguments = AstTestFactory.typeArgumentList(typeNames);
}
if (node is SimpleIdentifier) {
_push(new MethodInvocation(
_push(astFactory.methodInvocation(
null,
TokenFactory.tokenFromType(TokenType.PERIOD),
node,

View file

@ -5,6 +5,7 @@
library analyzer.test.dart.ast.ast_test;
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/testing/ast_test_factory.dart';
@ -365,7 +366,7 @@ class NodeListTest extends EngineTestCase {
AstNode parent = AstTestFactory.argumentList();
AstNode firstNode = AstTestFactory.booleanLiteral(true);
AstNode secondNode = AstTestFactory.booleanLiteral(false);
NodeList<AstNode> list = new NodeList<AstNode>(parent);
NodeList<AstNode> list = astFactory.nodeList/*<AstNode>*/(parent);
list.insert(0, secondNode);
list.insert(0, firstNode);
expect(list, hasLength(2));
@ -386,7 +387,7 @@ class NodeListTest extends EngineTestCase {
void test_add_negative() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list.insert(-1, AstTestFactory.booleanLiteral(true));
fail("Expected IndexOutOfBoundsException");
@ -397,7 +398,7 @@ class NodeListTest extends EngineTestCase {
void test_add_tooBig() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list.insert(1, AstTestFactory.booleanLiteral(true));
fail("Expected IndexOutOfBoundsException");
@ -413,7 +414,7 @@ class NodeListTest extends EngineTestCase {
AstNode secondNode = AstTestFactory.booleanLiteral(false);
firstNodes.add(firstNode);
firstNodes.add(secondNode);
NodeList<AstNode> list = new NodeList<AstNode>(parent);
NodeList<AstNode> list = astFactory.nodeList/*<AstNode>*/(parent);
list.addAll(firstNodes);
expect(list, hasLength(2));
expect(list[0], same(firstNode));
@ -439,7 +440,7 @@ class NodeListTest extends EngineTestCase {
void test_creation() {
AstNode owner = AstTestFactory.argumentList();
NodeList<AstNode> list = new NodeList<AstNode>(owner);
NodeList<AstNode> list = astFactory.nodeList/*<AstNode>*/(owner);
expect(list, isNotNull);
expect(list, hasLength(0));
expect(list.owner, same(owner));
@ -447,7 +448,7 @@ class NodeListTest extends EngineTestCase {
void test_get_negative() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list[-1];
fail("Expected IndexOutOfBoundsException");
@ -458,7 +459,7 @@ class NodeListTest extends EngineTestCase {
void test_get_tooBig() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list[1];
fail("Expected IndexOutOfBoundsException");
@ -469,13 +470,13 @@ class NodeListTest extends EngineTestCase {
void test_getBeginToken_empty() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
expect(list.beginToken, isNull);
}
void test_getBeginToken_nonEmpty() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
AstNode node = AstTestFactory
.parenthesizedExpression(AstTestFactory.booleanLiteral(true));
list.add(node);
@ -484,13 +485,13 @@ class NodeListTest extends EngineTestCase {
void test_getEndToken_empty() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
expect(list.endToken, isNull);
}
void test_getEndToken_nonEmpty() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
AstNode node = AstTestFactory
.parenthesizedExpression(AstTestFactory.booleanLiteral(true));
list.add(node);
@ -507,7 +508,7 @@ class NodeListTest extends EngineTestCase {
nodes.add(secondNode);
nodes.add(thirdNode);
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
list.addAll(nodes);
expect(list, hasLength(3));
expect(list.indexOf(firstNode), 0);
@ -526,7 +527,7 @@ class NodeListTest extends EngineTestCase {
nodes.add(secondNode);
nodes.add(thirdNode);
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
list.addAll(nodes);
expect(list, hasLength(3));
expect(list.removeAt(1), same(secondNode));
@ -537,7 +538,7 @@ class NodeListTest extends EngineTestCase {
void test_remove_negative() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list.removeAt(-1);
fail("Expected IndexOutOfBoundsException");
@ -548,7 +549,7 @@ class NodeListTest extends EngineTestCase {
void test_remove_tooBig() {
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list.removeAt(1);
fail("Expected IndexOutOfBoundsException");
@ -566,7 +567,7 @@ class NodeListTest extends EngineTestCase {
nodes.add(secondNode);
nodes.add(thirdNode);
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
list.addAll(nodes);
expect(list, hasLength(3));
AstNode fourthNode = AstTestFactory.integer(0);
@ -580,7 +581,7 @@ class NodeListTest extends EngineTestCase {
void test_set_negative() {
AstNode node = AstTestFactory.booleanLiteral(true);
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list[-1] = node;
fail("Expected IndexOutOfBoundsException");
@ -592,7 +593,7 @@ class NodeListTest extends EngineTestCase {
void test_set_tooBig() {
AstNode node = AstTestFactory.booleanLiteral(true);
NodeList<AstNode> list =
new NodeList<AstNode>(AstTestFactory.argumentList());
astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList());
try {
list[1] = node;
fail("Expected IndexOutOfBoundsException");
@ -795,47 +796,57 @@ class SimpleIdentifierTest extends ParserTestCase {
class SimpleStringLiteralTest extends ParserTestCase {
void test_contentsEnd() {
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
.contentsEnd,
2);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString('"X"'), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString('"X"'), "X")
.contentsEnd,
2);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString('"""X"""'), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString('"""X"""'), "X")
.contentsEnd,
4);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
.contentsEnd,
4);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("''' \nX'''"), "X")
.contentsEnd,
7);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
.contentsEnd,
3);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString('r"X"'), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString('r"X"'), "X")
.contentsEnd,
3);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString('r"""X"""'), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString('r"""X"""'), "X")
.contentsEnd,
5);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
.contentsEnd,
5);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("r''' \nX'''"), "X")
.contentsEnd,
8);
@ -843,47 +854,57 @@ class SimpleStringLiteralTest extends ParserTestCase {
void test_contentsOffset() {
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
.contentsOffset,
1);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
.contentsOffset,
1);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X")
.contentsOffset,
3);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
.contentsOffset,
3);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
.contentsOffset,
2);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
.contentsOffset,
2);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X")
.contentsOffset,
4);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
.contentsOffset,
4);
// leading whitespace
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("''' \ \nX''"), "X")
.contentsOffset,
6);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString('r""" \ \nX"""'), "X")
.contentsOffset,
7);
@ -891,36 +912,44 @@ class SimpleStringLiteralTest extends ParserTestCase {
void test_isMultiline() {
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
.isMultiline,
isFalse);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
.isMultiline,
isFalse);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
.isMultiline,
isFalse);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
.isMultiline,
isFalse);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
.isMultiline,
isTrue);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
.isMultiline,
isTrue);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X")
.isMultiline,
isTrue);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X")
.isMultiline,
isTrue);
@ -928,36 +957,45 @@ class SimpleStringLiteralTest extends ParserTestCase {
void test_isRaw() {
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isRaw,
isFalse);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
.isRaw,
isFalse);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
.isRaw,
isFalse);
expect(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X")
.isRaw,
isFalse);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
.isRaw,
isFalse);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
.isRaw,
isTrue);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
.isRaw,
isTrue);
expect(
new SimpleStringLiteral(
astFactory
.simpleStringLiteral(
TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X")
.isRaw,
isTrue);
expect(
new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
astFactory
.simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
.isRaw,
isTrue);
}
@ -966,25 +1004,25 @@ class SimpleStringLiteralTest extends ParserTestCase {
// '
{
var token = TokenFactory.tokenFromString("'X'");
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isTrue);
}
// '''
{
var token = TokenFactory.tokenFromString("'''X'''");
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isTrue);
}
// "
{
var token = TokenFactory.tokenFromString('"X"');
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isFalse);
}
// """
{
var token = TokenFactory.tokenFromString('"""X"""');
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isFalse);
}
}
@ -993,32 +1031,33 @@ class SimpleStringLiteralTest extends ParserTestCase {
// r'
{
var token = TokenFactory.tokenFromString("r'X'");
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isTrue);
}
// r'''
{
var token = TokenFactory.tokenFromString("r'''X'''");
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isTrue);
}
// r"
{
var token = TokenFactory.tokenFromString('r"X"');
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isFalse);
}
// r"""
{
var token = TokenFactory.tokenFromString('r"""X"""');
var node = new SimpleStringLiteral(token, null);
var node = astFactory.simpleStringLiteral(token, null);
expect(node.isSingleQuoted, isFalse);
}
}
void test_simple() {
Token token = TokenFactory.tokenFromString("'value'");
SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value");
SimpleStringLiteral stringLiteral =
astFactory.simpleStringLiteral(token, "value");
expect(stringLiteral.literal, same(token));
expect(stringLiteral.beginToken, same(token));
expect(stringLiteral.endToken, same(token));
@ -1034,7 +1073,7 @@ class StringInterpolationTest extends ParserTestCase {
{
var ae = AstTestFactory.interpolationString("'a", "a");
var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
var cElement = new InterpolationString(cToken, 'ccc');
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 1);
expect(node.contentsEnd, 10 + 4 - 1);
@ -1043,7 +1082,7 @@ class StringInterpolationTest extends ParserTestCase {
{
var ae = AstTestFactory.interpolationString("'''a", "a");
var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
var cElement = new InterpolationString(cToken, 'ccc');
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 3);
expect(node.contentsEnd, 10 + 4 - 1);
@ -1052,7 +1091,7 @@ class StringInterpolationTest extends ParserTestCase {
{
var ae = AstTestFactory.interpolationString('"""a', "a");
var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
var cElement = new InterpolationString(cToken, 'ccc');
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 3);
expect(node.contentsEnd, 10 + 4 - 1);
@ -1061,7 +1100,7 @@ class StringInterpolationTest extends ParserTestCase {
{
var ae = AstTestFactory.interpolationString("r'a", "a");
var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
var cElement = new InterpolationString(cToken, 'ccc');
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 2);
expect(node.contentsEnd, 10 + 4 - 1);
@ -1070,7 +1109,7 @@ class StringInterpolationTest extends ParserTestCase {
{
var ae = AstTestFactory.interpolationString("r'''a", "a");
var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
var cElement = new InterpolationString(cToken, 'ccc');
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 4);
expect(node.contentsEnd, 10 + 4 - 1);
@ -1079,7 +1118,7 @@ class StringInterpolationTest extends ParserTestCase {
{
var ae = AstTestFactory.interpolationString('r"""a', "a");
var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
var cElement = new InterpolationString(cToken, 'ccc');
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 4);
expect(node.contentsEnd, 10 + 4 - 1);
@ -1164,7 +1203,7 @@ class VariableDeclarationTest extends ParserTestCase {
VariableDeclaration varDecl = AstTestFactory.variableDeclaration("a");
TopLevelVariableDeclaration decl =
AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]);
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Comment comment = astFactory.documentationComment(new List<Token>(0));
expect(varDecl.documentationComment, isNull);
decl.documentationComment = comment;
expect(varDecl.documentationComment, isNotNull);
@ -1173,7 +1212,7 @@ class VariableDeclarationTest extends ParserTestCase {
void test_getDocumentationComment_onNode() {
VariableDeclaration decl = AstTestFactory.variableDeclaration("a");
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Comment comment = astFactory.documentationComment(new List<Token>(0));
decl.documentationComment = comment;
expect(decl.documentationComment, isNotNull);
}

View file

@ -5,6 +5,7 @@
library analyzer.test.dart.element.builder_test;
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/ast.dart';
@ -251,7 +252,7 @@ class C {
TopLevelVariableDeclaration topLevelVariableDeclaration = AstTestFactory
.topLevelVariableDeclaration(null, AstTestFactory.typeName4('int'),
[AstTestFactory.variableDeclaration('V')]);
CompilationUnit unit = new CompilationUnit(
CompilationUnit unit = astFactory.compilationUnit(
topLevelVariableDeclaration.beginToken,
null,
[],

View file

@ -5,6 +5,7 @@
library analyzer.test.generated.element_resolver_test;
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';
@ -546,7 +547,8 @@ class ElementResolverTest extends EngineTestCase {
..defineNameWithoutChecking('A', classA);
// prepare "A.p"
PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'p');
CommentReference commentReference = new CommentReference(null, prefixed);
CommentReference commentReference =
astFactory.commentReference(null, prefixed);
// resolve
_resolveNode(commentReference);
expect(prefixed.prefix.staticElement, classA);
@ -565,7 +567,8 @@ class ElementResolverTest extends EngineTestCase {
..defineNameWithoutChecking('A', classA);
// prepare "A.m"
PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'm');
CommentReference commentReference = new CommentReference(null, prefixed);
CommentReference commentReference =
astFactory.commentReference(null, prefixed);
// resolve
_resolveNode(commentReference);
expect(prefixed.prefix.staticElement, classA);
@ -584,7 +587,8 @@ class ElementResolverTest extends EngineTestCase {
..defineNameWithoutChecking('A', classA);
// prepare "A.=="
PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', '==');
CommentReference commentReference = new CommentReference(null, prefixed);
CommentReference commentReference =
astFactory.commentReference(null, prefixed);
// resolve
_resolveNode(commentReference);
expect(prefixed.prefix.staticElement, classA);

View file

@ -5,6 +5,7 @@
library analyzer.test.generated.parser_test;
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/error/error.dart';
@ -5066,7 +5067,7 @@ class SimpleParserTest extends ParserTestCase {
void test_parseAssignableSelector_none() {
createParser(';');
Expression expression =
parser.parseAssignableSelector(new SimpleIdentifier(null), true);
parser.parseAssignableSelector(astFactory.simpleIdentifier(null), true);
expectNotNullIfNoErrors(expression);
listener.assertNoErrors();
expect(expression, new isInstanceOf<SimpleIdentifier>());
@ -9423,8 +9424,9 @@ void''');
}
void test_parseFunctionDeclaration_function() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('f() {}');
FunctionDeclaration declaration = parser.parseFunctionDeclaration(
commentAndMetadata(comment), null, returnType);
@ -9442,8 +9444,9 @@ void''');
}
void test_parseFunctionDeclaration_functionWithTypeParameters() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('f<E>() {}');
FunctionDeclaration declaration = parser.parseFunctionDeclaration(
commentAndMetadata(comment), null, returnType);
@ -9462,8 +9465,9 @@ void''');
void test_parseFunctionDeclaration_functionWithTypeParameters_comment() {
enableGenericMethodComments = true;
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('f/*<E>*/() {}');
FunctionDeclaration declaration = parser.parseFunctionDeclaration(
commentAndMetadata(comment), null, returnType);
@ -9481,8 +9485,9 @@ void''');
}
void test_parseFunctionDeclaration_getter() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('get p => 0;');
FunctionDeclaration declaration = parser.parseFunctionDeclaration(
commentAndMetadata(comment), null, returnType);
@ -9500,8 +9505,9 @@ void''');
}
void test_parseFunctionDeclaration_setter() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('set p(v) {}');
FunctionDeclaration declaration = parser.parseFunctionDeclaration(
commentAndMetadata(comment), null, returnType);
@ -9590,8 +9596,9 @@ void''');
}
void test_parseGetter_nonStatic() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('get a;');
MethodDeclaration method =
parser.parseGetter(commentAndMetadata(comment), null, null, returnType);
@ -9609,9 +9616,10 @@ void''');
}
void test_parseGetter_static() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Comment comment = astFactory.documentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('get a => 42;');
MethodDeclaration method = parser.parseGetter(
commentAndMetadata(comment), null, staticKeyword, returnType);
@ -9860,9 +9868,10 @@ void''');
}
void test_parseInitializedIdentifierList_type() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Comment comment = astFactory.documentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
TypeName type = new TypeName(new SimpleIdentifier(null), null);
TypeName type =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser("a = 1, b, c = 3;");
FieldDeclaration declaration = parser.parseInitializedIdentifierList(
commentAndMetadata(comment), staticKeyword, null, type);
@ -9879,7 +9888,7 @@ void''');
}
void test_parseInitializedIdentifierList_var() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Comment comment = astFactory.documentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR);
createParser('a = 1, b, c = 3;');
@ -11071,8 +11080,9 @@ void''');
}
void test_parseOperator() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('operator +(A a);');
MethodDeclaration method =
parser.parseOperator(commentAndMetadata(comment), null, returnType);
@ -11729,8 +11739,9 @@ void''');
}
void test_parseSetter_nonStatic() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
Comment comment = astFactory.documentationComment(new List<Token>(0));
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('set a(var x);');
MethodDeclaration method =
parser.parseSetter(commentAndMetadata(comment), null, null, returnType);
@ -11749,9 +11760,10 @@ void''');
}
void test_parseSetter_static() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Comment comment = astFactory.documentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
TypeName returnType =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('set a(var x) {}');
MethodDeclaration method = parser.parseSetter(
commentAndMetadata(comment), null, staticKeyword, returnType);
@ -13118,7 +13130,8 @@ void''');
}
void test_parseVariableDeclarationListAfterType_type() {
TypeName type = new TypeName(new SimpleIdentifier(null), null);
TypeName type =
astFactory.typeName(astFactory.simpleIdentifier(null), null);
createParser('a');
VariableDeclarationList declarationList =
parser.parseVariableDeclarationListAfterType(

View file

@ -7,6 +7,7 @@ library analyzer.test.generated.resolver_test;
import 'dart:collection';
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/dart/element/element.dart';
@ -3462,7 +3463,7 @@ A v = new A();
void test_visitTypeName_noParameters_noArguments_undefined() {
SimpleIdentifier id = AstTestFactory.identifier3("unknown")
..staticElement = new _StaleElement();
TypeName typeName = new TypeName(id, null);
TypeName typeName = astFactory.typeName(id, null);
_resolveNode(typeName, []);
expect(typeName.type, UndefinedTypeImpl.instance);
expect(typeName.name.staticElement, null);
@ -3503,7 +3504,7 @@ A v = new A();
SimpleIdentifier suffix = AstTestFactory.identifier3("unknownSuffix")
..staticElement = new _StaleElement();
TypeName typeName =
new TypeName(AstTestFactory.identifier(prefix, suffix), null);
astFactory.typeName(AstTestFactory.identifier(prefix, suffix), null);
_resolveNode(typeName, []);
expect(typeName.type, UndefinedTypeImpl.instance);
expect(prefix.staticElement, null);

View file

@ -7,6 +7,7 @@ library analyzer.test.generated.utilities_test;
import 'dart:collection';
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';
@ -1606,7 +1607,7 @@ class ExceptionHandlingDelegatingAstVisitorTest extends EngineTestCase {
dynamic exception, StackTrace stackTrace) {
handlerInvoked = true;
});
new NullLiteral(null).accept(visitor);
astFactory.nullLiteral(null).accept(visitor);
expect(handlerInvoked, isTrue);
}
}
@ -3063,8 +3064,7 @@ class NodeReplacerTest extends EngineTestCase {
AstTestFactory.fieldDeclaration2(
false, null, [AstTestFactory.variableDeclaration("f")])
]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
node.nativeClause = AstTestFactory.nativeClause("");
@ -3087,8 +3087,7 @@ class NodeReplacerTest extends EngineTestCase {
AstTestFactory.typeName4("B"),
AstTestFactory.withClause([AstTestFactory.typeName4("C")]),
AstTestFactory.implementsClause([AstTestFactory.typeName4("D")]));
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_classTypeAlias_4());
@ -3100,15 +3099,15 @@ class NodeReplacerTest extends EngineTestCase {
}
void test_comment() {
Comment node = Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.references
.add(new CommentReference(null, AstTestFactory.identifier3("x")));
Comment node = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.references.add(
astFactory.commentReference(null, AstTestFactory.identifier3("x")));
_assertReplace(node, new ListGetter_NodeReplacerTest_test_comment(0));
}
void test_commentReference() {
CommentReference node =
new CommentReference(null, AstTestFactory.identifier3("x"));
astFactory.commentReference(null, AstTestFactory.identifier3("x"));
_assertReplace(node, new Getter_NodeReplacerTest_test_commentReference());
}
@ -3151,8 +3150,7 @@ class NodeReplacerTest extends EngineTestCase {
false, "x", AstTestFactory.integer(0))
],
AstTestFactory.emptyFunctionBody());
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
node.redirectedConstructor =
@ -3196,8 +3194,7 @@ class NodeReplacerTest extends EngineTestCase {
void test_declaredIdentifier() {
DeclaredIdentifier node =
AstTestFactory.declaredIdentifier4(AstTestFactory.typeName4("C"), "i");
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_declaredIdentifier());
@ -3223,8 +3220,8 @@ class NodeReplacerTest extends EngineTestCase {
}
void test_enumConstantDeclaration() {
EnumConstantDeclaration node = new EnumConstantDeclaration(
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST),
EnumConstantDeclaration node = astFactory.enumConstantDeclaration(
astFactory.endOfLineComment(EMPTY_TOKEN_LIST),
[AstTestFactory.annotation(AstTestFactory.identifier3("a"))],
AstTestFactory.identifier3("C"));
_assertReplace(
@ -3234,8 +3231,7 @@ class NodeReplacerTest extends EngineTestCase {
void test_enumDeclaration() {
EnumDeclaration node = AstTestFactory.enumDeclaration2("E", ["ONE", "TWO"]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_enumDeclaration());
@ -3246,8 +3242,7 @@ class NodeReplacerTest extends EngineTestCase {
ExportDirective node = AstTestFactory.exportDirective2("", [
AstTestFactory.hideCombinator2(["C"])
]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_testNamespaceDirective(node);
@ -3279,8 +3274,7 @@ class NodeReplacerTest extends EngineTestCase {
null,
AstTestFactory.typeName4("C"),
[AstTestFactory.variableDeclaration("c")]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_fieldDeclaration());
@ -3293,8 +3287,7 @@ class NodeReplacerTest extends EngineTestCase {
AstTestFactory.typeName4("C"),
"f",
AstTestFactory.formalParameterList());
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata = [
AstTestFactory.annotation(AstTestFactory.identifier3("a"))
];
@ -3380,8 +3373,7 @@ class NodeReplacerTest extends EngineTestCase {
"f",
AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(),
AstTestFactory.blockFunctionBody(AstTestFactory.block())));
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(
@ -3431,8 +3423,7 @@ class NodeReplacerTest extends EngineTestCase {
"F",
AstTestFactory.typeParameterList(["E"]),
AstTestFactory.formalParameterList());
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(
@ -3449,8 +3440,7 @@ class NodeReplacerTest extends EngineTestCase {
FunctionTypedFormalParameter node = AstTestFactory
.functionTypedFormalParameter(AstTestFactory.typeName4("R"), "f",
[AstTestFactory.simpleFormalParameter3("p")]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata = [
AstTestFactory.annotation(AstTestFactory.identifier3("a"))
];
@ -3489,8 +3479,7 @@ class NodeReplacerTest extends EngineTestCase {
AstTestFactory.showCombinator2(["A"]),
AstTestFactory.hideCombinator2(["B"])
]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_importDirective());
@ -3542,8 +3531,7 @@ class NodeReplacerTest extends EngineTestCase {
void test_libraryDirective() {
LibraryDirective node = AstTestFactory.libraryDirective2("lib");
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_libraryDirective());
@ -3590,8 +3578,7 @@ class NodeReplacerTest extends EngineTestCase {
AstTestFactory.identifier3("m"),
AstTestFactory.formalParameterList(),
AstTestFactory.blockFunctionBody(AstTestFactory.block()));
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_methodDeclaration());
@ -3638,8 +3625,7 @@ class NodeReplacerTest extends EngineTestCase {
void test_partDirective() {
PartDirective node = AstTestFactory.partDirective2("");
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_testUriBasedDirective(node);
@ -3648,8 +3634,7 @@ class NodeReplacerTest extends EngineTestCase {
void test_partOfDirective() {
PartOfDirective node = AstTestFactory
.partOfDirective(AstTestFactory.libraryIdentifier2(["lib"]));
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(node, new Getter_NodeReplacerTest_test_partOfDirective());
@ -3706,8 +3691,7 @@ class NodeReplacerTest extends EngineTestCase {
void test_simpleFormalParameter() {
SimpleFormalParameter node = AstTestFactory.simpleFormalParameter4(
AstTestFactory.typeName4("T"), "p");
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata = [
AstTestFactory.annotation(AstTestFactory.identifier3("a"))
];
@ -3768,8 +3752,7 @@ class NodeReplacerTest extends EngineTestCase {
TopLevelVariableDeclaration node = AstTestFactory
.topLevelVariableDeclaration(null, AstTestFactory.typeName4("T"),
[AstTestFactory.variableDeclaration("t")]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(
@ -3819,8 +3802,7 @@ class NodeReplacerTest extends EngineTestCase {
void test_variableDeclaration() {
VariableDeclaration node =
AstTestFactory.variableDeclaration2("a", AstTestFactory.nullLiteral());
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(
@ -3835,8 +3817,7 @@ class NodeReplacerTest extends EngineTestCase {
null,
AstTestFactory.typeName4("T"),
[AstTestFactory.variableDeclaration("a")]);
node.documentationComment =
Comment.createEndOfLineComment(EMPTY_TOKEN_LIST);
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(

View file

@ -5,6 +5,7 @@
library analyzer.test.src.dart.ast.utilities_test;
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';
@ -437,9 +438,9 @@ class B {}''');
@reflectiveTest
class ResolutionCopierTest extends EngineTestCase {
void test_visitAdjacentStrings() {
AdjacentStrings createNode() => new AdjacentStrings([
new SimpleStringLiteral(null, 'hello'),
new SimpleStringLiteral(null, 'world')
AdjacentStrings createNode() => astFactory.adjacentStrings([
astFactory.simpleStringLiteral(null, 'hello'),
astFactory.simpleStringLiteral(null, 'world')
]);
AdjacentStrings fromNode = createNode();
@ -1555,13 +1556,13 @@ class ToSourceVisitor2Test extends EngineTestCase {
void test_visitComment() {
_assertSource(
"",
Comment.createBlockComment(
astFactory.blockComment(
<Token>[TokenFactory.tokenFromString("/* comment */")]));
}
void test_visitCommentReference() {
_assertSource(
"", new CommentReference(null, AstTestFactory.identifier3("a")));
"", astFactory.commentReference(null, AstTestFactory.identifier3("a")));
}
void test_visitCompilationUnit_declaration() {
@ -1947,7 +1948,7 @@ class ToSourceVisitor2Test extends EngineTestCase {
void test_visitFieldFormalParameter_functionTyped_typeParameters() {
_assertSource(
"A this.a<E, F>(b)",
new FieldFormalParameter(
astFactory.fieldFormalParameter(
null,
null,
null,
@ -1989,7 +1990,7 @@ class ToSourceVisitor2Test extends EngineTestCase {
void test_visitForEachStatement_variable() {
_assertSource(
"for (a in b) {}",
new ForEachStatement.withReference(
astFactory.forEachStatementWithReference(
null,
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
@ -2003,7 +2004,7 @@ class ToSourceVisitor2Test extends EngineTestCase {
void test_visitForEachStatement_variable_await() {
_assertSource(
"await for (a in b) {}",
new ForEachStatement.withReference(
astFactory.forEachStatementWithReference(
TokenFactory.tokenFromString("await"),
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
@ -2305,7 +2306,7 @@ class ToSourceVisitor2Test extends EngineTestCase {
FunctionDeclaration f = AstTestFactory.functionDeclaration(
null, null, "f", AstTestFactory.functionExpression());
FunctionDeclarationStatement fStatement =
new FunctionDeclarationStatement(f);
astFactory.functionDeclarationStatement(f);
_assertSource(
"main() {f() {} 42;}",
AstTestFactory.functionDeclaration(
@ -2328,7 +2329,7 @@ class ToSourceVisitor2Test extends EngineTestCase {
AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(),
AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1))));
FunctionDeclarationStatement fStatement =
new FunctionDeclarationStatement(f);
astFactory.functionDeclarationStatement(f);
_assertSource(
"main() {f() => 1; 2;}",
AstTestFactory.functionDeclaration(
@ -2464,7 +2465,7 @@ class ToSourceVisitor2Test extends EngineTestCase {
void test_visitFunctionTypedFormalParameter_typeParameters() {
_assertSource(
"T f<E>()",
new FunctionTypedFormalParameter(
astFactory.functionTypedFormalParameter(
null,
null,
AstTestFactory.typeName4("T"),
@ -3885,13 +3886,13 @@ class ToSourceVisitorTest extends EngineTestCase {
void test_visitComment() {
_assertSource(
"",
Comment.createBlockComment(
astFactory.blockComment(
<Token>[TokenFactory.tokenFromString("/* comment */")]));
}
void test_visitCommentReference() {
_assertSource(
"", new CommentReference(null, AstTestFactory.identifier3("a")));
"", astFactory.commentReference(null, AstTestFactory.identifier3("a")));
}
void test_visitCompilationUnit_declaration() {
@ -4277,7 +4278,7 @@ class ToSourceVisitorTest extends EngineTestCase {
void test_visitFieldFormalParameter_functionTyped_typeParameters() {
_assertSource(
"A this.a<E, F>(b)",
new FieldFormalParameter(
astFactory.fieldFormalParameter(
null,
null,
null,
@ -4319,7 +4320,7 @@ class ToSourceVisitorTest extends EngineTestCase {
void test_visitForEachStatement_variable() {
_assertSource(
"for (a in b) {}",
new ForEachStatement.withReference(
astFactory.forEachStatementWithReference(
null,
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
@ -4333,7 +4334,7 @@ class ToSourceVisitorTest extends EngineTestCase {
void test_visitForEachStatement_variable_await() {
_assertSource(
"await for (a in b) {}",
new ForEachStatement.withReference(
astFactory.forEachStatementWithReference(
TokenFactory.tokenFromString("await"),
TokenFactory.tokenFromKeyword(Keyword.FOR),
TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
@ -4635,7 +4636,7 @@ class ToSourceVisitorTest extends EngineTestCase {
FunctionDeclaration f = AstTestFactory.functionDeclaration(
null, null, "f", AstTestFactory.functionExpression());
FunctionDeclarationStatement fStatement =
new FunctionDeclarationStatement(f);
astFactory.functionDeclarationStatement(f);
_assertSource(
"main() {f() {} 42;}",
AstTestFactory.functionDeclaration(
@ -4658,7 +4659,7 @@ class ToSourceVisitorTest extends EngineTestCase {
AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(),
AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1))));
FunctionDeclarationStatement fStatement =
new FunctionDeclarationStatement(f);
astFactory.functionDeclarationStatement(f);
_assertSource(
"main() {f() => 1; 2;}",
AstTestFactory.functionDeclaration(
@ -4794,7 +4795,7 @@ class ToSourceVisitorTest extends EngineTestCase {
void test_visitFunctionTypedFormalParameter_typeParameters() {
_assertSource(
"T f<E>()",
new FunctionTypedFormalParameter(
astFactory.functionTypedFormalParameter(
null,
null,
AstTestFactory.typeName4("T"),

View file

@ -5,6 +5,7 @@
library analyzer.test.src.dart.constant.utilities_test;
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';
@ -65,7 +66,7 @@ class ConstantFinderTest {
// Analyzer ignores annotations on enum constant declarations.
Annotation annotation = AstTestFactory.annotation2(
AstTestFactory.identifier3('A'), null, AstTestFactory.argumentList());
_node = new EnumConstantDeclaration(
_node = astFactory.enumConstantDeclaration(
null, <Annotation>[annotation], AstTestFactory.identifier3('C'));
expect(_findConstants(), isEmpty);
}