Clean up Forest.literalList and Forest.literalMap
Change-Id: Iba64ae132a98297466962f0ed8e4bfbe8535611b
Reviewed-on: https://dart-review.googlesource.com/54161
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/fasta/ast_building_factory.dart b/pkg/analyzer/lib/src/fasta/ast_building_factory.dart
index 44c005f..96318e4 100644
--- a/pkg/analyzer/lib/src/fasta/ast_building_factory.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_building_factory.dart
@@ -116,8 +116,7 @@
Object typeArguments,
Token leftBracket,
List<Expression> expressions,
- Token rightBracket,
- Token location) =>
+ Token rightBracket) =>
astFactory.listLiteral(
constKeyword, typeArguments, leftBracket, expressions, rightBracket);
@@ -130,8 +129,7 @@
Object typeArguments,
Token leftBracket,
covariant List entries,
- Token rightBracket,
- Token location) =>
+ Token rightBracket) =>
astFactory.mapLiteral(
constKeyword, typeArguments, leftBracket, entries, rightBracket);
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 8273574..15c3a55 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -1857,10 +1857,9 @@
constKeyword != null || constantContext == ConstantContext.inferred,
typeArgument,
typeArguments,
- null,
+ beginToken,
expressions,
- endToken,
- constKeyword ?? beginToken));
+ endToken));
}
@override
@@ -1916,8 +1915,7 @@
typeArguments,
beginToken,
entries,
- endToken,
- constKeyword ?? beginToken));
+ endToken));
}
@override
diff --git a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
index fac7751..ff27e54 100644
--- a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
@@ -111,11 +111,12 @@
Object typeArguments,
Token leftBracket,
List<Expression> expressions,
- Token rightBracket,
- Token location) {
+ Token rightBracket) {
+ // TODO(brianwilkerson): The file offset computed below will not be correct
+ // if there are type arguments but no `const` keyword.
return new ShadowListLiteral(expressions,
typeArgument: typeArgument, isConst: isConst)
- ..fileOffset = offsetForToken(location);
+ ..fileOffset = offsetForToken(constKeyword ?? leftBracket);
}
@override
@@ -127,11 +128,12 @@
Object typeArguments,
Token leftBracket,
List<MapEntry> entries,
- Token rightBracket,
- Token token) {
+ Token rightBracket) {
+ // TODO(brianwilkerson): The file offset computed below will not be correct
+ // if there are type arguments but no `const` keyword.
return new ShadowMapLiteral(entries,
keyType: keyType, valueType: valueType, isConst: isConst)
- ..fileOffset = offsetForToken(token);
+ ..fileOffset = offsetForToken(constKeyword ?? leftBracket);
}
@override
diff --git a/pkg/front_end/lib/src/fasta/kernel/forest.dart b/pkg/front_end/lib/src/fasta/kernel/forest.dart
index 1a1b99c..ce11b4f 100644
--- a/pkg/front_end/lib/src/fasta/kernel/forest.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/forest.dart
@@ -50,8 +50,7 @@
/// preceding the list literal, or `null` if there are no type arguments. The
/// [leftBracket] is the location of the `[`. The list of [expressions] is a
/// list of the representations of the list elements. The [rightBracket] is
- /// the location of the `]`. The [location] is the location of the first token
- /// in the list literal.
+ /// the location of the `]`.
Expression literalList(
Location constKeyword,
bool isConst,
@@ -59,8 +58,7 @@
Object typeArguments,
Location leftBracket,
List<Expression> expressions,
- Location rightBracket,
- Location location);
+ Location rightBracket);
/// Return a representation of a map literal. The [constKeyword] is the
/// location of the `const` keyword, or `null` if there is no keyword. The
@@ -75,8 +73,7 @@
/// preceding the map literal, or `null` if there are no type arguments. The
/// [leftBracket] is the location of the `{`. The list of [entries] is a
/// list of the representations of the map entries. The [rightBracket] is
- /// the location of the `}`. The [location] is the location of the first token
- /// in the map literal.
+ /// the location of the `}`.
Expression literalMap(
Location constKeyword,
bool isConst,
@@ -85,8 +82,7 @@
Object typeArguments,
Location leftBracket,
covariant List entries,
- Location rightBracket,
- Location location);
+ Location rightBracket);
/// Return a representation of a null literal at the given [location].
Expression literalNull(Location location);