Version 2.19.0-62.0.dev
Merge commit '8e1224da23fe579410f11219aff5cae86386325b' into 'dev'
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/1_issue_template.md
similarity index 100%
rename from .github/ISSUE_TEMPLATE.md
rename to .github/ISSUE_TEMPLATE/1_issue_template.md
diff --git a/.github/ISSUE_TEMPLATE/1_cherry_pick.yml b/.github/ISSUE_TEMPLATE/2_cherry_pick.yml
similarity index 100%
rename from .github/ISSUE_TEMPLATE/1_cherry_pick.yml
rename to .github/ISSUE_TEMPLATE/2_cherry_pick.yml
diff --git a/pkg/analyzer/lib/src/clients/dart_style/rewrite_cascade.dart b/pkg/analyzer/lib/src/clients/dart_style/rewrite_cascade.dart
index f79d178..d48d2dd 100644
--- a/pkg/analyzer/lib/src/clients/dart_style/rewrite_cascade.dart
+++ b/pkg/analyzer/lib/src/clients/dart_style/rewrite_cascade.dart
@@ -26,9 +26,9 @@
);
return astFactory.expressionStatement(
- astFactory.cascadeExpression(
- newTarget,
- cascadeExpression.cascadeSections,
+ CascadeExpressionImpl(
+ target: newTarget,
+ cascadeSections: cascadeExpression.cascadeSections,
),
expressionStatement.semicolon,
);
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index bd5a985..cd5207b 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -1231,7 +1231,10 @@
bool value = false;
/// Initialize a newly created boolean literal.
- BooleanLiteralImpl(this.literal, this.value);
+ BooleanLiteralImpl({
+ required this.literal,
+ required this.value,
+ });
@override
Token get beginToken => literal;
@@ -1288,7 +1291,11 @@
/// Initialize a newly created break statement. The [label] can be `null` if
/// there is no label associated with the statement.
- BreakStatementImpl(this.breakKeyword, this._label, this.semicolon) {
+ BreakStatementImpl({
+ required this.breakKeyword,
+ required SimpleIdentifierImpl? label,
+ required this.semicolon,
+ }) : _label = label {
_becomeParentOf(_label);
}
@@ -1345,7 +1352,10 @@
/// Initialize a newly created cascade expression. The list of
/// [cascadeSections] must contain at least one element.
- CascadeExpressionImpl(this._target, List<Expression> cascadeSections) {
+ CascadeExpressionImpl({
+ required ExpressionImpl target,
+ required List<Expression> cascadeSections,
+ }) : _target = target {
_becomeParentOf(_target);
_cascadeSections._initialize(this, cascadeSections);
}
@@ -1453,17 +1463,21 @@
/// [exceptionType] can be `null` if the clause will catch all exceptions. The
/// [comma] and [_stackTraceParameter] can be `null` if the stack trace
/// parameter is not defined.
- CatchClauseImpl(
- this.onKeyword,
- this._exceptionType,
- this.catchKeyword,
- this.leftParenthesis,
- this._exceptionParameter,
- this.comma,
- this._stackTraceParameter,
- this.rightParenthesis,
- this._body)
- : assert(onKeyword != null || catchKeyword != null) {
+ CatchClauseImpl({
+ required this.onKeyword,
+ required TypeAnnotationImpl? exceptionType,
+ required this.catchKeyword,
+ required this.leftParenthesis,
+ required CatchClauseParameterImpl? exceptionParameter,
+ required this.comma,
+ required CatchClauseParameterImpl? stackTraceParameter,
+ required this.rightParenthesis,
+ required BlockImpl body,
+ }) : assert(onKeyword != null || catchKeyword != null),
+ _exceptionType = exceptionType,
+ _exceptionParameter = exceptionParameter,
+ _stackTraceParameter = stackTraceParameter,
+ _body = body {
_becomeParentOf(_exceptionType);
_becomeParentOf(_exceptionParameter);
_becomeParentOf(_stackTraceParameter);
@@ -2124,7 +2138,11 @@
/// least one token. The [_type] is the type of the comment. The list of
/// [references] can be empty if the comment does not contain any embedded
/// references.
- CommentImpl(this.tokens, this._type, List<CommentReference> references) {
+ CommentImpl({
+ required this.tokens,
+ required CommentType type,
+ required List<CommentReference> references,
+ }) : _type = type {
_references._initialize(this, references);
}
@@ -2160,23 +2178,42 @@
}
/// Create a block comment consisting of the given [tokens].
- static CommentImpl createBlockComment(List<Token> tokens) =>
- CommentImpl(tokens, CommentType.BLOCK, const <CommentReference>[]);
+ static CommentImpl createBlockComment(List<Token> tokens) {
+ return CommentImpl(
+ tokens: tokens,
+ type: CommentType.BLOCK,
+ references: const <CommentReference>[],
+ );
+ }
/// Create a documentation comment consisting of the given [tokens].
- static CommentImpl createDocumentationComment(List<Token> tokens) =>
- CommentImpl(
- tokens, CommentType.DOCUMENTATION, const <CommentReference>[]);
+ static CommentImpl createDocumentationComment(List<Token> tokens) {
+ return CommentImpl(
+ tokens: tokens,
+ type: CommentType.DOCUMENTATION,
+ references: const <CommentReference>[],
+ );
+ }
/// Create a documentation comment consisting of the given [tokens] and having
/// the given [references] embedded within it.
static CommentImpl createDocumentationCommentWithReferences(
- List<Token> tokens, List<CommentReference> references) =>
- CommentImpl(tokens, CommentType.DOCUMENTATION, references);
+ List<Token> tokens, List<CommentReference> references) {
+ return CommentImpl(
+ tokens: tokens,
+ type: CommentType.DOCUMENTATION,
+ references: references,
+ );
+ }
/// Create an end-of-line comment consisting of the given [tokens].
- static CommentImpl createEndOfLineComment(List<Token> tokens) =>
- CommentImpl(tokens, CommentType.END_OF_LINE, const <CommentReference>[]);
+ static CommentImpl createEndOfLineComment(List<Token> tokens) {
+ return CommentImpl(
+ tokens: tokens,
+ type: CommentType.END_OF_LINE,
+ references: const <CommentReference>[],
+ );
+ }
}
abstract class CommentReferableExpressionImpl extends ExpressionImpl
@@ -2197,7 +2234,10 @@
/// Initialize a newly created reference to a Dart element. The [newKeyword]
/// can be `null` if the reference is not to a constructor.
- CommentReferenceImpl(this.newKeyword, this._expression) {
+ CommentReferenceImpl({
+ required this.newKeyword,
+ required CommentReferableExpressionImpl expression,
+ }) : _expression = expression {
_becomeParentOf(_expression);
}
@@ -2483,8 +2523,15 @@
ExpressionImpl _elseExpression;
/// Initialize a newly created conditional expression.
- ConditionalExpressionImpl(this._condition, this.question,
- this._thenExpression, this.colon, this._elseExpression) {
+ ConditionalExpressionImpl({
+ required ExpressionImpl condition,
+ required this.question,
+ required ExpressionImpl thenExpression,
+ required this.colon,
+ required ExpressionImpl elseExpression,
+ }) : _condition = condition,
+ _thenExpression = thenExpression,
+ _elseExpression = elseExpression {
_becomeParentOf(_condition);
_becomeParentOf(_thenExpression);
_becomeParentOf(_elseExpression);
@@ -2577,8 +2624,17 @@
@override
DirectiveUri? resolvedUri;
- ConfigurationImpl(this.ifKeyword, this.leftParenthesis, this._name,
- this.equalToken, this._value, this.rightParenthesis, this._uri) {
+ ConfigurationImpl({
+ required this.ifKeyword,
+ required this.leftParenthesis,
+ required DottedNameImpl name,
+ required this.equalToken,
+ required StringLiteralImpl? value,
+ required this.rightParenthesis,
+ required StringLiteralImpl uri,
+ }) : _name = name,
+ _value = value,
+ _uri = uri {
_becomeParentOf(_name);
_becomeParentOf(_value);
_becomeParentOf(_uri);
@@ -2884,8 +2940,14 @@
/// Initialize a newly created field initializer to initialize the field with
/// the given name to the value of the given expression. The [thisKeyword] and
/// [period] can be `null` if the 'this' keyword was not specified.
- ConstructorFieldInitializerImpl(this.thisKeyword, this.period,
- this._fieldName, this.equals, this._expression) {
+ ConstructorFieldInitializerImpl({
+ required this.thisKeyword,
+ required this.period,
+ required SimpleIdentifierImpl fieldName,
+ required this.equals,
+ required ExpressionImpl expression,
+ }) : _fieldName = fieldName,
+ _expression = expression {
_becomeParentOf(_fieldName);
_becomeParentOf(_expression);
}
@@ -2968,7 +3030,12 @@
/// Initialize a newly created constructor name. The [period] and [name] can
/// be`null` if the constructor being named is the unnamed constructor.
- ConstructorNameImpl(this._type, this.period, this._name) {
+ ConstructorNameImpl({
+ required NamedTypeImpl type,
+ required this.period,
+ required SimpleIdentifierImpl? name,
+ }) : _type = type,
+ _name = name {
_becomeParentOf(_type);
_becomeParentOf(_name);
}
@@ -3028,7 +3095,9 @@
implements ConstructorReference {
ConstructorNameImpl _constructorName;
- ConstructorReferenceImpl(this._constructorName) {
+ ConstructorReferenceImpl({
+ required ConstructorNameImpl constructorName,
+ }) : _constructorName = constructorName {
_becomeParentOf(_constructorName);
}
@@ -3129,7 +3198,11 @@
/// Initialize a newly created continue statement. The [label] can be `null`
/// if there is no label associated with the statement.
- ContinueStatementImpl(this.continueKeyword, this._label, this.semicolon) {
+ ContinueStatementImpl({
+ required this.continueKeyword,
+ required SimpleIdentifierImpl? label,
+ required this.semicolon,
+ }) : _label = label {
_becomeParentOf(_label);
}
@@ -3309,8 +3382,13 @@
/// Initialize a newly created default formal parameter. The [separator] and
/// [defaultValue] can be `null` if there is no default value.
- DefaultFormalParameterImpl(
- this._parameter, this.kind, this.separator, this._defaultValue) {
+ DefaultFormalParameterImpl({
+ required NormalFormalParameterImpl parameter,
+ required this.kind,
+ required this.separator,
+ required ExpressionImpl? defaultValue,
+ }) : _parameter = parameter,
+ _defaultValue = defaultValue {
_becomeParentOf(_parameter);
_becomeParentOf(_defaultValue);
}
diff --git a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
index 2b88c05..e75df71 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
@@ -9,7 +9,6 @@
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/source/line_info.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
-import 'package:analyzer/src/generated/utilities_dart.dart';
/// The instance of [AstFactoryImpl].
final AstFactoryImpl astFactory = AstFactoryImpl();
@@ -18,23 +17,6 @@
CommentImpl blockComment(List<Token> tokens) =>
CommentImpl.createBlockComment(tokens);
- BooleanLiteralImpl booleanLiteral(Token literal, bool value) =>
- BooleanLiteralImpl(literal, value);
-
- BreakStatementImpl breakStatement(
- Token breakKeyword, SimpleIdentifier? label, Token semicolon) =>
- BreakStatementImpl(
- breakKeyword, label as SimpleIdentifierImpl?, semicolon);
-
- CascadeExpressionImpl cascadeExpression(
- Expression target, List<Expression> cascadeSections) =>
- CascadeExpressionImpl(target as ExpressionImpl, cascadeSections);
-
- CommentReferenceImpl commentReference(
- Token? newKeyword, CommentReferableExpression expression) =>
- CommentReferenceImpl(
- newKeyword, expression as CommentReferableExpressionImpl);
-
CompilationUnitImpl compilationUnit(
{required Token beginToken,
ScriptTag? scriptTag,
@@ -50,71 +32,6 @@
CompilationUnitImpl(beginToken, scriptTag as ScriptTagImpl?, directives,
declarations, endToken, featureSet, lineInfo ?? LineInfo([0]));
- ConditionalExpressionImpl conditionalExpression(
- Expression condition,
- Token question,
- Expression thenExpression,
- Token colon,
- Expression elseExpression) =>
- ConditionalExpressionImpl(
- condition as ExpressionImpl,
- question,
- thenExpression as ExpressionImpl,
- colon,
- elseExpression as ExpressionImpl);
-
- ConfigurationImpl configuration(
- Token ifKeyword,
- Token leftParenthesis,
- DottedName name,
- Token? equalToken,
- StringLiteral? value,
- Token rightParenthesis,
- StringLiteral libraryUri) =>
- ConfigurationImpl(
- ifKeyword,
- leftParenthesis,
- name as DottedNameImpl,
- equalToken,
- value as StringLiteralImpl?,
- rightParenthesis,
- libraryUri as StringLiteralImpl);
-
- ConstructorFieldInitializerImpl constructorFieldInitializer(
- Token? thisKeyword,
- Token? period,
- SimpleIdentifier fieldName,
- Token equals,
- Expression expression) =>
- ConstructorFieldInitializerImpl(
- thisKeyword,
- period,
- fieldName as SimpleIdentifierImpl,
- equals,
- expression as ExpressionImpl);
-
- ConstructorNameImpl constructorName(
- NamedType type, Token? period, SimpleIdentifier? name) =>
- ConstructorNameImpl(
- type as NamedTypeImpl, period, name as SimpleIdentifierImpl?);
-
- ConstructorReferenceImpl constructorReference(
- {required ConstructorName constructorName}) =>
- ConstructorReferenceImpl(constructorName as ConstructorNameImpl);
-
- ContinueStatementImpl continueStatement(
- Token continueKeyword, SimpleIdentifier? label, Token semicolon) =>
- ContinueStatementImpl(
- continueKeyword, label as SimpleIdentifierImpl?, semicolon);
-
- DefaultFormalParameterImpl defaultFormalParameter(
- NormalFormalParameter parameter,
- ParameterKind kind,
- Token? separator,
- Expression? defaultValue) =>
- DefaultFormalParameterImpl(parameter as NormalFormalParameterImpl, kind,
- separator, defaultValue as ExpressionImpl?);
-
CommentImpl documentationComment(List<Token> tokens,
[List<CommentReference>? references]) =>
CommentImpl.createDocumentationCommentWithReferences(
diff --git a/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart b/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart
index 0fdb8cc..4d6e6c5 100644
--- a/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart
@@ -97,8 +97,8 @@
/// Possibly rewrites [node] as an [ExtensionOverride] or as an
/// [InstanceCreationExpression].
- AstNode methodInvocation(Scope nameScope, MethodInvocation node) {
- SimpleIdentifier methodName = node.methodName;
+ AstNode methodInvocation(Scope nameScope, MethodInvocationImpl node) {
+ final methodName = node.methodName;
if (methodName.isSynthetic) {
// This isn't a constructor invocation because the method name is
// synthetic.
@@ -132,7 +132,7 @@
typeIdentifier: methodName,
);
}
- } else if (target is SimpleIdentifier) {
+ } else if (target is SimpleIdentifierImpl) {
// Possible cases: C.n(), p.C() or p.C<>()
if (node.isNullAware) {
// This isn't a constructor invocation because a null aware operator is
@@ -224,19 +224,19 @@
/// [PrefixedIdentifier] with 'prefix' of `List` and 'identifier' of `filled`.
/// The [PrefixedIdentifier] may need to be rewritten as a
/// [ConstructorReference].
- AstNode prefixedIdentifier(Scope nameScope, PrefixedIdentifier node) {
+ AstNode prefixedIdentifier(Scope nameScope, PrefixedIdentifierImpl node) {
var parent = node.parent;
if (parent is Annotation) {
// An annotations which is a const constructor invocation can initially be
// represented with a [PrefixedIdentifier]. Do not rewrite such nodes.
return node;
}
- if (parent is CommentReference) {
+ if (parent is CommentReferenceImpl) {
// TODO(srawlins): This probably should be allowed to be rewritten to a
// [ConstructorReference] at some point.
return node;
}
- if (parent is AssignmentExpression && parent.leftHandSide == node) {
+ if (parent is AssignmentExpressionImpl && parent.leftHandSide == node) {
// A constructor cannot be assigned to, in some expression like
// `C.new = foo`; do not rewrite.
return node;
@@ -275,29 +275,29 @@
/// 'prefix' of `List` and 'identifier' of `filled`) and a 'propertyName' of
/// `value`. The [PropertyAccess] may need to be rewritten as a
/// [ConstructorReference].
- AstNode propertyAccess(Scope nameScope, PropertyAccess node) {
+ AstNode propertyAccess(Scope nameScope, PropertyAccessImpl node) {
if (node.isCascaded) {
// For example, `List..filled`: this is a property access on an instance
// `Type`.
return node;
}
- if (node.parent is CommentReference) {
+ if (node.parent is CommentReferenceImpl) {
// TODO(srawlins): This probably should be allowed to be rewritten to a
// [ConstructorReference] at some point.
return node;
}
var receiver = node.target!;
- Identifier receiverIdentifier;
- TypeArgumentList? typeArguments;
- if (receiver is PrefixedIdentifier) {
+ IdentifierImpl receiverIdentifier;
+ TypeArgumentListImpl? typeArguments;
+ if (receiver is PrefixedIdentifierImpl) {
receiverIdentifier = receiver;
- } else if (receiver is FunctionReference) {
+ } else if (receiver is FunctionReferenceImpl) {
// A [ConstructorReference] with explicit type arguments is initially
// parsed as a [PropertyAccess] with a [FunctionReference] target; for
// example: `List<int>.filled` or `core.List<int>.filled`.
var function = receiver.function;
- if (function is! Identifier) {
+ if (function is! IdentifierImpl) {
// If [receiverIdentifier] is not an Identifier then [node] is not a
// ConstructorReference.
return node;
@@ -311,9 +311,9 @@
}
Element? element;
- if (receiverIdentifier is SimpleIdentifier) {
+ if (receiverIdentifier is SimpleIdentifierImpl) {
element = nameScope.lookup(receiverIdentifier.name).getter;
- } else if (receiverIdentifier is PrefixedIdentifier) {
+ } else if (receiverIdentifier is PrefixedIdentifierImpl) {
var prefixElement =
nameScope.lookup(receiverIdentifier.prefix.name).getter;
if (prefixElement is PrefixElement) {
@@ -371,9 +371,9 @@
}
AstNode _instanceCreation_prefix_type_name({
- required MethodInvocation node,
- required PrefixedIdentifier typeNameIdentifier,
- required SimpleIdentifier constructorIdentifier,
+ required MethodInvocationImpl node,
+ required PrefixedIdentifierImpl typeNameIdentifier,
+ required SimpleIdentifierImpl constructorIdentifier,
required ClassElement classElement,
}) {
var constructorElement = classElement.getNamedConstructor(
@@ -395,16 +395,21 @@
name: typeNameIdentifier,
typeArguments: typeArguments,
);
- var constructorName = astFactory.constructorName(
- typeName, node.operator, constructorIdentifier);
+ var constructorName = ConstructorNameImpl(
+ type: typeName,
+ period: node.operator,
+ name: constructorIdentifier,
+ );
var instanceCreationExpression = astFactory.instanceCreationExpression(
null, constructorName, node.argumentList);
NodeReplacer.replace(node, instanceCreationExpression);
return instanceCreationExpression;
}
- AstNode _toConstructorReference_prefixed(
- {required PrefixedIdentifier node, required ClassElement classElement}) {
+ AstNode _toConstructorReference_prefixed({
+ required PrefixedIdentifierImpl node,
+ required ClassElement classElement,
+ }) {
var name = node.identifier.name;
var constructorElement = name == 'new'
? classElement.unnamedConstructor
@@ -414,18 +419,22 @@
}
var typeName = astFactory.namedType(name: node.prefix);
- var constructorName =
- astFactory.constructorName(typeName, node.period, node.identifier);
- var constructorReference =
- astFactory.constructorReference(constructorName: constructorName);
+ var constructorName = ConstructorNameImpl(
+ type: typeName,
+ period: node.period,
+ name: node.identifier,
+ );
+ var constructorReference = ConstructorReferenceImpl(
+ constructorName: constructorName,
+ );
NodeReplacer.replace(node, constructorReference);
return constructorReference;
}
AstNode _toConstructorReference_propertyAccess({
- required PropertyAccess node,
- required Identifier receiver,
- required TypeArgumentList? typeArguments,
+ required PropertyAccessImpl node,
+ required IdentifierImpl receiver,
+ required TypeArgumentListImpl? typeArguments,
required ClassElement classElement,
}) {
var name = node.propertyName.name;
@@ -446,18 +455,22 @@
name: receiver,
typeArguments: typeArguments,
);
- var constructorName =
- astFactory.constructorName(typeName, operator, node.propertyName);
- var constructorReference =
- astFactory.constructorReference(constructorName: constructorName);
+ var constructorName = ConstructorNameImpl(
+ type: typeName,
+ period: operator,
+ name: node.propertyName,
+ );
+ var constructorReference = ConstructorReferenceImpl(
+ constructorName: constructorName,
+ );
NodeReplacer.replace(node, constructorReference);
return constructorReference;
}
InstanceCreationExpression _toInstanceCreation_prefix_type({
- required MethodInvocation node,
- required SimpleIdentifier prefixIdentifier,
- required SimpleIdentifier typeIdentifier,
+ required MethodInvocationImpl node,
+ required SimpleIdentifierImpl prefixIdentifier,
+ required SimpleIdentifierImpl typeIdentifier,
}) {
var typeName = astFactory.namedType(
name: astFactory.prefixedIdentifier(
@@ -467,7 +480,11 @@
),
typeArguments: node.typeArguments,
);
- var constructorName = astFactory.constructorName(typeName, null, null);
+ var constructorName = ConstructorNameImpl(
+ type: typeName,
+ period: null,
+ name: null,
+ );
var instanceCreationExpression = astFactory.instanceCreationExpression(
null, constructorName, node.argumentList);
NodeReplacer.replace(node, instanceCreationExpression);
@@ -482,7 +499,11 @@
name: typeIdentifier,
typeArguments: node.typeArguments,
);
- var constructorName = astFactory.constructorName(typeName, null, null);
+ var constructorName = ConstructorNameImpl(
+ type: typeName,
+ period: null,
+ name: null,
+ );
var instanceCreationExpression = astFactory.instanceCreationExpression(
null, constructorName, node.argumentList);
NodeReplacer.replace(node, instanceCreationExpression);
@@ -490,9 +511,9 @@
}
AstNode _toInstanceCreation_type_constructor({
- required MethodInvocation node,
- required SimpleIdentifier typeIdentifier,
- required SimpleIdentifier constructorIdentifier,
+ required MethodInvocationImpl node,
+ required SimpleIdentifierImpl typeIdentifier,
+ required SimpleIdentifierImpl constructorIdentifier,
required ClassElement classElement,
}) {
var name = constructorIdentifier.name;
@@ -509,8 +530,11 @@
[typeIdentifier.name, constructorIdentifier.name]);
}
var typeName = astFactory.namedType(name: typeIdentifier);
- var constructorName = astFactory.constructorName(
- typeName, node.operator, constructorIdentifier);
+ var constructorName = ConstructorNameImpl(
+ type: typeName,
+ period: node.operator,
+ name: constructorIdentifier,
+ );
// TODO(scheglov) I think we should drop "typeArguments" below.
var instanceCreationExpression = astFactory.instanceCreationExpression(
null, constructorName, node.argumentList,
diff --git a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
index 1283c93..787cbfe 100644
--- a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
@@ -885,7 +885,7 @@
}
@override
- void visitMethodInvocation(MethodInvocation node) {
+ void visitMethodInvocation(covariant MethodInvocationImpl node) {
var newNode = _astRewriter.methodInvocation(_nameScope, node);
if (newNode != node) {
return newNode.accept(this);
@@ -948,7 +948,7 @@
}
@override
- void visitPrefixedIdentifier(PrefixedIdentifier node) {
+ void visitPrefixedIdentifier(covariant PrefixedIdentifierImpl node) {
var newNode = _astRewriter.prefixedIdentifier(_nameScope, node);
if (newNode != node) {
return newNode.accept(this);
@@ -958,7 +958,7 @@
}
@override
- void visitPropertyAccess(PropertyAccess node) {
+ void visitPropertyAccess(covariant PropertyAccessImpl node) {
var newNode = _astRewriter.propertyAccess(_nameScope, node);
if (newNode != node) {
return newNode.accept(this);
diff --git a/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart b/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
index d3dfb14..f6822f4 100644
--- a/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
+++ b/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
@@ -17,6 +17,50 @@
/// Initialize a newly created diagnostic factory.
DiagnosticFactory();
+ /// Return a diagnostic indicating that [duplicateElement] reuses a name
+ /// already used by [originalElement].
+ AnalysisError duplicateDefinition(ErrorCode code, Element duplicateElement,
+ Element originalElement, List<Object> arguments) {
+ final duplicate = duplicateElement.nonSynthetic;
+ final original = originalElement.nonSynthetic;
+ return AnalysisError(
+ duplicate.source!,
+ duplicate.nameOffset,
+ duplicate.nameLength,
+ code,
+ arguments,
+ [
+ DiagnosticMessageImpl(
+ filePath: original.source!.fullName,
+ message: "The first definition of this name.",
+ offset: original.nameOffset,
+ length: original.nameLength,
+ url: null)
+ ],
+ );
+ }
+
+ /// Return a diagnostic indicating that [duplicateNode] reuses a name
+ /// already used by [originalNode].
+ AnalysisError duplicateDefinitionForNodes(Source source, ErrorCode code,
+ AstNode duplicateNode, AstNode originalNode, List<Object> arguments) {
+ return AnalysisError(
+ source,
+ duplicateNode.offset,
+ duplicateNode.length,
+ code,
+ arguments,
+ [
+ DiagnosticMessageImpl(
+ filePath: source.fullName,
+ message: "The first definition of this name.",
+ offset: originalNode.offset,
+ length: originalNode.length,
+ url: null)
+ ],
+ );
+ }
+
/// Return a diagnostic indicating that the [duplicateElement] (in a constant
/// set) is a duplicate of the [originalElement].
AnalysisError equalElementsInConstSet(
diff --git a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
index 991084b..366f6f6 100644
--- a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
+++ b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
@@ -11,6 +11,7 @@
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
+import 'package:analyzer/src/diagnostic/diagnostic_factory.dart';
import 'package:analyzer/src/error/codes.dart';
class DuplicateDefinitionVerifier {
@@ -18,6 +19,8 @@
final LibraryElement _currentLibrary;
final ErrorReporter _errorReporter;
+ final DiagnosticFactory _diagnosticFactory = DiagnosticFactory();
+
DuplicateDefinitionVerifier(
this._inheritanceManager,
this._currentLibrary,
@@ -31,10 +34,13 @@
if (exceptionParameter != null && stackTraceParameter != null) {
String exceptionName = exceptionParameter.name.lexeme;
if (exceptionName == stackTraceParameter.name.lexeme) {
- _errorReporter.reportErrorForNode(
- CompileTimeErrorCode.DUPLICATE_DEFINITION,
- stackTraceParameter,
- [exceptionName]);
+ _errorReporter.reportError(_diagnosticFactory
+ .duplicateDefinitionForNodes(
+ _errorReporter.source,
+ CompileTimeErrorCode.DUPLICATE_DEFINITION,
+ stackTraceParameter,
+ exceptionParameter,
+ [exceptionName]));
}
}
}
@@ -525,11 +531,12 @@
var previous = getterScope[name];
if (previous != null) {
if (!_isGetterSetterPair(element, previous)) {
- _errorReporter.reportErrorForToken(
+ _errorReporter.reportError(_diagnosticFactory.duplicateDefinition(
getError(previous, element),
- identifier,
+ element,
+ previous,
[name],
- );
+ ));
}
} else {
getterScope[name] = element;
@@ -539,11 +546,12 @@
if (element is PropertyAccessorElement && element.isSetter) {
previous = setterScope[name];
if (previous != null) {
- _errorReporter.reportErrorForToken(
+ _errorReporter.reportError(_diagnosticFactory.duplicateDefinition(
getError(previous, element),
- identifier,
+ element,
+ previous,
[name],
- );
+ ));
} else {
setterScope[name] = element;
}
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index f0ab1d9..5710ff2 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -229,12 +229,17 @@
assert(optional('..', token) || optional('?..', token));
debugEvent("beginCascade");
- var expression = pop() as Expression;
+ var expression = pop() as ExpressionImpl;
push(token);
if (expression is CascadeExpression) {
push(expression);
} else {
- push(ast.cascadeExpression(expression, <Expression>[]));
+ push(
+ CascadeExpressionImpl(
+ target: expression,
+ cascadeSections: <Expression>[],
+ ),
+ );
}
push(NullValue.CascadeReceiver);
}
@@ -491,14 +496,14 @@
initializerObject.target, initializerObject);
}
- if (initializerObject is AssignmentExpression) {
+ if (initializerObject is AssignmentExpressionImpl) {
Token? thisKeyword;
Token? period;
- SimpleIdentifier fieldName;
+ SimpleIdentifierImpl fieldName;
Expression left = initializerObject.leftHandSide;
- if (left is PropertyAccess) {
+ if (left is PropertyAccessImpl) {
var target = left.target;
- if (target is ThisExpression) {
+ if (target is ThisExpressionImpl) {
thisKeyword = target.thisKeyword;
period = left.operator;
} else {
@@ -507,7 +512,7 @@
// Parser has reported FieldInitializedOutsideDeclaringClass.
}
fieldName = left.propertyName;
- } else if (left is SimpleIdentifier) {
+ } else if (left is SimpleIdentifierImpl) {
fieldName = left;
} else {
// Recovery:
@@ -515,8 +520,13 @@
var superExpression = left as SuperExpression;
fieldName = ast.simpleIdentifier(superExpression.superKeyword);
}
- return ast.constructorFieldInitializer(thisKeyword, period, fieldName,
- initializerObject.operator, initializerObject.rightHandSide);
+ return ConstructorFieldInitializerImpl(
+ thisKeyword: thisKeyword,
+ period: period,
+ fieldName: fieldName,
+ equals: initializerObject.operator,
+ expression: initializerObject.rightHandSide,
+ );
}
if (initializerObject is AssertInitializer) {
@@ -1190,13 +1200,20 @@
assert(optional(':', colon));
debugEvent("ConditionalExpression");
- var elseExpression = pop() as Expression;
- var thenExpression = pop() as Expression;
- var condition = pop() as Expression;
+ var elseExpression = pop() as ExpressionImpl;
+ var thenExpression = pop() as ExpressionImpl;
+ var condition = pop() as ExpressionImpl;
reportErrorIfSuper(elseExpression);
reportErrorIfSuper(thenExpression);
- push(ast.conditionalExpression(
- condition, question, thenExpression, colon, elseExpression));
+ push(
+ ConditionalExpressionImpl(
+ condition: condition,
+ question: question,
+ thenExpression: thenExpression,
+ colon: colon,
+ elseExpression: elseExpression,
+ ),
+ );
}
@override
@@ -1206,9 +1223,9 @@
assert(optionalOrNull('==', equalSign));
debugEvent("ConditionalUri");
- var libraryUri = pop() as StringLiteral;
- var value = popIfNotNull(equalSign) as StringLiteral?;
- if (value is StringInterpolation) {
+ var libraryUri = pop() as StringLiteralImpl;
+ var value = popIfNotNull(equalSign) as StringLiteralImpl?;
+ if (value is StringInterpolationImpl) {
for (var child in value.childEntities) {
if (child is InterpolationExpression) {
// This error is reported in OutlineBuilder.endLiteralString
@@ -1218,9 +1235,18 @@
}
}
}
- var name = pop() as DottedName;
- push(ast.configuration(ifKeyword, leftParen, name, equalSign, value,
- leftParen.endGroup!, libraryUri));
+ var name = pop() as DottedNameImpl;
+ push(
+ ConfigurationImpl(
+ ifKeyword: ifKeyword,
+ leftParenthesis: leftParen,
+ name: name,
+ equalToken: equalSign,
+ value: value,
+ rightParenthesis: leftParen.endGroup!,
+ uri: libraryUri,
+ ),
+ );
}
@override
@@ -1249,17 +1275,17 @@
assert(optionalOrNull('.', periodBeforeName));
debugEvent("ConstructorReference");
- var constructorName = pop() as SimpleIdentifier?;
- var typeArguments = pop() as TypeArgumentList?;
- var typeNameIdentifier = pop() as Identifier;
+ var constructorName = pop() as SimpleIdentifierImpl?;
+ var typeArguments = pop() as TypeArgumentListImpl?;
+ var typeNameIdentifier = pop() as IdentifierImpl;
push(
- ast.constructorName(
- ast.namedType(
+ ConstructorNameImpl(
+ type: ast.namedType(
name: typeNameIdentifier,
typeArguments: typeArguments,
),
- periodBeforeName,
- constructorName,
+ period: periodBeforeName,
+ name: constructorName,
),
);
}
@@ -1594,8 +1620,8 @@
var comment = _findComment(metadata,
thisKeyword ?? typeOrFunctionTypedParameter?.beginToken ?? nameToken);
- NormalFormalParameter node;
- if (typeOrFunctionTypedParameter is FunctionTypedFormalParameter) {
+ NormalFormalParameterImpl node;
+ if (typeOrFunctionTypedParameter is FunctionTypedFormalParameterImpl) {
// This is a temporary AST node that was constructed in
// [endFunctionTypedFormalParameter]. We now deconstruct it and create
// the final AST node.
@@ -1691,13 +1717,21 @@
ParameterKind analyzerKind = _toAnalyzerParameterKind(kind);
FormalParameter parameter = node;
if (analyzerKind != ParameterKind.REQUIRED) {
- parameter = ast.defaultFormalParameter(
- node, analyzerKind, defaultValue?.separator, defaultValue?.value);
+ parameter = DefaultFormalParameterImpl(
+ parameter: node,
+ kind: analyzerKind,
+ separator: defaultValue?.separator,
+ defaultValue: defaultValue?.value,
+ );
} else if (defaultValue != null) {
// An error is reported if a required parameter has a default value.
// Record it as named parameter for recovery.
- parameter = ast.defaultFormalParameter(node, ParameterKind.NAMED,
- defaultValue.separator, defaultValue.value);
+ parameter = DefaultFormalParameterImpl(
+ parameter: node,
+ kind: ParameterKind.NAMED,
+ separator: defaultValue.separator,
+ defaultValue: defaultValue.value,
+ );
}
push(parameter);
}
@@ -2842,8 +2876,14 @@
assert(optional(';', semicolon));
debugEvent("BreakStatement");
- var label = hasTarget ? pop() as SimpleIdentifier : null;
- push(ast.breakStatement(breakKeyword, label, semicolon));
+ var label = hasTarget ? pop() as SimpleIdentifierImpl : null;
+ push(
+ BreakStatementImpl(
+ breakKeyword: breakKeyword,
+ label: label,
+ semicolon: semicolon,
+ ),
+ );
}
@override
@@ -2882,23 +2922,23 @@
}
push(
CatchClauseImpl(
- onKeyword,
- type as TypeAnnotationImpl?,
- catchKeyword,
- catchParameterList?.leftParenthesis,
- exception != null
+ onKeyword: onKeyword,
+ exceptionType: type as TypeAnnotationImpl?,
+ catchKeyword: catchKeyword,
+ leftParenthesis: catchParameterList?.leftParenthesis,
+ exceptionParameter: exception != null
? CatchClauseParameterImpl(
nameNode: exception as SimpleIdentifierImpl,
)
: null,
- comma,
- stackTrace != null
+ comma: comma,
+ stackTraceParameter: stackTrace != null
? CatchClauseParameterImpl(
nameNode: stackTrace as SimpleIdentifierImpl,
)
: null,
- catchParameterList?.rightParenthesis,
- body as BlockImpl,
+ rightParenthesis: catchParameterList?.rightParenthesis,
+ body: body as BlockImpl,
),
);
}
@@ -2994,13 +3034,28 @@
var target = ast.prefixedIdentifier(ast.simpleIdentifier(firstToken),
firstPeriod!, ast.simpleIdentifier(secondToken!));
var expression = ast.propertyAccess(target, secondPeriod!, identifier);
- push(ast.commentReference(newKeyword, expression));
+ push(
+ CommentReferenceImpl(
+ newKeyword: newKeyword,
+ expression: expression,
+ ),
+ );
} else if (secondToken != null) {
var expression = ast.prefixedIdentifier(
ast.simpleIdentifier(secondToken), secondPeriod!, identifier);
- push(ast.commentReference(newKeyword, expression));
+ push(
+ CommentReferenceImpl(
+ newKeyword: newKeyword,
+ expression: expression,
+ ),
+ );
} else {
- push(ast.commentReference(newKeyword, identifier));
+ push(
+ CommentReferenceImpl(
+ newKeyword: newKeyword,
+ expression: identifier,
+ ),
+ );
}
}
@@ -3024,8 +3079,14 @@
assert(optional(';', semicolon));
debugEvent("ContinueStatement");
- var label = hasTarget ? pop() as SimpleIdentifier : null;
- push(ast.continueStatement(continueKeyword, label, semicolon));
+ var label = hasTarget ? pop() as SimpleIdentifierImpl : null;
+ push(
+ ContinueStatementImpl(
+ continueKeyword: continueKeyword,
+ label: label,
+ semicolon: semicolon,
+ ),
+ );
}
@override
@@ -3598,7 +3659,12 @@
assert(value || identical(token.stringValue, "false"));
debugEvent("LiteralBool");
- push(ast.booleanLiteral(token, value));
+ push(
+ BooleanLiteralImpl(
+ literal: token,
+ value: value,
+ ),
+ );
}
@override
@@ -4252,7 +4318,7 @@
assert(optional('=', equals) || optional(':', equals));
debugEvent("ValuedFormalParameter");
- var value = pop() as Expression;
+ var value = pop() as ExpressionImpl;
push(_ParameterDefaultValue(equals, value));
}
@@ -4631,7 +4697,7 @@
/// value with the separator token.
class _ParameterDefaultValue {
final Token separator;
- final Expression value;
+ final ExpressionImpl value;
_ParameterDefaultValue(this.separator, this.value);
}
diff --git a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
index c50db2b..0dae99f 100644
--- a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
@@ -12,7 +12,6 @@
import 'package:analyzer/src/dart/ast/ast_factory.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/testing/token_factory.dart';
-import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:meta/meta.dart';
/// The class `AstTestFactory` defines utility methods that can be used to
@@ -68,23 +67,6 @@
semicolon: TokenFactory.tokenFromType(TokenType.SEMICOLON),
);
- static BooleanLiteralImpl booleanLiteral(
- bool value) =>
- astFactory.booleanLiteral(
- value
- ? TokenFactory.tokenFromKeyword(Keyword.TRUE)
- : TokenFactory.tokenFromKeyword(Keyword.FALSE),
- value);
-
- static BreakStatementImpl breakStatement() => astFactory.breakStatement(
- TokenFactory.tokenFromKeyword(Keyword.BREAK),
- null,
- TokenFactory.tokenFromType(TokenType.SEMICOLON));
-
- static BreakStatementImpl breakStatement2(String label) =>
- astFactory.breakStatement(TokenFactory.tokenFromKeyword(Keyword.BREAK),
- identifier3(label), TokenFactory.tokenFromType(TokenType.SEMICOLON));
-
static IndexExpressionImpl cascadedIndexExpression(Expression index) =>
astFactory.indexExpressionForCascade2(
period: TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD),
@@ -109,13 +91,6 @@
TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD),
identifier3(propertyName));
- static CascadeExpressionImpl cascadeExpression(Expression target,
- [List<Expression> cascadeSections = const []]) {
- var cascade = astFactory.cascadeExpression(target, cascadeSections);
- cascade.target.endToken.next = cascadeSections.first.beginToken;
- return cascade;
- }
-
static ClassDeclarationImpl classDeclaration(
Keyword? abstractKeyword,
String name,
@@ -228,15 +203,6 @@
featureSet: featureSet,
lineInfo: LineInfo.fromContent(''));
- static ConditionalExpressionImpl conditionalExpression(Expression condition,
- Expression thenExpression, Expression elseExpression) =>
- astFactory.conditionalExpression(
- condition,
- TokenFactory.tokenFromType(TokenType.QUESTION),
- thenExpression,
- TokenFactory.tokenFromType(TokenType.COLON),
- elseExpression);
-
static ConstructorDeclarationImpl constructorDeclaration(
Identifier returnType,
String? name,
@@ -292,29 +258,6 @@
body: body as FunctionBodyImpl,
);
- static ConstructorFieldInitializerImpl constructorFieldInitializer(
- bool prefixedWithThis, String fieldName, Expression expression) =>
- astFactory.constructorFieldInitializer(
- prefixedWithThis ? TokenFactory.tokenFromKeyword(Keyword.THIS) : null,
- prefixedWithThis
- ? TokenFactory.tokenFromType(TokenType.PERIOD)
- : null,
- identifier3(fieldName),
- TokenFactory.tokenFromType(TokenType.EQ),
- expression);
-
- static ConstructorNameImpl constructorName(NamedType type, String? name) =>
- astFactory.constructorName(
- type,
- name == null ? null : TokenFactory.tokenFromType(TokenType.PERIOD),
- name == null ? null : identifier3(name));
-
- static ContinueStatementImpl continueStatement([String? label]) =>
- astFactory.continueStatement(
- TokenFactory.tokenFromKeyword(Keyword.CONTINUE),
- label == null ? null : identifier3(label),
- TokenFactory.tokenFromType(TokenType.SEMICOLON));
-
static DeclaredIdentifierImpl declaredIdentifier(
Keyword keyword, String identifier) =>
declaredIdentifier2(keyword, null, identifier);
@@ -751,24 +694,6 @@
name,
argumentList(arguments));
- static InstanceCreationExpressionImpl instanceCreationExpression2(
- Keyword? keyword, NamedType type,
- [List<Expression> arguments = const []]) =>
- instanceCreationExpression3(keyword, type, null, arguments);
-
- static InstanceCreationExpressionImpl instanceCreationExpression3(
- Keyword? keyword, NamedType type, String? identifier,
- [List<Expression> arguments = const []]) =>
- instanceCreationExpression(
- keyword,
- astFactory.constructorName(
- type,
- identifier == null
- ? null
- : TokenFactory.tokenFromType(TokenType.PERIOD),
- identifier == null ? null : identifier3(identifier)),
- arguments);
-
static IntegerLiteralImpl integer(int value) => astFactory.integerLiteral(
TokenFactory.tokenFromTypeAndString(TokenType.INT, value.toString()),
value);
@@ -997,16 +922,6 @@
String label, Expression expression) =>
namedExpression(label2(label), expression);
- static DefaultFormalParameterImpl namedFormalParameter(
- NormalFormalParameter parameter, Expression? expression) =>
- astFactory.defaultFormalParameter(
- parameter,
- ParameterKind.NAMED,
- expression == null
- ? null
- : TokenFactory.tokenFromType(TokenType.COLON),
- expression);
-
/// Create a type name whose name has been resolved to the given [element] and
/// whose type has been resolved to the type of the given element.
///
@@ -1091,14 +1006,6 @@
semicolon: TokenFactory.tokenFromType(TokenType.SEMICOLON),
);
- static DefaultFormalParameterImpl positionalFormalParameter(
- NormalFormalParameter parameter, Expression? expression) =>
- astFactory.defaultFormalParameter(
- parameter,
- ParameterKind.POSITIONAL,
- expression == null ? null : TokenFactory.tokenFromType(TokenType.EQ),
- expression);
-
static PostfixExpressionImpl postfixExpression(
Expression expression, TokenType operator) =>
astFactory.postfixExpression(
diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
index 8cdade2..81e31ef 100644
--- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
@@ -4,7 +4,6 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
@@ -14,7 +13,6 @@
import 'package:analyzer/src/dart/resolver/variance.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
@@ -334,38 +332,6 @@
static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) =>
TopLevelVariableElementImpl(name.name, name.offset);
- static TopLevelVariableElementImpl topLevelVariableElement2(String name) =>
- topLevelVariableElement3(name, false, false, DynamicTypeImpl.instance);
-
- static TopLevelVariableElementImpl topLevelVariableElement3(
- String name, bool isConst, bool isFinal, DartType type) {
- TopLevelVariableElementImpl variable;
- if (isConst) {
- ConstTopLevelVariableElementImpl constant =
- ConstTopLevelVariableElementImpl(name, -1);
- var typeElement = type.element as ClassElement;
- var initializer = AstTestFactory.instanceCreationExpression2(
- Keyword.CONST, AstTestFactory.namedType(typeElement));
- if (type is InterfaceType) {
- var element = typeElement.unnamedConstructor;
- initializer.constructorName.staticElement = element;
- }
- constant.constantInitializer = initializer;
- variable = constant;
- } else {
- variable = TopLevelVariableElementImpl(name, -1);
- }
- variable.isConst = isConst;
- variable.isFinal = isFinal;
- variable.isSynthetic = false;
- variable.type = type;
- PropertyAccessorElementImpl_ImplicitGetter(variable);
- if (!isConst && !isFinal) {
- PropertyAccessorElementImpl_ImplicitSetter(variable);
- }
- return variable;
- }
-
static TypeParameterElementImpl typeParameterElement(String name) {
return TypeParameterElementImpl(name, 0);
}
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
index a6937a0..c23c958 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
@@ -293,7 +293,10 @@
BooleanLiteral _readBooleanLiteral() {
var value = _readByte() == 1;
- var node = AstTestFactory.booleanLiteral(value);
+ var node = BooleanLiteralImpl(
+ literal: value ? Tokens.true_() : Tokens.false_(),
+ value: value,
+ );
_readExpressionResolution(node);
return node;
}
@@ -303,23 +306,26 @@
}
CascadeExpression _readCascadeExpression() {
- var target = readNode() as Expression;
+ var target = readNode() as ExpressionImpl;
var sections = _readNodeList<Expression>();
- var node = astFactory.cascadeExpression(target, sections);
+ var node = CascadeExpressionImpl(
+ target: target,
+ cascadeSections: sections,
+ );
node.staticType = target.staticType;
return node;
}
ConditionalExpression _readConditionalExpression() {
- var condition = readNode() as Expression;
- var thenExpression = readNode() as Expression;
- var elseExpression = readNode() as Expression;
- var node = astFactory.conditionalExpression(
- condition,
- Tokens.question(),
- thenExpression,
- Tokens.colon(),
- elseExpression,
+ var condition = readNode() as ExpressionImpl;
+ var thenExpression = readNode() as ExpressionImpl;
+ var elseExpression = readNode() as ExpressionImpl;
+ var node = ConditionalExpressionImpl(
+ condition: condition,
+ question: Tokens.question(),
+ thenExpression: thenExpression,
+ colon: Tokens.colon(),
+ elseExpression: elseExpression,
);
_readExpressionResolution(node);
return node;
@@ -327,34 +333,34 @@
ConstructorFieldInitializer _readConstructorFieldInitializer() {
var flags = _readByte();
- var fieldName = readNode() as SimpleIdentifier;
- var expression = readNode() as Expression;
+ var fieldName = readNode() as SimpleIdentifierImpl;
+ var expression = readNode() as ExpressionImpl;
var hasThis = AstBinaryFlags.hasThis(flags);
- return astFactory.constructorFieldInitializer(
- hasThis ? Tokens.this_() : null,
- hasThis ? Tokens.period() : null,
- fieldName,
- Tokens.eq(),
- expression,
+ return ConstructorFieldInitializerImpl(
+ thisKeyword: hasThis ? Tokens.this_() : null,
+ period: hasThis ? Tokens.period() : null,
+ fieldName: fieldName,
+ equals: Tokens.eq(),
+ expression: expression,
);
}
ConstructorName _readConstructorName() {
- var type = readNode() as NamedType;
- var name = _readOptionalNode() as SimpleIdentifier?;
+ var type = readNode() as NamedTypeImpl;
+ var name = _readOptionalNode() as SimpleIdentifierImpl?;
- var node = astFactory.constructorName(
- type,
- name != null ? Tokens.period() : null,
- name,
+ var node = ConstructorNameImpl(
+ type: type,
+ period: name != null ? Tokens.period() : null,
+ name: name,
);
node.staticElement = _reader.readElement() as ConstructorElement?;
return node;
}
ConstructorReference _readConstructorReference() {
- var constructorName = readNode() as ConstructorName;
- var node = astFactory.constructorReference(
+ var constructorName = readNode() as ConstructorNameImpl;
+ var node = ConstructorReferenceImpl(
constructorName: constructorName,
);
_readExpressionResolution(node);
@@ -391,8 +397,8 @@
DefaultFormalParameter _readDefaultFormalParameter() {
var flags = _readByte();
- var parameter = readNode() as NormalFormalParameter;
- var defaultValue = _readOptionalNode() as Expression?;
+ var parameter = readNode() as NormalFormalParameterImpl;
+ var defaultValue = _readOptionalNode() as ExpressionImpl?;
ParameterKind kind;
if (AstBinaryFlags.isPositional(flags)) {
@@ -405,11 +411,11 @@
: ParameterKind.NAMED;
}
- var node = astFactory.defaultFormalParameter(
- parameter,
- kind,
- AstBinaryFlags.hasInitializer(flags) ? Tokens.colon() : null,
- defaultValue,
+ var node = DefaultFormalParameterImpl(
+ parameter: parameter,
+ kind: kind,
+ separator: AstBinaryFlags.hasInitializer(flags) ? Tokens.colon() : null,
+ defaultValue: defaultValue,
);
var nonDefaultElement = parameter.declaredElement!;
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_tokens.dart b/pkg/analyzer/lib/src/summary2/ast_binary_tokens.dart
index b19041d..9b6329f 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_tokens.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_tokens.dart
@@ -75,6 +75,8 @@
static Token factory_() => TokenFactory.tokenFromKeyword(Keyword.FACTORY);
+ static Token false_() => TokenFactory.tokenFromKeyword(Keyword.FALSE);
+
static Token final_() => TokenFactory.tokenFromKeyword(Keyword.FINAL);
static Token finally_() => TokenFactory.tokenFromKeyword(Keyword.FINALLY);
@@ -186,6 +188,8 @@
static Token throw_() => TokenFactory.tokenFromKeyword(Keyword.THROW);
+ static Token true_() => TokenFactory.tokenFromKeyword(Keyword.TRUE);
+
static Token try_() => TokenFactory.tokenFromKeyword(Keyword.TRY);
static Token typedef_() => TokenFactory.tokenFromKeyword(Keyword.TYPEDEF);
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index a9bb9a2..83b178b 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -242,15 +242,15 @@
var initializer = astFactory.instanceCreationExpression(
null,
- astFactory.constructorName(
- astFactory.namedType(
+ ConstructorNameImpl(
+ type: astFactory.namedType(
name: astFactory.simpleIdentifier(
StringToken(TokenType.STRING, element.name, -1),
),
typeArguments: constant.arguments?.typeArguments,
),
- constructorName != null ? Tokens.period() : null,
- constructorName != null
+ period: constructorName != null ? Tokens.period() : null,
+ name: constructorName != null
? astFactory.simpleIdentifier(
StringToken(TokenType.STRING, constructorName, -1),
)
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
index bfd8020..20a95d0 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
@@ -930,22 +930,19 @@
]),
];
- var deprecatedVariable = _topLevelVariable(
+ var deprecatedVariable = _topLevelVariableConst(
'deprecated',
_interfaceType(deprecatedElement),
- isConst: true,
);
- var overrideVariable = _topLevelVariable(
+ var overrideVariable = _topLevelVariableConst(
'override',
_interfaceType(overrideElement),
- isConst: true,
);
- var proxyVariable = _topLevelVariable(
+ var proxyVariable = _topLevelVariableConst(
'proxy',
_interfaceType(proxyElement),
- isConst: true,
);
coreUnit.accessors = <PropertyAccessorElement>[
@@ -1121,14 +1118,12 @@
.toList();
}
- TopLevelVariableElement _topLevelVariable(
- String name,
- DartType type, {
- bool isConst = false,
- bool isFinal = false,
- }) {
- return ElementFactory.topLevelVariableElement3(
- name, isConst, isFinal, type);
+ TopLevelVariableElement _topLevelVariableConst(String name, DartType type) {
+ final variable = ConstTopLevelVariableElementImpl(name, -1)
+ ..isConst = true
+ ..type = type;
+ PropertyAccessorElementImpl_ImplicitGetter(variable);
+ return variable;
}
TypeParameterElementImpl _typeParameter(String name) {
diff --git a/pkg/analyzer/test/dart/ast/ast_test.dart b/pkg/analyzer/test/dart/ast/ast_test.dart
index 3e6441a..b22e22d 100644
--- a/pkg/analyzer/test/dart/ast/ast_test.dart
+++ b/pkg/analyzer/test/dart/ast/ast_test.dart
@@ -12,6 +12,7 @@
import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
import 'package:analyzer/src/generated/testing/token_factory.dart';
import 'package:analyzer/src/summary2/ast_binary_tokens.dart';
+import 'package:analyzer/src/test_utilities/find_node.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -790,28 +791,22 @@
}
void test_isNullAware_cascade_false() {
- final expression = AstTestFactory.indexExpressionForCascade(
- AstTestFactory.nullLiteral(),
- AstTestFactory.nullLiteral(),
- TokenType.PERIOD_PERIOD,
- TokenType.OPEN_SQUARE_BRACKET);
- AstTestFactory.cascadeExpression(
- AstTestFactory.nullLiteral(),
- [expression],
- );
+ final findNode = _parseStringToFindNode('''
+void f() {
+ a..[0];
+}
+''');
+ final expression = findNode.index('[0]');
expect(expression.isNullAware, isFalse);
}
void test_isNullAware_cascade_true() {
- final expression = AstTestFactory.indexExpressionForCascade(
- AstTestFactory.nullLiteral(),
- AstTestFactory.nullLiteral(),
- TokenType.QUESTION_PERIOD_PERIOD,
- TokenType.OPEN_SQUARE_BRACKET);
- AstTestFactory.cascadeExpression(
- AstTestFactory.nullLiteral(),
- [expression],
- );
+ final findNode = _parseStringToFindNode('''
+void f() {
+ a?..[0];
+}
+''');
+ final expression = findNode.index('[0]');
expect(expression.isNullAware, isTrue);
}
@@ -1042,34 +1037,24 @@
}
@reflectiveTest
-class MethodInvocationTest extends ParserTestCase {
+class MethodInvocationTest extends _AstTest {
void test_isNullAware_cascade() {
- var invocation = astFactory.methodInvocation(
- null,
- TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD),
- AstTestFactory.identifier3('foo'),
- null,
- AstTestFactory.argumentList(),
- );
- AstTestFactory.cascadeExpression(
- AstTestFactory.nullLiteral(),
- [invocation],
- );
+ final findNode = _parseStringToFindNode('''
+void f() {
+ a..foo();
+}
+''');
+ final invocation = findNode.methodInvocation('foo');
expect(invocation.isNullAware, isFalse);
}
void test_isNullAware_cascade_true() {
- var invocation = astFactory.methodInvocation(
- null,
- TokenFactory.tokenFromType(TokenType.QUESTION_PERIOD_PERIOD),
- AstTestFactory.identifier3('foo'),
- null,
- AstTestFactory.argumentList(),
- );
- AstTestFactory.cascadeExpression(
- AstTestFactory.nullLiteral(),
- [invocation],
- );
+ final findNode = _parseStringToFindNode('''
+void f() {
+ a?..foo();
+}
+''');
+ final invocation = findNode.methodInvocation('foo');
expect(invocation.isNullAware, isTrue);
}
@@ -1094,8 +1079,8 @@
class NodeListTest {
void test_add() {
AstNode parent = AstTestFactory.argumentList();
- AstNode firstNode = AstTestFactory.booleanLiteral(true);
- AstNode secondNode = AstTestFactory.booleanLiteral(false);
+ AstNode firstNode = true_();
+ AstNode secondNode = false_();
NodeList<AstNode> list = astFactory.nodeList<AstNode>(parent);
list.insert(0, secondNode);
list.insert(0, firstNode);
@@ -1104,7 +1089,7 @@
expect(list[1], same(secondNode));
expect(firstNode.parent, same(parent));
expect(secondNode.parent, same(parent));
- AstNode thirdNode = AstTestFactory.booleanLiteral(false);
+ AstNode thirdNode = false_();
list.insert(1, thirdNode);
expect(list, hasLength(3));
expect(list[0], same(firstNode));
@@ -1119,7 +1104,7 @@
NodeList<AstNode> list =
astFactory.nodeList<AstNode>(AstTestFactory.argumentList());
try {
- list.insert(-1, AstTestFactory.booleanLiteral(true));
+ list.insert(-1, true_());
fail("Expected IndexOutOfBoundsException");
} on RangeError {
// Expected
@@ -1130,7 +1115,7 @@
NodeList<AstNode> list =
astFactory.nodeList<AstNode>(AstTestFactory.argumentList());
try {
- list.insert(1, AstTestFactory.booleanLiteral(true));
+ list.insert(1, true_());
fail("Expected IndexOutOfBoundsException");
} on RangeError {
// Expected
@@ -1140,8 +1125,8 @@
void test_addAll() {
AstNode parent = AstTestFactory.argumentList();
List<AstNode> firstNodes = <AstNode>[];
- AstNode firstNode = AstTestFactory.booleanLiteral(true);
- AstNode secondNode = AstTestFactory.booleanLiteral(false);
+ AstNode firstNode = true_();
+ AstNode secondNode = false_();
firstNodes.add(firstNode);
firstNodes.add(secondNode);
NodeList<AstNode> list = astFactory.nodeList<AstNode>(parent);
@@ -1152,8 +1137,8 @@
expect(firstNode.parent, same(parent));
expect(secondNode.parent, same(parent));
List<AstNode> secondNodes = <AstNode>[];
- AstNode thirdNode = AstTestFactory.booleanLiteral(true);
- AstNode fourthNode = AstTestFactory.booleanLiteral(false);
+ AstNode thirdNode = true_();
+ AstNode fourthNode = false_();
secondNodes.add(thirdNode);
secondNodes.add(fourthNode);
list.addAll(secondNodes);
@@ -1207,8 +1192,7 @@
void test_getBeginToken_nonEmpty() {
NodeList<AstNode> list =
astFactory.nodeList<AstNode>(AstTestFactory.argumentList());
- AstNode node = AstTestFactory.parenthesizedExpression(
- AstTestFactory.booleanLiteral(true));
+ AstNode node = AstTestFactory.parenthesizedExpression(true_());
list.add(node);
expect(list.beginToken, same(node.beginToken));
}
@@ -1222,18 +1206,17 @@
void test_getEndToken_nonEmpty() {
NodeList<AstNode> list =
astFactory.nodeList<AstNode>(AstTestFactory.argumentList());
- AstNode node = AstTestFactory.parenthesizedExpression(
- AstTestFactory.booleanLiteral(true));
+ AstNode node = AstTestFactory.parenthesizedExpression(true_());
list.add(node);
expect(list.endToken, same(node.endToken));
}
void test_indexOf() {
List<AstNode> nodes = <AstNode>[];
- AstNode firstNode = AstTestFactory.booleanLiteral(true);
- AstNode secondNode = AstTestFactory.booleanLiteral(false);
- AstNode thirdNode = AstTestFactory.booleanLiteral(true);
- AstNode fourthNode = AstTestFactory.booleanLiteral(false);
+ AstNode firstNode = true_();
+ AstNode secondNode = false_();
+ AstNode thirdNode = true_();
+ AstNode fourthNode = false_();
nodes.add(firstNode);
nodes.add(secondNode);
nodes.add(thirdNode);
@@ -1249,9 +1232,9 @@
void test_remove() {
List<AstNode> nodes = <AstNode>[];
- AstNode firstNode = AstTestFactory.booleanLiteral(true);
- AstNode secondNode = AstTestFactory.booleanLiteral(false);
- AstNode thirdNode = AstTestFactory.booleanLiteral(true);
+ AstNode firstNode = true_();
+ AstNode secondNode = false_();
+ AstNode thirdNode = true_();
nodes.add(firstNode);
nodes.add(secondNode);
nodes.add(thirdNode);
@@ -1289,9 +1272,9 @@
void test_set() {
List<AstNode> nodes = <AstNode>[];
- AstNode firstNode = AstTestFactory.booleanLiteral(true);
- AstNode secondNode = AstTestFactory.booleanLiteral(false);
- AstNode thirdNode = AstTestFactory.booleanLiteral(true);
+ AstNode firstNode = true_();
+ AstNode secondNode = false_();
+ AstNode thirdNode = true_();
nodes.add(firstNode);
nodes.add(secondNode);
nodes.add(thirdNode);
@@ -1307,7 +1290,7 @@
}
void test_set_negative() {
- AstNode node = AstTestFactory.booleanLiteral(true);
+ AstNode node = true_();
var list = astFactory.nodeList<AstNode>(AstTestFactory.argumentList());
try {
list[-1] = node;
@@ -1318,7 +1301,7 @@
}
void test_set_tooBig() {
- AstNode node = AstTestFactory.booleanLiteral(true);
+ AstNode node = true_();
var list = astFactory.nodeList<AstNode>(AstTestFactory.argumentList());
try {
list[1] = node;
@@ -1327,6 +1310,20 @@
// Expected
}
}
+
+ static BooleanLiteralImpl false_() {
+ return BooleanLiteralImpl(
+ literal: Tokens.true_(),
+ value: true,
+ );
+ }
+
+ static BooleanLiteralImpl true_() {
+ return BooleanLiteralImpl(
+ literal: Tokens.true_(),
+ value: true,
+ );
+ }
}
@reflectiveTest
@@ -1431,24 +1428,24 @@
}
@reflectiveTest
-class PropertyAccessTest extends ParserTestCase {
+class PropertyAccessTest extends _AstTest {
void test_isNullAware_cascade() {
- final invocation = AstTestFactory.propertyAccess2(
- AstTestFactory.nullLiteral(), 'foo', TokenType.PERIOD_PERIOD);
- AstTestFactory.cascadeExpression(
- AstTestFactory.nullLiteral(),
- [invocation],
- );
+ final findNode = _parseStringToFindNode('''
+void f() {
+ a..foo;
+}
+''');
+ final invocation = findNode.propertyAccess('foo');
expect(invocation.isNullAware, isFalse);
}
void test_isNullAware_cascade_true() {
- final invocation = AstTestFactory.propertyAccess2(
- null, 'foo', TokenType.QUESTION_PERIOD_PERIOD);
- AstTestFactory.cascadeExpression(
- AstTestFactory.nullLiteral(),
- [invocation],
- );
+ final findNode = _parseStringToFindNode('''
+void f() {
+ a?..foo;
+}
+''');
+ final invocation = findNode.propertyAccess('foo');
expect(invocation.isNullAware, isTrue);
}
@@ -1487,9 +1484,11 @@
}
void test_inGetterContext_constructorFieldInitializer() {
- ConstructorFieldInitializer initializer =
- AstTestFactory.constructorFieldInitializer(
- false, 'f', AstTestFactory.integer(0));
+ final initializer = _parseStringToNode<ConstructorFieldInitializer>('''
+class A {
+ A() : ^f = 0;
+}
+''');
SimpleIdentifier identifier = initializer.fieldName;
expect(identifier.inGetterContext(), isFalse);
}
@@ -1560,9 +1559,10 @@
}
void test_isQualified_inConstructorName() {
- ConstructorName constructor = AstTestFactory.constructorName(
- AstTestFactory.namedType4('MyClass'), "test");
- SimpleIdentifier name = constructor.name!;
+ final constructor = _parseStringToNode<ConstructorName>(r'''
+final x = List<String>.^foo();
+''');
+ final name = constructor.name!;
expect(name.isQualified, isTrue);
}
@@ -2207,6 +2207,14 @@
}
class _AstTest {
+ FindNode _parseStringToFindNode(String content) {
+ var parseResult = parseString(
+ content: content,
+ featureSet: FeatureSets.latestWithExperiments,
+ );
+ return FindNode(parseResult.content, parseResult.unit);
+ }
+
T _parseStringToNode<T extends AstNode>(String codeWithMark) {
var offset = codeWithMark.indexOf('^');
expect(offset, isNot(equals(-1)), reason: 'missing ^');
diff --git a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
index 9ed16ce..a40cbfd 100644
--- a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
@@ -200,46 +200,73 @@
}
void test_visitBooleanLiteral_false() {
- _assertSource("false", AstTestFactory.booleanLiteral(false));
+ final code = 'false';
+ final findNode = _parseStringToFindNode('''
+final v = $code;
+''');
+ _assertSource(code, findNode.booleanLiteral(code));
}
void test_visitBooleanLiteral_true() {
- _assertSource("true", AstTestFactory.booleanLiteral(true));
+ final code = 'true';
+ final findNode = _parseStringToFindNode('''
+final v = $code;
+''');
+ _assertSource(code, findNode.booleanLiteral(code));
}
void test_visitBreakStatement_label() {
- _assertSource("break l;", AstTestFactory.breakStatement2("l"));
+ final code = 'break L;';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ L: while (true) {
+ $code
+ }
+}
+''');
+ _assertSource(code, findNode.breakStatement(code));
}
void test_visitBreakStatement_noLabel() {
- _assertSource("break;", AstTestFactory.breakStatement());
+ final code = 'break;';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ while (true) {
+ $code
+ }
+}
+''');
+ _assertSource(code, findNode.breakStatement(code));
}
void test_visitCascadeExpression_field() {
- _assertSource(
- "a..b..c",
- AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
- AstTestFactory.cascadedPropertyAccess("b"),
- AstTestFactory.cascadedPropertyAccess("c")
- ]));
+ final code = 'a..b..c';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ $code;
+}
+''');
+ _assertSource(code, findNode.cascade(code));
}
void test_visitCascadeExpression_index() {
- _assertSource(
- "a..[0]..[1]",
- AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
- AstTestFactory.cascadedIndexExpression(AstTestFactory.integer(0)),
- AstTestFactory.cascadedIndexExpression(AstTestFactory.integer(1))
- ]));
+ final code = 'a..[0]..[1]';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ $code;
+}
+''');
+ _assertSource(code, findNode.cascade(code));
}
void test_visitCascadeExpression_method() {
- _assertSource(
- "a..b()..c()",
- AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
- AstTestFactory.cascadedMethodInvocation("b"),
- AstTestFactory.cascadedMethodInvocation("c")
- ]));
+ final code = 'a..b()..c()';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ $code;
+}
+''');
+ _assertSource(code, findNode.cascade(code));
}
void test_visitCatchClause_catch_noStack() {
@@ -640,8 +667,12 @@
}
void test_visitCommentReference() {
- _assertSource(
- "", astFactory.commentReference(null, AstTestFactory.identifier3("a")));
+ final code = 'x';
+ final findNode = _parseStringToFindNode('''
+/// [$code]
+void f() {}
+''');
+ _assertSource('', findNode.commentReference(code));
}
void test_visitCompilationUnit_declaration() {
@@ -708,10 +739,13 @@
}
void test_visitConditionalExpression() {
- _assertSource(
- "a ? b : c",
- AstTestFactory.conditionalExpression(AstTestFactory.identifier3("a"),
- AstTestFactory.identifier3("b"), AstTestFactory.identifier3("c")));
+ final code = 'a ? b : c';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ $code;
+}
+''');
+ _assertSource(code, findNode.conditionalExpression(code));
}
void test_visitConstructorDeclaration_const() {
@@ -792,45 +826,71 @@
}
void test_visitConstructorFieldInitializer_withoutThis() {
- _assertSource(
- "a = b",
- AstTestFactory.constructorFieldInitializer(
- false, "a", AstTestFactory.identifier3("b")));
+ final code = 'a = 0';
+ final findNode = _parseStringToFindNode('''
+class C {
+ C() : $code;
+}
+''');
+ _assertSource(code, findNode.constructorFieldInitializer(code));
}
void test_visitConstructorFieldInitializer_withThis() {
- _assertSource(
- "this.a = b",
- AstTestFactory.constructorFieldInitializer(
- true, "a", AstTestFactory.identifier3("b")));
+ final code = 'this.a = 0';
+ final findNode = _parseStringToFindNode('''
+class C {
+ C() : $code;
+}
+''');
+ _assertSource(code, findNode.constructorFieldInitializer(code));
}
void test_visitConstructorName_named_prefix() {
- _assertSource(
- "p.C.n",
- AstTestFactory.constructorName(
- AstTestFactory.namedType4("p.C.n"), null));
+ final code = 'prefix.A.foo';
+ final findNode = _parseStringToFindNode('''
+final x = new $code();
+''');
+ _assertSource(code, findNode.constructorName(code));
}
void test_visitConstructorName_unnamed_noPrefix() {
- _assertSource("C",
- AstTestFactory.constructorName(AstTestFactory.namedType4("C"), null));
+ final code = 'A';
+ final findNode = _parseStringToFindNode('''
+final x = new $code();
+''');
+ _assertSource(code, findNode.constructorName(code));
}
void test_visitConstructorName_unnamed_prefix() {
- _assertSource(
- "p.C",
- AstTestFactory.constructorName(
- AstTestFactory.namedType3(AstTestFactory.identifier5("p", "C")),
- null));
+ final code = 'prefix.A';
+ final findNode = _parseStringToFindNode('''
+final x = new $code();
+''');
+ _assertSource(code, findNode.constructorName(code));
}
void test_visitContinueStatement_label() {
- _assertSource("continue l;", AstTestFactory.continueStatement("l"));
+ final code = 'continue L;';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ L: while (true) {
+ $code
+ }
+}
+''');
+ _assertSource(code, findNode.continueStatement('continue'));
}
void test_visitContinueStatement_noLabel() {
- _assertSource("continue;", AstTestFactory.continueStatement());
+ final code = 'continue;';
+ final findNode = _parseStringToFindNode('''
+void f() {
+ while (true) {
+ $code
+ }
+}
+''');
+ _assertSource(code, findNode.continueStatement('continue'));
}
void test_visitDefaultFormalParameter_annotation() {
@@ -842,33 +902,35 @@
}
void test_visitDefaultFormalParameter_named_noValue() {
- _assertSource(
- "p",
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("p"), null));
+ final code = 'int? a';
+ final findNode = _parseStringToFindNode('''
+void f({$code}) {}
+''');
+ _assertSource(code, findNode.defaultParameter(code));
}
void test_visitDefaultFormalParameter_named_value() {
- _assertSource(
- "p: 0",
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("p"),
- AstTestFactory.integer(0)));
+ final code = 'int? a = 0';
+ final findNode = _parseStringToFindNode('''
+void f({$code}) {}
+''');
+ _assertSource(code, findNode.defaultParameter(code));
}
void test_visitDefaultFormalParameter_positional_noValue() {
- _assertSource(
- "p",
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("p"), null));
+ final code = 'int? a';
+ final findNode = _parseStringToFindNode('''
+void f([$code]) {}
+''');
+ _assertSource(code, findNode.defaultParameter(code));
}
void test_visitDefaultFormalParameter_positional_value() {
- _assertSource(
- "p = 0",
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("p"),
- AstTestFactory.integer(0)));
+ final code = 'int? a = 0';
+ final findNode = _parseStringToFindNode('''
+void f([$code]) {}
+''');
+ _assertSource(code, findNode.defaultParameter(code));
}
void test_visitDoStatement() {
@@ -1546,67 +1608,43 @@
}
void test_visitFormalParameterList_n() {
- _assertSource(
- "({a: 0})",
- AstTestFactory.formalParameterList([
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.integer(0))
- ]));
+ final code = '({a = 0})';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_namedRequired() {
- _assertSource(
- "({required a, required A b})",
- AstTestFactory.formalParameterList([
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("a")
- ..requiredKeyword =
- TokenFactory.tokenFromKeyword(Keyword.REQUIRED),
- null),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter2(
- null, AstTestFactory.namedType4('A'), "b")
- ..requiredKeyword =
- TokenFactory.tokenFromKeyword(Keyword.REQUIRED),
- null),
- ]));
+ final code = '({required a, required int b})';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_nn() {
- _assertSource(
- "({a: 0, b: 1})",
- AstTestFactory.formalParameterList([
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.integer(0)),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.integer(1))
- ]));
+ final code = '({int a = 0, b = 1})';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_p() {
- _assertSource(
- "([a = 0])",
- AstTestFactory.formalParameterList([
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.integer(0))
- ]));
+ final code = '([a = 0])';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_pp() {
- _assertSource(
- "([a = 0, b = 1])",
- AstTestFactory.formalParameterList([
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.integer(0)),
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.integer(1))
- ]));
+ final code = '([a = 0, b = 1])';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_r() {
@@ -1617,53 +1655,35 @@
}
void test_visitFormalParameterList_rn() {
- _assertSource(
- "(a, {b: 1})",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.integer(1))
- ]));
+ final code = '(a, {b = 1})';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_rnn() {
- _assertSource(
- "(a, {b: 1, c: 2})",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.integer(1)),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("c"),
- AstTestFactory.integer(2))
- ]));
+ final code = '(a, {b = 1, c = 2})';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_rp() {
- _assertSource(
- "(a, [b = 1])",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.integer(1))
- ]));
+ final code = '(a, [b = 1])';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_rpp() {
- _assertSource(
- "(a, [b = 1, c = 2])",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.integer(1)),
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("c"),
- AstTestFactory.integer(2))
- ]));
+ final code = '(a, [b = 1, c = 2])';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_rr() {
@@ -1676,57 +1696,35 @@
}
void test_visitFormalParameterList_rrn() {
- _assertSource(
- "(a, b, {c: 3})",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("c"),
- AstTestFactory.integer(3))
- ]));
+ final code = '(a, b, {c = 2})';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_rrnn() {
- _assertSource(
- "(a, b, {c: 3, d: 4})",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("c"),
- AstTestFactory.integer(3)),
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter3("d"),
- AstTestFactory.integer(4))
- ]));
+ final code = '(a, b, {c = 2, d = 3})';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_rrp() {
- _assertSource(
- "(a, b, [c = 3])",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("c"),
- AstTestFactory.integer(3))
- ]));
+ final code = '(a, b, [c = 2])';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitFormalParameterList_rrpp() {
- _assertSource(
- "(a, b, [c = 3, d = 4])",
- AstTestFactory.formalParameterList([
- AstTestFactory.simpleFormalParameter3("a"),
- AstTestFactory.simpleFormalParameter3("b"),
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("c"),
- AstTestFactory.integer(3)),
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter3("d"),
- AstTestFactory.integer(4))
- ]));
+ final code = '(a, b, [c = 2, d = 3])';
+ final findNode = _parseStringToFindNode('''
+void f$code {}
+''');
+ _assertSource(code, findNode.formalParameterList(code));
}
void test_visitForPartsWithDeclarations() {
@@ -2257,24 +2255,27 @@
}
void test_visitInstanceCreationExpression_const() {
- _assertSource(
- "const C()",
- AstTestFactory.instanceCreationExpression2(
- Keyword.CONST, AstTestFactory.namedType4("C")));
+ final code = 'const A()';
+ final findNode = _parseStringToFindNode('''
+final x = $code;
+''');
+ _assertSource(code, findNode.instanceCreation(code));
}
void test_visitInstanceCreationExpression_named() {
- _assertSource(
- "new C.c()",
- AstTestFactory.instanceCreationExpression3(
- Keyword.NEW, AstTestFactory.namedType4("C"), "c"));
+ final code = 'new A.foo()';
+ final findNode = _parseStringToFindNode('''
+final x = $code;
+''');
+ _assertSource(code, findNode.instanceCreation(code));
}
void test_visitInstanceCreationExpression_unnamed() {
- _assertSource(
- "new C()",
- AstTestFactory.instanceCreationExpression2(
- Keyword.NEW, AstTestFactory.namedType4("C")));
+ final code = 'new A()';
+ final findNode = _parseStringToFindNode('''
+final x = $code;
+''');
+ _assertSource(code, findNode.instanceCreation(code));
}
void test_visitIntegerLiteral() {
@@ -2666,11 +2667,11 @@
}
void test_visitNamedFormalParameter() {
- _assertSource(
- "var a: 0",
- AstTestFactory.namedFormalParameter(
- AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
- AstTestFactory.integer(0)));
+ final code = 'var a = 0';
+ final findNode = _parseStringToFindNode('''
+void f({$code}) {}
+''');
+ _assertSource(code, findNode.defaultParameter(code));
}
void test_visitNativeClause() {
@@ -2721,11 +2722,11 @@
}
void test_visitPositionalFormalParameter() {
- _assertSource(
- "var a = 0",
- AstTestFactory.positionalFormalParameter(
- AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
- AstTestFactory.integer(0)));
+ final code = 'var a = 0';
+ final findNode = _parseStringToFindNode('''
+void f([$code]) {}
+''');
+ _assertSource(code, findNode.defaultParameter(code));
}
void test_visitPostfixExpression() {
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
index 3b4dac7..00b9a00 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
@@ -28,7 +28,23 @@
int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
+ ]);
+ }
+
+ test_instance_field_field_field() async {
+ await assertErrorsInCode(r'''
+class C {
+ int foo = 0;
+ int foo = 0;
+ int foo = 0;
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -39,7 +55,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 35, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 35, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -50,7 +67,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -61,7 +79,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 22, 3)]),
]);
}
@@ -81,7 +100,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 20, 3)]),
]);
}
@@ -92,7 +112,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 20, 3)]),
]);
}
@@ -112,7 +133,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 3)]),
]);
}
@@ -123,7 +145,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 3)]),
]);
}
@@ -134,7 +157,8 @@
set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 3)]),
]);
}
@@ -154,7 +178,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -165,7 +190,8 @@
void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 42, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 42, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 3)]),
]);
}
@@ -176,7 +202,8 @@
static int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -187,7 +214,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 49, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 49, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -198,7 +226,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -209,7 +238,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 55, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 55, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 3)]),
]);
}
@@ -229,7 +259,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 54, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 54, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -240,7 +271,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -260,7 +292,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -271,7 +304,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -282,7 +316,8 @@
static set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -302,7 +337,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -313,7 +349,8 @@
static void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 56, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 56, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 3)]),
]);
}
@@ -335,7 +372,8 @@
foo, foo
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 16, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 16, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 11, 3)]),
]);
}
@@ -347,7 +385,8 @@
final int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 26, 3)]),
]);
}
@@ -359,7 +398,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 26, 3)]),
]);
}
@@ -371,7 +411,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 42, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 42, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 26, 3)]),
]);
}
@@ -383,7 +424,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 26, 3)]),
]);
}
@@ -405,7 +447,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 44, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 44, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -417,7 +460,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -439,7 +483,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 3)]),
]);
}
@@ -451,7 +496,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 3)]),
]);
}
@@ -463,7 +509,8 @@
set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 3)]),
]);
}
@@ -485,7 +532,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 20, 3)]),
]);
}
@@ -497,7 +545,8 @@
void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 3)]),
]);
}
@@ -508,7 +557,8 @@
static int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 29, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 29, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 11, 3)]),
]);
}
@@ -519,7 +569,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 11, 3)]),
]);
}
@@ -530,7 +581,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 30, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 30, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 11, 3)]),
]);
}
@@ -551,7 +603,8 @@
static int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 49, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 49, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -563,7 +616,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 53, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 53, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -575,7 +629,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -587,7 +642,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 59, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 59, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 33, 3)]),
]);
}
@@ -609,7 +665,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 58, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 58, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 31, 3)]),
]);
}
@@ -621,7 +678,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 55, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 55, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 31, 3)]),
]);
}
@@ -643,7 +701,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 54, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 54, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 3)]),
]);
}
@@ -655,7 +714,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 3)]),
]);
}
@@ -667,7 +727,8 @@
static set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 3)]),
]);
}
@@ -689,7 +750,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -701,7 +763,8 @@
static void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 60, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 60, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 32, 3)]),
]);
}
}
@@ -748,7 +811,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 60, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 60, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 3)]),
]);
}
@@ -760,7 +824,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 57, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 57, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 3)]),
]);
}
@@ -782,7 +847,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 56, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 56, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 37, 3)]),
]);
}
@@ -794,7 +860,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 53, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 53, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 37, 3)]),
]);
}
@@ -806,7 +873,8 @@
set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 52, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 52, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 37, 3)]),
]);
}
@@ -828,7 +896,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 53, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 53, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 36, 3)]),
]);
}
@@ -840,7 +909,8 @@
void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 62, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 62, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 41, 3)]),
]);
}
@@ -852,7 +922,8 @@
static int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 65, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 65, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 43, 3)]),
]);
}
@@ -864,7 +935,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 69, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 69, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 43, 3)]),
]);
}
@@ -876,7 +948,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 66, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 66, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 43, 3)]),
]);
}
@@ -888,7 +961,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 75, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 75, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 49, 3)]),
]);
}
@@ -910,7 +984,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 74, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 74, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 47, 3)]),
]);
}
@@ -922,7 +997,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 71, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 71, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 47, 3)]),
]);
}
@@ -944,7 +1020,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 70, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 70, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 44, 3)]),
]);
}
@@ -956,7 +1033,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 67, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 67, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 44, 3)]),
]);
}
@@ -968,7 +1046,8 @@
static set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 66, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 66, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 44, 3)]),
]);
}
@@ -989,7 +1068,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 67, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 67, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 43, 3)]),
]);
}
@@ -1001,7 +1081,8 @@
static void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 76, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 76, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 48, 3)]),
]);
}
@@ -1011,7 +1092,8 @@
extension E on A {}
extension E on A {}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 1)]),
]);
}
}
@@ -1025,7 +1107,8 @@
int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -1036,7 +1119,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 35, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 35, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -1047,7 +1131,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -1058,7 +1143,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 41, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 22, 3)]),
]);
}
@@ -1078,7 +1164,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 20, 3)]),
]);
}
@@ -1089,7 +1176,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 20, 3)]),
]);
}
@@ -1109,7 +1197,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 3)]),
]);
}
@@ -1120,7 +1209,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 3)]),
]);
}
@@ -1131,7 +1221,8 @@
set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 32, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 3)]),
]);
}
@@ -1151,7 +1242,8 @@
void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -1162,7 +1254,8 @@
void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 42, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 42, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 3)]),
]);
}
@@ -1173,7 +1266,8 @@
static int foo = 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 45, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -1184,7 +1278,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 49, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 49, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -1195,7 +1290,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -1206,7 +1302,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 55, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 55, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 3)]),
]);
}
@@ -1226,7 +1323,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 54, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 54, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -1237,7 +1335,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 27, 3)]),
]);
}
@@ -1257,7 +1356,8 @@
static int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 50, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -1268,7 +1368,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -1279,7 +1380,8 @@
static set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 46, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 3)]),
]);
}
@@ -1299,7 +1401,8 @@
static void foo() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 47, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -1310,7 +1413,8 @@
static void set foo(_) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 56, 3),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 56, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 3)]),
]);
}
}
@@ -1323,7 +1427,8 @@
try {} catch (e, e) {}
}''', [
error(HintCode.UNUSED_CATCH_STACK, 28, 1),
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 28, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 28, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 1)]),
]);
}
@@ -1346,7 +1451,8 @@
for (int i = 0, i = 0; i < 5;) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 24, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 24, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 1)]),
error(HintCode.UNUSED_LOCAL_VARIABLE, 24, 1),
]);
}
@@ -1368,7 +1474,8 @@
''', [
error(HintCode.UNUSED_LOCAL_VARIABLE, 40, 1),
error(HintCode.UNUSED_LOCAL_VARIABLE, 51, 1),
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
]);
}
@@ -1382,7 +1489,8 @@
}
''', [
error(HintCode.UNUSED_LOCAL_VARIABLE, 26, 1),
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 37, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 26, 1)]),
error(HintCode.UNUSED_LOCAL_VARIABLE, 37, 1),
]);
}
@@ -1399,7 +1507,8 @@
''', [
error(HintCode.UNUSED_LOCAL_VARIABLE, 45, 1),
error(HintCode.UNUSED_LOCAL_VARIABLE, 58, 1),
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 58, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 58, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
]);
}
@@ -1411,7 +1520,8 @@
}
''', [
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 24, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 24, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 15, 1)]),
error(HintCode.UNUSED_ELEMENT, 24, 1),
]);
}
@@ -1423,7 +1533,8 @@
A(this.a, int a);
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 1)]),
]);
}
@@ -1434,7 +1545,8 @@
A(int a, this.a);
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 36, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 1)]),
]);
}
@@ -1442,7 +1554,8 @@
await assertErrorsInCode(r'''
typedef void F(int a, double a);
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 29, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 29, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 19, 1)]),
]);
}
@@ -1450,7 +1563,8 @@
await assertErrorsInCode(r'''
typedef F = void Function(int a, double a);
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 40, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 30, 1)]),
]);
}
@@ -1462,7 +1576,8 @@
}
''', [
error(HintCode.UNUSED_ELEMENT, 11, 1),
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 1)]),
]);
}
@@ -1473,7 +1588,8 @@
}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 28, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 28, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 18, 1)]),
]);
}
@@ -1481,7 +1597,8 @@
await assertErrorsInCode(r'''
f(int a, double a) {}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 16, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 16, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 6, 1)]),
]);
}
@@ -1489,7 +1606,8 @@
await assertErrorsInCode(r'''
class A<T, T> {}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 11, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 11, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 8, 1)]),
]);
}
@@ -1497,7 +1615,8 @@
await assertErrorsInCode(r'''
typedef void F<T, T>();
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 18, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 18, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 15, 1)]),
]);
}
@@ -1505,7 +1624,8 @@
await assertErrorsInCode(r'''
typedef F = void Function<T, T>();
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 29, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 29, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 26, 1)]),
]);
}
@@ -1513,7 +1633,8 @@
await assertErrorsInCode(r'''
typedef F<T, T> = void Function();
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 13, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 13, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 10, 1)]),
]);
}
@@ -1521,7 +1642,8 @@
await assertErrorsInCode(r'''
typedef F<T, T> = Map;
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 13, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 13, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 10, 1)]),
]);
}
@@ -1531,7 +1653,8 @@
void m<T, T>() {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 22, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 22, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 19, 1)]),
]);
}
@@ -1539,7 +1662,8 @@
await assertErrorsInCode(r'''
void f<T, T>() {}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 10, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 10, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 7, 1)]),
]);
}
@@ -1549,7 +1673,8 @@
class B {}
class A {}
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 28, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 28, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 6, 1)])
]);
}
@@ -1573,7 +1698,8 @@
GatheringErrorListener()
..addAll(aResult.errors)
..assertErrors([
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1,
+ contextMessages: [message('/home/test/lib/lib.dart', 22, 1)]),
]);
}
@@ -1607,7 +1733,8 @@
GatheringErrorListener()
..addAll(bResult.errors)
..assertErrors([
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1,
+ contextMessages: [message('/home/test/lib/a.dart', 27, 1)]),
]);
}
@@ -1616,7 +1743,8 @@
typedef A = List<int>;
typedef A = List<int>;
''', [
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 8, 1)]),
]);
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_field_formal_parameter_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_field_formal_parameter_test.dart
index 586709e..6240510 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_field_formal_parameter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_field_formal_parameter_test.dart
@@ -22,7 +22,8 @@
A({this.a = 0, this.a = 1});
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 41, 1),
+ error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 41, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 1)]),
]);
}
@@ -33,7 +34,8 @@
A([this.a = 0, this.a = 1]);
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 41, 1),
+ error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 41, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 1)]),
]);
}
@@ -44,7 +46,8 @@
A([this.x = 1, this.x = 2]) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 43, 1),
+ error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 43, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 31, 1)]),
]);
}
@@ -55,7 +58,8 @@
A({required this.a, required this.a});
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 55, 1),
+ error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 55, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 38, 1)]),
]);
}
@@ -66,7 +70,8 @@
A(this.a, this.a);
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 36, 1),
+ error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 36, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 1)]),
]);
}
@@ -77,7 +82,8 @@
A(this.x, this.x) {}
}
''', [
- error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 38, 1),
+ error(CompileTimeErrorCode.DUPLICATE_FIELD_FORMAL_PARAMETER, 38, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 30, 1)]),
]);
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart b/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart
index 1050310..711d029 100644
--- a/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart
@@ -25,7 +25,8 @@
typedef p();
p.A a = p.A();
''', [
- error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 32, 1),
+ error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 32, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 1)]),
]);
}
@@ -53,7 +54,8 @@
p() {}
p.A a = p.A();
''', [
- error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 24, 1),
+ error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 24, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 1)]),
]);
}
@@ -67,7 +69,8 @@
var p = null;
p.A a = p.A();
''', [
- error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 28, 1),
+ error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 28, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 1)]),
]);
}
@@ -81,7 +84,8 @@
class p {}
p.A a = p.A();
''', [
- error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 30, 1),
+ error(CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, 30, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 1)]),
]);
}
}
diff --git a/pkg/analyzer_cli/lib/src/options.dart b/pkg/analyzer_cli/lib/src/options.dart
index bb914e3..4430145 100644
--- a/pkg/analyzer_cli/lib/src/options.dart
+++ b/pkg/analyzer_cli/lib/src/options.dart
@@ -22,8 +22,6 @@
const _enableExperimentOption = 'enable-experiment';
const _enableInitializingFormalAccessFlag = 'initializing-formal-access';
const _ignoreUnrecognizedFlagsFlag = 'ignore-unrecognized-flags';
-const _implicitCastsFlag = 'implicit-casts';
-const _noImplicitDynamicFlag = 'no-implicit-dynamic';
const _packagesOption = 'packages';
const _sdkPathOption = 'dart-sdk';
@@ -175,10 +173,6 @@
return castNullable(_argResults[_enableExperimentOption]);
}
- bool? get implicitCasts => _argResults[_implicitCastsFlag] as bool?;
-
- bool? get noImplicitDynamic => _argResults[_noImplicitDynamicFlag] as bool?;
-
/// Update the [analysisOptions] with flags that the user specified
/// explicitly. The [analysisOptions] are usually loaded from one of
/// `analysis_options.yaml` files, possibly with includes. We consider
@@ -201,16 +195,6 @@
flags: enabledExperiments,
);
}
-
- var implicitCasts = this.implicitCasts;
- if (implicitCasts != null) {
- analysisOptions.implicitCasts = implicitCasts;
- }
-
- var noImplicitDynamic = this.noImplicitDynamic;
- if (noImplicitDynamic != null) {
- analysisOptions.implicitDynamic = !noImplicitDynamic;
- }
}
/// Return a list of command-line arguments containing all of the given [args]
@@ -327,31 +311,10 @@
help: 'The path to the Dart SDK.', hide: ddc && hide);
parser.addOption(_analysisOptionsFileOption,
help: 'Path to an analysis options file.', hide: ddc && hide);
- parser.addFlag('strong',
- help: 'Enable strong mode (deprecated); this option is now ignored.',
- defaultsTo: true,
- hide: true,
- negatable: true);
- parser.addFlag('declaration-casts',
- negatable: true,
- help:
- 'Disable declaration casts in strong mode (https://goo.gl/cTLz40)\n'
- 'This option is now ignored and will be removed in a future release.',
- hide: ddc && hide);
parser.addMultiOption(_enableExperimentOption,
help: 'Enable one or more experimental features. If multiple features '
'are being added, they should be comma separated.',
splitCommas: true);
- parser.addFlag(_implicitCastsFlag,
- negatable: true,
- help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40).',
- defaultsTo: null,
- hide: ddc && hide);
- parser.addFlag(_noImplicitDynamicFlag,
- defaultsTo: null,
- negatable: false,
- help: 'Disable implicit dynamic (https://goo.gl/m0UgXD).',
- hide: ddc && hide);
//
// Hidden flags and options.
@@ -520,11 +483,6 @@
}
}
- if (results.wasParsed('strong')) {
- errorSink.writeln(
- 'Note: the --strong flag is deprecated and will be removed in an '
- 'future release.\n');
- }
if (results.wasParsed(_enableExperimentOption)) {
var names =
(results[_enableExperimentOption] as List).cast<String>().toList();
diff --git a/pkg/analyzer_cli/test/options_test.dart b/pkg/analyzer_cli/test/options_test.dart
index 397a42f..95528b5 100644
--- a/pkg/analyzer_cli/test/options_test.dart
+++ b/pkg/analyzer_cli/test/options_test.dart
@@ -61,11 +61,9 @@
expect(options.enabledExperiments, isEmpty);
expect(options.displayVersion, isFalse);
expect(options.ignoreUnrecognizedFlags, isFalse);
- expect(options.implicitCasts, isNull);
expect(options.log, isFalse);
expect(options.jsonFormat, isFalse);
expect(options.machineFormat, isFalse);
- expect(options.noImplicitDynamic, isNull);
expect(options.batchMode, isFalse);
expect(options.sourceFiles, equals(['foo.dart']));
expect(options.trainSnapshot, isFalse);
@@ -381,86 +379,6 @@
});
}
- void test_updateAnalysisOptions_implicitCasts() {
- // Turn on.
- _applyAnalysisOptions(
- ['--implicit-casts', 'a.dart'],
- (analysisOptions) {
- analysisOptions.implicitCasts = false;
- },
- (analysisOptions) {
- expect(analysisOptions.implicitCasts, isTrue);
- },
- );
-
- // Turn off.
- _applyAnalysisOptions(
- ['--no-implicit-casts', 'a.dart'],
- (analysisOptions) {
- analysisOptions.implicitCasts = true;
- },
- (analysisOptions) {
- expect(analysisOptions.implicitCasts, isFalse);
- },
- );
-
- // Don't change if not provided, false.
- _applyAnalysisOptions(
- ['a.dart'],
- (analysisOptions) {
- analysisOptions.implicitCasts = false;
- },
- (analysisOptions) {
- expect(analysisOptions.implicitCasts, isFalse);
- },
- );
-
- // Don't change if not provided, true.
- _applyAnalysisOptions(
- ['a.dart'],
- (analysisOptions) {
- analysisOptions.implicitCasts = true;
- },
- (analysisOptions) {
- expect(analysisOptions.implicitCasts, isTrue);
- },
- );
- }
-
- void test_updateAnalysisOptions_noImplicitDynamic() {
- _applyAnalysisOptions(
- ['--no-implicit-dynamic', 'a.dart'],
- (analysisOptions) {
- analysisOptions.implicitDynamic = true;
- },
- (analysisOptions) {
- expect(analysisOptions.implicitDynamic, isFalse);
- },
- );
-
- // Don't change if not provided, false.
- _applyAnalysisOptions(
- ['a.dart'],
- (analysisOptions) {
- analysisOptions.implicitDynamic = false;
- },
- (analysisOptions) {
- expect(analysisOptions.implicitDynamic, isFalse);
- },
- );
-
- // Don't change if not provided, true.
- _applyAnalysisOptions(
- ['a.dart'],
- (analysisOptions) {
- analysisOptions.implicitDynamic = true;
- },
- (analysisOptions) {
- expect(analysisOptions.implicitDynamic, isTrue);
- },
- );
- }
-
void _applyAnalysisOptions(
List<String> args,
void Function(AnalysisOptionsImpl) configureInitial,
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 3aa7df2..41f9204 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -478,7 +478,11 @@
return null;
}
}
- _buildField(target);
+ if (targetElement.isInstanceMember) {
+ _buildInstanceFieldSetter(target);
+ } else {
+ _buildStaticFieldInitializer(target);
+ }
} else if (target is ir.LocalFunction) {
_buildFunctionNode(targetElement,
_ensureDefaultArgumentValues(null, target.function));
@@ -579,52 +583,56 @@
return function;
}
- void _buildField(ir.Field node) {
- graph.isLazyInitializer = node.isStatic;
+ void _buildInstanceFieldSetter(ir.Field node) {
+ assert(!node.isStatic);
FieldEntity field = _elementMap.getMember(node);
_openFunction(field, checks: TargetChecks.none);
- if (node.isInstanceMember &&
- closedWorld.annotationsData.getParameterCheckPolicy(field).isEmitted) {
- HInstruction thisInstruction = localsHandler.readThis(
- sourceInformation: _sourceInformationBuilder.buildGet(node));
- // Use dynamic type because the type computed by the inferrer is
- // narrowed to the type annotation.
- HInstruction parameter =
- HParameterValue(field, _abstractValueDomain.dynamicType);
- // Add the parameter as the last instruction of the entry block.
- // If the method is intercepted, we want the actual receiver
- // to be the first parameter.
- graph.entry.addBefore(graph.entry.last, parameter);
- DartType type = _getDartTypeIfValid(node.type);
- HInstruction value = _typeBuilder.potentiallyCheckOrTrustTypeOfParameter(
- field, parameter, type);
- // TODO(sra): Pass source information to
- // [potentiallyCheckOrTrustTypeOfParameter].
- // TODO(sra): The source information should indicate the field and
- // possibly its type but not the initializer.
- value.sourceInformation ??= _sourceInformationBuilder.buildSet(node);
- value = _potentiallyAssertNotNull(field, node, value, type);
- if (!_fieldAnalysis.getFieldData(field).isElided) {
- add(HFieldSet(_abstractValueDomain, field, thisInstruction, value));
- }
- } else {
- if (node.initializer != null) {
- node.initializer.accept(this);
- HInstruction fieldValue = pop();
- HInstruction checkInstruction =
- _typeBuilder.potentiallyCheckOrTrustTypeOfAssignment(
- field, fieldValue, _getDartTypeIfValid(node.type));
- stack.add(checkInstruction);
- } else {
- stack.add(graph.addConstantNull(closedWorld));
- }
- HInstruction value = pop();
- _closeAndGotoExit(HReturn(_abstractValueDomain, value,
- _sourceInformationBuilder.buildReturn(node)));
+ HInstruction thisInstruction = localsHandler.readThis(
+ sourceInformation: _sourceInformationBuilder.buildGet(node));
+ // Use dynamic type because the type computed by the inferrer is
+ // narrowed to the type annotation.
+ HInstruction parameter =
+ HParameterValue(field, _abstractValueDomain.dynamicType);
+ // Add the parameter as the last instruction of the entry block.
+ // If the method is intercepted, we want the actual receiver
+ // to be the first parameter.
+ graph.entry.addBefore(graph.entry.last, parameter);
+ DartType type = _getDartTypeIfValid(node.type);
+ HInstruction value = _typeBuilder.potentiallyCheckOrTrustTypeOfParameter(
+ field, parameter, type);
+ // TODO(sra): Pass source information to
+ // [potentiallyCheckOrTrustTypeOfParameter].
+ // TODO(sra): The source information should indicate the field and
+ // possibly its type but not the initializer.
+ value.sourceInformation ??= _sourceInformationBuilder.buildSet(node);
+ value = _potentiallyAssertNotNull(field, node, value, type);
+ if (!_fieldAnalysis.getFieldData(field).isElided) {
+ add(HFieldSet(_abstractValueDomain, field, thisInstruction, value));
}
_closeFunction();
}
+ void _buildStaticFieldInitializer(ir.Field node) {
+ assert(node.isStatic);
+ graph.isLazyInitializer = true;
+ FieldEntity field = _elementMap.getMember(node);
+ _openFunction(field, checks: TargetChecks.none);
+ if (node.initializer != null) {
+ node.initializer.accept(this);
+ HInstruction fieldValue = pop();
+ HInstruction checkInstruction =
+ _typeBuilder.potentiallyCheckOrTrustTypeOfAssignment(
+ field, fieldValue, _getDartTypeIfValid(node.type));
+ stack.add(checkInstruction);
+ } else {
+ stack.add(graph.addConstantNull(closedWorld));
+ }
+ HInstruction value = pop();
+ _closeAndGotoExit(HReturn(_abstractValueDomain, value,
+ _sourceInformationBuilder.buildReturn(node)));
+ _closeFunction();
+ }
+
DartType _getDartTypeIfValid(ir.DartType type) {
if (type is ir.InvalidType) return dartTypes.dynamicType();
return _elementMap.getDartType(type);
diff --git a/tools/VERSION b/tools/VERSION
index 1145bf5..890a9f6 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 19
PATCH 0
-PRERELEASE 61
+PRERELEASE 62
PRERELEASE_PATCH 0
\ No newline at end of file