Use named formal parameters in InvalidConstant.
Change-Id: I417913d4c14161fca381466cc6d8b439375f5587 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415040 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
committed by
Commit Queue
parent
934b7b4c3a
commit
e4d9ea3843
File diff suppressed because it is too large
Load Diff
@@ -2410,12 +2410,12 @@ class IntState extends NumState {
|
||||
|
||||
/// An invalid constant that contains diagnostic information.
|
||||
class InvalidConstant implements Constant {
|
||||
/// The length of the entity that the evaluation error is reported at.
|
||||
final int length;
|
||||
|
||||
/// The offset of the entity that the evaluation error is reported at.
|
||||
final int offset;
|
||||
|
||||
/// The length of the entity that the evaluation error is reported at.
|
||||
final int length;
|
||||
|
||||
/// The error code that is being reported.
|
||||
final ErrorCode errorCode;
|
||||
|
||||
@@ -2448,11 +2448,13 @@ class InvalidConstant implements Constant {
|
||||
final bool isUnresolved;
|
||||
|
||||
/// Creates a duplicate instance of [other], with a different [entity].
|
||||
factory InvalidConstant.copyWithEntity(
|
||||
InvalidConstant other, SyntacticEntity entity) {
|
||||
factory InvalidConstant.copyWithEntity({
|
||||
required InvalidConstant other,
|
||||
required SyntacticEntity entity,
|
||||
}) {
|
||||
return InvalidConstant.forEntity(
|
||||
entity,
|
||||
other.errorCode,
|
||||
entity: entity,
|
||||
errorCode: other.errorCode,
|
||||
arguments: other.arguments,
|
||||
contextMessages: other.contextMessages,
|
||||
avoidReporting: other.avoidReporting,
|
||||
@@ -2462,16 +2464,18 @@ class InvalidConstant implements Constant {
|
||||
}
|
||||
|
||||
/// Creates a constant evaluation error associated with an [element].
|
||||
InvalidConstant.forElement(Element2 element, ErrorCode errorCode,
|
||||
{List<Object>? arguments,
|
||||
List<DiagnosticMessage>? contextMessages,
|
||||
bool avoidReporting = false,
|
||||
bool isUnresolved = false,
|
||||
bool isRuntimeException = false})
|
||||
: this._(
|
||||
element.name3!.length,
|
||||
element.firstFragment.nameOffset2 ?? -1,
|
||||
errorCode,
|
||||
InvalidConstant.forElement({
|
||||
required Element2 element,
|
||||
required ErrorCode errorCode,
|
||||
List<Object>? arguments,
|
||||
List<DiagnosticMessage>? contextMessages,
|
||||
bool avoidReporting = false,
|
||||
bool isUnresolved = false,
|
||||
bool isRuntimeException = false,
|
||||
}) : this._(
|
||||
length: element.name3!.length,
|
||||
offset: element.firstFragment.nameOffset2 ?? -1,
|
||||
errorCode: errorCode,
|
||||
arguments: arguments,
|
||||
contextMessages: contextMessages,
|
||||
avoidReporting: avoidReporting,
|
||||
@@ -2481,16 +2485,18 @@ class InvalidConstant implements Constant {
|
||||
|
||||
/// Creates a constant evaluation error associated with a token or node
|
||||
/// [entity].
|
||||
InvalidConstant.forEntity(SyntacticEntity entity, ErrorCode errorCode,
|
||||
{List<Object>? arguments,
|
||||
List<DiagnosticMessage>? contextMessages,
|
||||
bool avoidReporting = false,
|
||||
bool isUnresolved = false,
|
||||
bool isRuntimeException = false})
|
||||
: this._(
|
||||
entity.length,
|
||||
entity.offset,
|
||||
errorCode,
|
||||
InvalidConstant.forEntity({
|
||||
required SyntacticEntity entity,
|
||||
required ErrorCode errorCode,
|
||||
List<Object>? arguments,
|
||||
List<DiagnosticMessage>? contextMessages,
|
||||
bool avoidReporting = false,
|
||||
bool isUnresolved = false,
|
||||
bool isRuntimeException = false,
|
||||
}) : this._(
|
||||
offset: entity.offset,
|
||||
length: entity.length,
|
||||
errorCode: errorCode,
|
||||
arguments: arguments,
|
||||
contextMessages: contextMessages,
|
||||
avoidReporting: avoidReporting,
|
||||
@@ -2499,29 +2505,38 @@ class InvalidConstant implements Constant {
|
||||
);
|
||||
|
||||
/// Creates a generic error depending on the [node] provided.
|
||||
factory InvalidConstant.genericError(AstNode node,
|
||||
{bool isUnresolved = false}) {
|
||||
factory InvalidConstant.genericError({
|
||||
required AstNode node,
|
||||
bool isUnresolved = false,
|
||||
}) {
|
||||
var parent = node.parent;
|
||||
var parent2 = parent?.parent;
|
||||
if (parent is ArgumentList &&
|
||||
parent2 is InstanceCreationExpression &&
|
||||
parent2.isConst) {
|
||||
return InvalidConstant.forEntity(
|
||||
node, CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT,
|
||||
isUnresolved: isUnresolved);
|
||||
entity: node,
|
||||
errorCode: CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT,
|
||||
isUnresolved: isUnresolved,
|
||||
);
|
||||
}
|
||||
return InvalidConstant.forEntity(
|
||||
node, CompileTimeErrorCode.INVALID_CONSTANT,
|
||||
isUnresolved: isUnresolved);
|
||||
entity: node,
|
||||
errorCode: CompileTimeErrorCode.INVALID_CONSTANT,
|
||||
isUnresolved: isUnresolved,
|
||||
);
|
||||
}
|
||||
|
||||
InvalidConstant._(this.length, this.offset, this.errorCode,
|
||||
{List<Object>? arguments,
|
||||
List<DiagnosticMessage>? contextMessages,
|
||||
this.avoidReporting = false,
|
||||
this.isUnresolved = false,
|
||||
this.isRuntimeException = false})
|
||||
: arguments = arguments ?? [],
|
||||
InvalidConstant._({
|
||||
required this.offset,
|
||||
required this.length,
|
||||
required this.errorCode,
|
||||
List<Object>? arguments,
|
||||
List<DiagnosticMessage>? contextMessages,
|
||||
this.avoidReporting = false,
|
||||
this.isUnresolved = false,
|
||||
this.isRuntimeException = false,
|
||||
}) : arguments = arguments ?? [],
|
||||
contextMessages = contextMessages ?? [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user