Fix Dart 2 runtime errors in the front end
Fix all the Dart 2 runtime errors revealed by compiling dart2js, the front end itself, the front end tests. Change-Id: Ic6e6dd9f85db845b6a351ebbcfea9a6045843fc2 Reviewed-on: https://dart-review.googlesource.com/56322 Commit-Queue: Kevin Millikin <kmillikin@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
89514bd8cf
commit
2d46ebd6a5
@@ -178,13 +178,14 @@ class MiniAstBuilder extends StackListener {
|
||||
@override
|
||||
void endArguments(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("Arguments");
|
||||
push(popList(count));
|
||||
push(popList(count, new List<dynamic>.filled(count, null, growable: true)));
|
||||
}
|
||||
|
||||
@override
|
||||
void endClassBody(int memberCount, Token beginToken, Token endToken) {
|
||||
debugEvent("ClassBody");
|
||||
push(popList(memberCount));
|
||||
push(popList(memberCount,
|
||||
new List<dynamic>.filled(memberCount, null, growable: true)));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -229,7 +230,9 @@ class MiniAstBuilder extends StackListener {
|
||||
|
||||
void endEnum(Token enumKeyword, Token leftBrace, int count) {
|
||||
debugEvent("Enum");
|
||||
List<EnumConstantDeclaration> constants = popList(count);
|
||||
List<EnumConstantDeclaration> constants =
|
||||
new List.filled(count, null, growable: true);
|
||||
popList(count, constants);
|
||||
String name = pop();
|
||||
List<Annotation> metadata = pop();
|
||||
Comment comment = pop();
|
||||
@@ -273,7 +276,7 @@ class MiniAstBuilder extends StackListener {
|
||||
@override
|
||||
void handleIdentifierList(int count) {
|
||||
debugEvent("IdentifierList");
|
||||
push(popList(count));
|
||||
push(popList(count, new List<dynamic>.filled(count, null, growable: true)));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -345,7 +348,9 @@ class MiniAstBuilder extends StackListener {
|
||||
@override
|
||||
void endMetadataStar(int count) {
|
||||
debugEvent("MetadataStar");
|
||||
push(popList(count) ?? NullValue.Metadata);
|
||||
push(
|
||||
popList(count, new List<dynamic>.filled(count, null, growable: true)) ??
|
||||
NullValue.Metadata);
|
||||
}
|
||||
|
||||
void endMethod(
|
||||
@@ -384,7 +389,8 @@ class MiniAstBuilder extends StackListener {
|
||||
// We ignore top level variable declarations; they are present just to make
|
||||
// the IDL analyze without warnings.
|
||||
debugEvent("TopLevelFields");
|
||||
popList(count); // Fields
|
||||
popList(
|
||||
count, new List<dynamic>.filled(count, null, growable: true)); // Fields
|
||||
pop(); // Type
|
||||
pop(); // Metadata
|
||||
pop(); // Comment
|
||||
@@ -393,7 +399,7 @@ class MiniAstBuilder extends StackListener {
|
||||
@override
|
||||
void endTypeArguments(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("TypeArguments");
|
||||
push(popList(count));
|
||||
push(popList(count, new List<dynamic>.filled(count, null, growable: true)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -164,9 +164,10 @@ class LibrariesSpecification {
|
||||
}
|
||||
|
||||
var uri = checkAndResolve(data['uri']);
|
||||
var patches;
|
||||
List<Uri> patches;
|
||||
if (data['patches'] is List) {
|
||||
patches = data['patches'].map(baseUri.resolve).toList();
|
||||
patches =
|
||||
data['patches'].map<Uri>((s) => baseUri.resolve(s)).toList();
|
||||
} else if (data['patches'] is String) {
|
||||
patches = [checkAndResolve(data['patches'])];
|
||||
} else if (data['patches'] == null) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import 'builder.dart'
|
||||
show
|
||||
Builder,
|
||||
ClassBuilder,
|
||||
DynamicTypeBuilder,
|
||||
ModifierBuilder,
|
||||
PrefixBuilder,
|
||||
Scope,
|
||||
@@ -181,12 +180,7 @@ abstract class LibraryBuilder<T extends TypeBuilder, R>
|
||||
return 0;
|
||||
}
|
||||
|
||||
void becomeCoreLibrary(dynamicType) {
|
||||
if (scope.local["dynamic"] == null) {
|
||||
addBuilder("dynamic",
|
||||
new DynamicTypeBuilder<T, dynamic>(dynamicType, this, -1), -1);
|
||||
}
|
||||
}
|
||||
void becomeCoreLibrary(dynamicType);
|
||||
|
||||
void forEach(void f(String name, Builder builder)) {
|
||||
scope.forEach((String name, Builder builder) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'dart:convert' show jsonDecode;
|
||||
import 'package:kernel/ast.dart'
|
||||
show
|
||||
Class,
|
||||
DartType,
|
||||
Field,
|
||||
Library,
|
||||
ListLiteral,
|
||||
@@ -25,6 +26,7 @@ import '../problems.dart' show internalProblem, unhandled, unimplemented;
|
||||
import '../kernel/kernel_builder.dart'
|
||||
show
|
||||
Builder,
|
||||
DynamicTypeBuilder,
|
||||
InvalidTypeBuilder,
|
||||
KernelInvalidTypeBuilder,
|
||||
KernelTypeBuilder,
|
||||
@@ -65,6 +67,16 @@ class DillLibraryBuilder extends LibraryBuilder<KernelTypeBuilder, Library> {
|
||||
@override
|
||||
Library get target => library;
|
||||
|
||||
void becomeCoreLibrary(dynamicType) {
|
||||
if (scope.local["dynamic"] == null) {
|
||||
addBuilder(
|
||||
"dynamic",
|
||||
new DynamicTypeBuilder<KernelTypeBuilder, DartType>(
|
||||
dynamicType, this, -1),
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
||||
void addClass(Class cls) {
|
||||
DillClassBuilder classBulder = new DillClassBuilder(cls, this);
|
||||
addBuilder(cls.name, classBulder, cls.fileOffset);
|
||||
|
||||
@@ -445,7 +445,9 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
@override
|
||||
void endMetadataStar(int count) {
|
||||
debugEvent("MetadataStar");
|
||||
push(popList(count) ?? NullValue.Metadata);
|
||||
push(popList(
|
||||
count, new List<Expression>.filled(count, null, growable: true)) ??
|
||||
NullValue.Metadata);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -822,7 +824,9 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
@override
|
||||
void endArguments(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("Arguments");
|
||||
List arguments = popList(count) ?? <Expression>[];
|
||||
List<dynamic> arguments =
|
||||
new List<dynamic>.filled(count, null, growable: true);
|
||||
popList(count, arguments);
|
||||
int firstNamedArgumentIndex = arguments.length;
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
var node = arguments[i];
|
||||
@@ -877,7 +881,9 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
}
|
||||
push(forest.arguments(positional, beginToken, named: named));
|
||||
} else {
|
||||
push(forest.arguments(arguments, beginToken));
|
||||
// TODO(kmillikin): Find a way to avoid allocating a second list in the
|
||||
// case where there were no named arguments, which is a common one.
|
||||
push(forest.arguments(new List<Expression>.from(arguments), beginToken));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1510,7 +1516,9 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
String value = unescapeString(token.lexeme);
|
||||
push(forest.literalString(value, token));
|
||||
} else {
|
||||
List parts = popList(1 + interpolationCount * 2);
|
||||
var count = 1 + interpolationCount * 2;
|
||||
List<Object> parts =
|
||||
popList(count, new List<Object>.filled(count, null, growable: true));
|
||||
Token first = parts.first;
|
||||
Token last = parts.last;
|
||||
Quote quote = analyzeQuote(first.lexeme);
|
||||
@@ -2251,7 +2259,10 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
FormalParameterKind kind = optional("{", beginToken)
|
||||
? FormalParameterKind.optionalNamed
|
||||
: FormalParameterKind.optionalPositional;
|
||||
push(new OptionalFormals(kind, popList(count) ?? []));
|
||||
var variables =
|
||||
new List<VariableDeclaration>.filled(count, null, growable: true);
|
||||
popList(count, variables);
|
||||
push(new OptionalFormals(kind, variables));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -2389,7 +2400,8 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
@override
|
||||
void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) {
|
||||
Statement finallyBlock = popStatementIfNotNull(finallyKeyword);
|
||||
Object catches = popList(catchCount);
|
||||
Object catches = popList(
|
||||
catchCount, new List<Catch>.filled(catchCount, null, growable: true));
|
||||
Statement tryBlock = popStatement();
|
||||
if (compileTimeErrorInTry == null) {
|
||||
push(forest.tryStatement(
|
||||
@@ -2910,7 +2922,8 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
@override
|
||||
void endTypeArguments(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("TypeArguments");
|
||||
push(popList(count));
|
||||
push(
|
||||
popList(count, new List<DartType>.filled(count, null, growable: true)));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -3372,7 +3385,9 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
@override
|
||||
void beginSwitchCase(int labelCount, int expressionCount, Token firstToken) {
|
||||
debugEvent("beginSwitchCase");
|
||||
List labelsAndExpressions = popList(labelCount + expressionCount);
|
||||
var count = labelCount + expressionCount;
|
||||
List<Object> labelsAndExpressions =
|
||||
popList(count, new List<Object>.filled(count, null, growable: true));
|
||||
List<Object> labels = <Object>[];
|
||||
List<Expression> expressions = <Expression>[];
|
||||
if (labelsAndExpressions != null) {
|
||||
@@ -3656,7 +3671,10 @@ abstract class BodyBuilder<Expression, Statement, Arguments>
|
||||
@override
|
||||
void endTypeVariables(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("TypeVariables");
|
||||
List<KernelTypeVariableBuilder> typeVariables = popList(count);
|
||||
List<KernelTypeVariableBuilder> typeVariables = popList(
|
||||
count,
|
||||
new List<KernelTypeVariableBuilder>.filled(count, null,
|
||||
growable: true));
|
||||
if (typeVariables != null) {
|
||||
if (library.loader.target.strongMode) {
|
||||
List<KernelTypeBuilder> calculatedBounds = calculateBounds(
|
||||
|
||||
@@ -53,6 +53,7 @@ import 'kernel_builder.dart'
|
||||
BuiltinTypeBuilder,
|
||||
ClassBuilder,
|
||||
ConstructorReferenceBuilder,
|
||||
DynamicTypeBuilder,
|
||||
FormalParameterBuilder,
|
||||
InvalidTypeBuilder,
|
||||
KernelClassBuilder,
|
||||
@@ -125,6 +126,16 @@ class KernelLibraryBuilder
|
||||
|
||||
Uri get uri => library.importUri;
|
||||
|
||||
void becomeCoreLibrary(dynamicType) {
|
||||
if (scope.local["dynamic"] == null) {
|
||||
addBuilder(
|
||||
"dynamic",
|
||||
new DynamicTypeBuilder<KernelTypeBuilder, DartType>(
|
||||
dynamicType, this, -1),
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
||||
KernelTypeBuilder addNamedType(
|
||||
Object name, List<KernelTypeBuilder> arguments, int charOffset) {
|
||||
return addType(new KernelNamedTypeBuilder(name, arguments), charOffset);
|
||||
@@ -138,7 +149,8 @@ class KernelLibraryBuilder
|
||||
|
||||
KernelTypeBuilder addVoidType(int charOffset) {
|
||||
return addNamedType("void", null, charOffset)
|
||||
..bind(new VoidTypeBuilder(const VoidType(), this, charOffset));
|
||||
..bind(new VoidTypeBuilder<KernelTypeBuilder, VoidType>(
|
||||
const VoidType(), this, charOffset));
|
||||
}
|
||||
|
||||
void addClass(
|
||||
@@ -976,7 +988,8 @@ class KernelLibraryBuilder
|
||||
boundlessTypeVariables.add(newVariable);
|
||||
}
|
||||
for (TypeBuilder newType in newTypes) {
|
||||
declaration.addType(new UnresolvedType(newType, -1, null));
|
||||
declaration
|
||||
.addType(new UnresolvedType<KernelTypeBuilder>(newType, -1, null));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,9 @@ class DietListener extends StackListener {
|
||||
@override
|
||||
void endMetadataStar(int count) {
|
||||
debugEvent("MetadataStar");
|
||||
push(popList(count)?.first ?? NullValue.Metadata);
|
||||
push(popList(count, new List<Token>.filled(count, null, growable: true))
|
||||
?.first ??
|
||||
NullValue.Metadata);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -574,7 +576,8 @@ class DietListener extends StackListener {
|
||||
}
|
||||
|
||||
void buildFields(int count, Token token, bool isTopLevel) {
|
||||
List<String> names = popList(count);
|
||||
List<String> names =
|
||||
popList(count, new List<String>.filled(count, null, growable: true));
|
||||
Builder builder = lookupBuilder(token, null, names.first);
|
||||
Token metadata = pop();
|
||||
// TODO(paulberry): don't re-parse the field if we've already parsed it
|
||||
|
||||
@@ -10,6 +10,8 @@ import '../../scanner/token.dart' show Token;
|
||||
|
||||
import '../builder/builder.dart';
|
||||
|
||||
import '../builder/metadata_builder.dart' show ExpressionMetadataBuilder;
|
||||
|
||||
import '../combinator.dart' show Combinator;
|
||||
|
||||
import '../fasta_codes.dart'
|
||||
@@ -66,6 +68,13 @@ import 'stack_listener.dart' show NullValue, StackListener;
|
||||
|
||||
import '../configuration.dart' show Configuration;
|
||||
|
||||
import '../kernel/kernel_builder.dart'
|
||||
show
|
||||
KernelFormalParameterBuilder,
|
||||
KernelNamedTypeBuilder,
|
||||
KernelTypeBuilder,
|
||||
KernelTypeVariableBuilder;
|
||||
|
||||
enum MethodBody {
|
||||
Abstract,
|
||||
Regular,
|
||||
@@ -129,7 +138,11 @@ class OutlineBuilder extends StackListener {
|
||||
@override
|
||||
void endMetadataStar(int count) {
|
||||
debugEvent("MetadataStar");
|
||||
push(popList(count) ?? NullValue.Metadata);
|
||||
push(popList(
|
||||
count,
|
||||
new List<ExpressionMetadataBuilder<TypeBuilder>>.filled(count, null,
|
||||
growable: true)) ??
|
||||
NullValue.Metadata);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -155,7 +168,9 @@ class OutlineBuilder extends StackListener {
|
||||
@override
|
||||
void endCombinators(int count) {
|
||||
debugEvent("Combinators");
|
||||
push(popList(count) ?? NullValue.Combinators);
|
||||
push(popList(
|
||||
count, new List<Combinator>.filled(count, null, growable: true)) ??
|
||||
NullValue.Combinators);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -202,7 +217,9 @@ class OutlineBuilder extends StackListener {
|
||||
@override
|
||||
void endConditionalUris(int count) {
|
||||
debugEvent("EndConditionalUris");
|
||||
push(popList(count) ?? NullValue.ConditionalUris);
|
||||
push(popList(count,
|
||||
new List<Configuration>.filled(count, null, growable: true)) ??
|
||||
NullValue.ConditionalUris);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -388,7 +405,11 @@ class OutlineBuilder extends StackListener {
|
||||
@override
|
||||
void handleClassImplements(Token implementsKeyword, int interfacesCount) {
|
||||
debugEvent("handleClassImplements");
|
||||
push(popList(interfacesCount) ?? NullValue.TypeBuilderList);
|
||||
push(popList(
|
||||
interfacesCount,
|
||||
new List<KernelNamedTypeBuilder>.filled(interfacesCount, null,
|
||||
growable: true)) ??
|
||||
NullValue.TypeBuilderList);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -730,7 +751,9 @@ class OutlineBuilder extends StackListener {
|
||||
@override
|
||||
void endTypeArguments(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("TypeArguments");
|
||||
push(popList(count) ?? NullValue.TypeArguments);
|
||||
push(popList(count,
|
||||
new List<KernelTypeBuilder>.filled(count, null, growable: true)) ??
|
||||
NullValue.TypeArguments);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -750,13 +773,21 @@ class OutlineBuilder extends StackListener {
|
||||
@override
|
||||
void endTypeList(int count) {
|
||||
debugEvent("TypeList");
|
||||
push(popList(count) ?? NullValue.TypeList);
|
||||
push(popList(
|
||||
count,
|
||||
new List<KernelNamedTypeBuilder>.filled(count, null,
|
||||
growable: true)) ??
|
||||
NullValue.TypeList);
|
||||
}
|
||||
|
||||
@override
|
||||
void endTypeVariables(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("TypeVariables");
|
||||
push(popList(count) ?? NullValue.TypeVariables);
|
||||
push(popList(
|
||||
count,
|
||||
new List<KernelTypeVariableBuilder>.filled(count, null,
|
||||
growable: true)) ??
|
||||
NullValue.TypeVariables);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -819,7 +850,9 @@ class OutlineBuilder extends StackListener {
|
||||
// 0. It might be simpler if the parser didn't call this method in that
|
||||
// case, however, then [beginOptionalFormalParameters] wouldn't always be
|
||||
// matched by this method.
|
||||
List parameters = popList(count) ?? [];
|
||||
var parameters = new List<KernelFormalParameterBuilder>.filled(count, null,
|
||||
growable: true);
|
||||
popList(count, parameters);
|
||||
for (FormalParameterBuilder parameter in parameters) {
|
||||
parameter.kind = kind;
|
||||
}
|
||||
@@ -910,7 +943,8 @@ class OutlineBuilder extends StackListener {
|
||||
@override
|
||||
void endEnum(Token enumKeyword, Token leftBrace, int count) {
|
||||
String documentationComment = getDocumentationComment(enumKeyword);
|
||||
List constantNamesAndOffsets = popList(count * 3);
|
||||
List<Object> constantNamesAndOffsets = popList(
|
||||
count * 3, new List<Object>.filled(count * 3, null, growable: true));
|
||||
int charOffset = pop();
|
||||
String name = pop();
|
||||
List<MetadataBuilder> metadata = pop();
|
||||
@@ -1007,7 +1041,8 @@ class OutlineBuilder extends StackListener {
|
||||
void endTopLevelFields(Token staticToken, Token covariantToken,
|
||||
Token varFinalOrConst, int count, Token beginToken, Token endToken) {
|
||||
debugEvent("endTopLevelFields");
|
||||
List fieldsInfo = popList(count * 4);
|
||||
List<Object> fieldsInfo = popList(
|
||||
count * 4, new List<Object>.filled(count * 4, null, growable: true));
|
||||
TypeBuilder type = pop();
|
||||
int modifiers = (staticToken != null ? staticMask : 0) |
|
||||
(covariantToken != null ? covariantMask : 0) |
|
||||
@@ -1023,7 +1058,8 @@ class OutlineBuilder extends StackListener {
|
||||
void endFields(Token staticToken, Token covariantToken, Token varFinalOrConst,
|
||||
int count, Token beginToken, Token endToken) {
|
||||
debugEvent("Fields");
|
||||
List fieldsInfo = popList(count * 4);
|
||||
List<Object> fieldsInfo = popList(
|
||||
count * 4, new List<Object>.filled(count * 4, null, growable: true));
|
||||
TypeBuilder type = pop();
|
||||
int modifiers = (staticToken != null ? staticMask : 0) |
|
||||
(covariantToken != null ? covariantMask : 0) |
|
||||
|
||||
@@ -121,7 +121,7 @@ abstract class StackListener extends Listener {
|
||||
return value == null ? null : pop();
|
||||
}
|
||||
|
||||
List popList(int n, [List list]) {
|
||||
List popList(int n, List list) {
|
||||
if (n == 0) return null;
|
||||
return stack.popList(n, list);
|
||||
}
|
||||
@@ -314,7 +314,9 @@ abstract class StackListener extends Listener {
|
||||
@override
|
||||
void handleStringJuxtaposition(int literalCount) {
|
||||
debugEvent("StringJuxtaposition");
|
||||
push(popList(literalCount).join(""));
|
||||
push(popList(literalCount,
|
||||
new List<Expression>.filled(literalCount, null, growable: true))
|
||||
.join(""));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -396,16 +398,15 @@ class Stack {
|
||||
final table = array;
|
||||
final length = arrayLength;
|
||||
|
||||
final tailList = list ?? new List.filled(count, null, growable: true);
|
||||
final startIndex = length - count;
|
||||
for (int i = 0; i < count; i++) {
|
||||
final value = table[startIndex + i];
|
||||
tailList[i] = value is NullValue ? null : value;
|
||||
list[i] = value is NullValue ? null : value;
|
||||
table[startIndex + i] = null;
|
||||
}
|
||||
arrayLength -= count;
|
||||
|
||||
return tailList;
|
||||
return list;
|
||||
}
|
||||
|
||||
List get values {
|
||||
|
||||
@@ -58,7 +58,8 @@ class AnalyzerDietListener extends DietListener {
|
||||
|
||||
@override
|
||||
void buildFields(int count, Token token, bool isTopLevel) {
|
||||
List<String> names = popList(count);
|
||||
List<String> names =
|
||||
popList(count, new List<String>.filled(count, null, growable: true));
|
||||
Builder builder = lookupBuilder(token, null, names.first);
|
||||
Token metadata = pop();
|
||||
AstBuilder listener =
|
||||
|
||||
@@ -247,7 +247,7 @@ class Run extends Step<Uri, int, FastaContext> {
|
||||
File generated = new File.fromUri(uri);
|
||||
StdioProcess process;
|
||||
try {
|
||||
var args = [];
|
||||
var args = <String>[];
|
||||
if (context.strongMode) {
|
||||
args.add('--strong');
|
||||
args.add('--reify-generic-functions');
|
||||
|
||||
@@ -52,7 +52,7 @@ class CloneVisitor implements TreeVisitor {
|
||||
return _activeFileUri == null ? TreeNode.noOffset : fileOffset;
|
||||
}
|
||||
|
||||
TreeNode clone(TreeNode node) {
|
||||
T clone<T extends TreeNode>(T node) {
|
||||
final Uri activeFileUriSaved = _activeFileUri;
|
||||
if (node is FileUriNode) _activeFileUri = node.fileUri ?? _activeFileUri;
|
||||
final TreeNode result = node.accept(this)
|
||||
|
||||
@@ -46,18 +46,23 @@ class Analyze extends Suite {
|
||||
String optionsPath = json["options"];
|
||||
Uri optionsUri = optionsPath == null ? null : base.resolve(optionsPath);
|
||||
|
||||
List<Uri> uris = new List<Uri>.from(
|
||||
json["uris"].map((String relative) => base.resolve(relative)));
|
||||
List<Uri> uris = json["uris"].map<Uri>((relative) {
|
||||
String r = relative;
|
||||
return base.resolve(r);
|
||||
}).toList();
|
||||
|
||||
List<RegExp> exclude =
|
||||
new List<RegExp>.from(json["exclude"].map((String p) => new RegExp(p)));
|
||||
json["exclude"].map<RegExp>((p) => new RegExp(p)).toList();
|
||||
|
||||
Map gitGrep = json["git grep"];
|
||||
List<String> gitGrepPathspecs;
|
||||
List<String> gitGrepPatterns;
|
||||
if (gitGrep != null) {
|
||||
gitGrepPathspecs = gitGrep["pathspecs"] ?? const <String>["."];
|
||||
gitGrepPatterns = gitGrep["patterns"];
|
||||
gitGrepPathspecs = gitGrep["pathspecs"] == null
|
||||
? const <String>["."]
|
||||
: new List<String>.from(gitGrep["pathspecs"]);
|
||||
if (gitGrep["patterns"] != null)
|
||||
gitGrepPatterns = new List<String>.from(gitGrep["patterns"]);
|
||||
}
|
||||
|
||||
return new Analyze(
|
||||
|
||||
@@ -63,9 +63,9 @@ class Chain extends Suite {
|
||||
Uri uri = base.resolve(path);
|
||||
Uri statusFile = base.resolve(json["status"]);
|
||||
List<RegExp> pattern =
|
||||
new List<RegExp>.from(json["pattern"].map((String p) => new RegExp(p)));
|
||||
json["pattern"].map<RegExp>((p) => new RegExp(p)).toList();
|
||||
List<RegExp> exclude =
|
||||
new List<RegExp>.from(json["exclude"].map((String p) => new RegExp(p)));
|
||||
json["exclude"].map<RegExp>((p) => new RegExp(p)).toList();
|
||||
bool processMultitests = json["process-multitests"] ?? false;
|
||||
return new Chain(name, kind, source, uri, statusFile, pattern, exclude,
|
||||
processMultitests);
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'dart:io' show exitCode, stderr;
|
||||
|
||||
import 'dart:isolate' show ReceivePort;
|
||||
|
||||
Future withErrorHandling(Future f()) async {
|
||||
Future<T> withErrorHandling<T>(Future<T> f()) async {
|
||||
final ReceivePort port = new ReceivePort();
|
||||
try {
|
||||
return await f();
|
||||
@@ -20,6 +20,7 @@ Future withErrorHandling(Future f()) async {
|
||||
if (trace != null) {
|
||||
stderr.writeln(trace);
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
port.close();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class ExpectationSet {
|
||||
|
||||
const ExpectationSet(this.internalMap);
|
||||
|
||||
operator [](String name) {
|
||||
Expectation operator [](String name) {
|
||||
return internalMap[name.toLowerCase()] ??
|
||||
(throw "No expectation named: '$name'.");
|
||||
}
|
||||
|
||||
@@ -206,8 +206,10 @@ ${imports.toString().trim()}
|
||||
|
||||
Future<Null> main() async {
|
||||
if ($isVerbose) enableVerboseOutput();
|
||||
Map<String, String> environment = json.decode('${json.encode(environment)}');
|
||||
Set<String> selectors = json.decode('${json.encode(selectors)}').toSet();
|
||||
Map<String, String> environment =
|
||||
new Map<String, String>.from(json.decode('${json.encode(environment)}'));
|
||||
Set<String> selectors =
|
||||
new Set<String>.from(json.decode('${json.encode(selectors)}'));
|
||||
await runTests(<String, Function> {
|
||||
${splitLines(dart.toString().trim()).join(' ')}
|
||||
});
|
||||
|
||||
@@ -39,11 +39,11 @@ class CommandLine {
|
||||
Set<String> get skip => commaSeparated("--skip=");
|
||||
|
||||
Set<String> commaSeparated(String prefix) {
|
||||
return options.expand((String s) {
|
||||
return new Set<String>.from(options.expand((String s) {
|
||||
if (!s.startsWith(prefix)) return const [];
|
||||
s = s.substring(prefix.length);
|
||||
return s.split(",");
|
||||
}).toSet();
|
||||
}));
|
||||
}
|
||||
|
||||
Map<String, String> get environment {
|
||||
@@ -167,8 +167,8 @@ main(List<String> arguments) => withErrorHandling(() async {
|
||||
print("Running tests took: ${sw.elapsed}.");
|
||||
});
|
||||
|
||||
Future<Null> runTests(Map<String, Function> tests) =>
|
||||
withErrorHandling(() async {
|
||||
Future<void> runTests(Map<String, Function> tests) =>
|
||||
withErrorHandling<void>(() async {
|
||||
int completed = 0;
|
||||
for (String name in tests.keys) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
@@ -29,7 +29,9 @@ class TestDart extends Suite {
|
||||
factory TestDart.fromJsonMap(Uri base, Map json, String name, String kind) {
|
||||
String common = json["common"] ?? "";
|
||||
String processes = json["processes"] ?? "-j${Platform.numberOfProcessors}";
|
||||
List<String> commandLines = json["command-lines"] ?? <String>[];
|
||||
List<String> commandLines = json["command-lines"] == null
|
||||
? new List<String>.from(json["command-lines"])
|
||||
: <String>[];
|
||||
return new TestDart(name, common, processes, commandLines);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class Section {
|
||||
Section(this.statusFile, this.condition, this.lineNumber)
|
||||
: testRules = new List<TestRule>();
|
||||
|
||||
bool isEnabled(environment) =>
|
||||
bool isEnabled(Map<String, String> environment) =>
|
||||
condition == null || condition.evaluate(environment);
|
||||
|
||||
String toString() {
|
||||
@@ -48,15 +48,15 @@ class Section {
|
||||
}
|
||||
|
||||
Future<TestExpectations> ReadTestExpectations(List<String> statusFilePaths,
|
||||
Map environment, ExpectationSet expectationSet) {
|
||||
Map<String, String> environment, ExpectationSet expectationSet) {
|
||||
var testExpectations = new TestExpectations(expectationSet);
|
||||
return Future.wait(statusFilePaths.map((String statusFile) {
|
||||
return ReadTestExpectationsInto(testExpectations, statusFile, environment);
|
||||
})).then((_) => testExpectations);
|
||||
}
|
||||
|
||||
Future ReadTestExpectationsInto(
|
||||
TestExpectations expectations, String statusFilePath, environment) {
|
||||
Future<void> ReadTestExpectationsInto(TestExpectations expectations,
|
||||
String statusFilePath, Map<String, String> environment) {
|
||||
var completer = new Completer();
|
||||
List<Section> sections = new List<Section>();
|
||||
|
||||
@@ -75,7 +75,7 @@ Future ReadTestExpectationsInto(
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
void ReadConfigurationInto(Path path, sections, onDone) {
|
||||
void ReadConfigurationInto(Path path, List<Section> sections, void onDone()) {
|
||||
StatusFile statusFile = new StatusFile(path);
|
||||
File file = new File(path.toNativePath());
|
||||
if (!file.existsSync()) {
|
||||
@@ -152,25 +152,25 @@ class TestExpectations {
|
||||
// Only create one copy of each Set<Expectation>.
|
||||
// We just use .toString as a key, so we may make a few
|
||||
// sets that only differ in their toString element order.
|
||||
static Map _cachedSets = new Map();
|
||||
static Map<String, Set<Expectation>> _cachedSets = {};
|
||||
|
||||
final ExpectationSet expectationSet;
|
||||
|
||||
Map _map;
|
||||
Map<String, Set<Expectation>> _map;
|
||||
bool _preprocessed = false;
|
||||
Map _regExpCache;
|
||||
Map _keyToRegExps;
|
||||
Map<String, RegExp> _regExpCache;
|
||||
Map<String, List<RegExp>> _keyToRegExps;
|
||||
|
||||
/**
|
||||
* Create a TestExpectations object. See the [expectations] method
|
||||
* for an explanation of matching.
|
||||
*/
|
||||
TestExpectations(this.expectationSet) : _map = new Map();
|
||||
TestExpectations(this.expectationSet) : _map = {};
|
||||
|
||||
/**
|
||||
* Add a rule to the expectations.
|
||||
*/
|
||||
void addRule(testRule, environment) {
|
||||
void addRule(TestRule testRule, Map<String, String> environment) {
|
||||
// Once we have started using the expectations we cannot add more
|
||||
// rules.
|
||||
if (_preprocessed) {
|
||||
@@ -193,7 +193,7 @@ class TestExpectations {
|
||||
* "^$keyComponent\$" matches the corresponding filename component.
|
||||
*/
|
||||
Set<Expectation> expectations(String filename) {
|
||||
var result = new Set();
|
||||
var result = new Set<Expectation>();
|
||||
var splitFilename = filename.split('/');
|
||||
|
||||
// Create mapping from keys to list of RegExps once and for all.
|
||||
@@ -224,13 +224,13 @@ class TestExpectations {
|
||||
void _preprocessForMatching() {
|
||||
if (_preprocessed) return;
|
||||
|
||||
_keyToRegExps = new Map();
|
||||
_regExpCache = new Map();
|
||||
_keyToRegExps = {};
|
||||
_regExpCache = {};
|
||||
|
||||
_map.forEach((key, expectations) {
|
||||
if (_keyToRegExps[key] != null) return;
|
||||
var splitKey = key.split('/');
|
||||
var regExps = new List(splitKey.length);
|
||||
var regExps = new List<RegExp>(splitKey.length);
|
||||
for (var i = 0; i < splitKey.length; i++) {
|
||||
var component = splitKey[i];
|
||||
var regExp = _regExpCache[component];
|
||||
|
||||
@@ -75,8 +75,9 @@ class TestRoot {
|
||||
|
||||
Uri packages = uri.resolve(data["packages"]);
|
||||
|
||||
List<Suite> suites = new List<Suite>.from(
|
||||
data["suites"].map((Map json) => new Suite.fromJsonMap(uri, json)));
|
||||
List<Suite> suites = data["suites"]
|
||||
.map<Suite>((json) => new Suite.fromJsonMap(uri, json))
|
||||
.toList();
|
||||
|
||||
Analyze analyze = await Analyze.fromJsonMap(uri, data["analyze"], suites);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user