From bf6aacaa7cbb4c26f1e3b3dcb63725a5dc7e4327 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 22 Aug 2017 13:10:58 -0700 Subject: [PATCH] Use non-comment generic method syntax (#676) Fixes #667 --- lib/src/frontend/expect_async.dart | 159 +++++++------------- lib/src/runner/browser/browser_manager.dart | 2 +- lib/src/runner/browser/chrome.dart | 2 +- lib/src/runner/browser/content_shell.dart | 2 +- lib/src/runner/browser/dartium.dart | 2 +- lib/src/runner/configuration.dart | 9 +- lib/src/runner/configuration/args.dart | 6 +- lib/src/runner/configuration/load.dart | 34 ++--- lib/src/runner/configuration/suite.dart | 6 +- lib/src/runner/parse_metadata.dart | 9 +- lib/src/utils.dart | 5 +- 11 files changed, 85 insertions(+), 151 deletions(-) diff --git a/lib/src/frontend/expect_async.dart b/lib/src/frontend/expect_async.dart index 52cb59701..9a37bdfa3 100644 --- a/lib/src/frontend/expect_async.dart +++ b/lib/src/frontend/expect_async.dart @@ -264,14 +264,13 @@ Function expectAsync(Function callback, /// This method takes callbacks with zero arguments. See also /// [expectAsync1], [expectAsync2], [expectAsync3], [expectAsync4], /// [expectAsync5], and [expectAsync6] for callbacks with different arity. -Func0 expectAsync0/**/(dynamic/*=T*/ callback(), +Func0 expectAsync0(T callback(), {int count: 1, int max: 0, String id, String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync0() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, count, max, - id: id, reason: reason) + return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .max0; } @@ -296,18 +295,13 @@ Func0 expectAsync0/**/(dynamic/*=T*/ callback(), /// This method takes callbacks with one argument. See also /// [expectAsync0], [expectAsync2], [expectAsync3], [expectAsync4], /// [expectAsync5], and [expectAsync6] for callbacks with different arity. -Func1 expectAsync1/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a), - {int count: 1, - int max: 0, - String id, - String reason}) { +Func1 expectAsync1(T callback(A a), + {int count: 1, int max: 0, String id, String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync1() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, count, max, - id: id, reason: reason) + return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .max1; } @@ -332,18 +326,13 @@ Func1 expectAsync1/**/( /// This method takes callbacks with two arguments. See also /// [expectAsync0], [expectAsync1], [expectAsync3], [expectAsync4], /// [expectAsync5], and [expectAsync6] for callbacks with different arity. -Func2 expectAsync2/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b), - {int count: 1, - int max: 0, - String id, - String reason}) { +Func2 expectAsync2(T callback(A a, B b), + {int count: 1, int max: 0, String id, String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync2() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, count, max, - id: id, reason: reason) + return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .max2; } @@ -368,20 +357,13 @@ Func2 expectAsync2/**/( /// This method takes callbacks with three arguments. See also /// [expectAsync0], [expectAsync1], [expectAsync2], [expectAsync4], /// [expectAsync5], and [expectAsync6] for callbacks with different arity. -Func3 - expectAsync3/**/( - dynamic/*=T*/ callback( - dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c), - {int count: 1, - int max: 0, - String id, - String reason}) { +Func3 expectAsync3(T callback(A a, B b, C c), + {int count: 1, int max: 0, String id, String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync3() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, count, max, - id: id, reason: reason) + return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .max3; } @@ -406,21 +388,13 @@ Func3 /// This method takes callbacks with four arguments. See also /// [expectAsync0], [expectAsync1], [expectAsync2], [expectAsync3], /// [expectAsync5], and [expectAsync6] for callbacks with different arity. -Func4 - expectAsync4/**/( - dynamic/*=T*/ callback( - dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c, dynamic/*=D*/ d), - {int count: 1, - int max: 0, - String id, - String reason}) { +Func4 expectAsync4(T callback(A a, B b, C c, D d), + {int count: 1, int max: 0, String id, String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync4() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, count, max, - id: id, reason: reason) + return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .max4; } @@ -445,21 +419,17 @@ Func4 - expectAsync5/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b, - dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e), - {int count: 1, - int max: 0, - String id, - String reason}) { +Func5 expectAsync5( + T callback(A a, B b, C c, D d, E e), + {int count: 1, + int max: 0, + String id, + String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync5() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, count, max, - id: id, reason: reason) + return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .max5; } @@ -484,21 +454,17 @@ Func5 - expectAsync6/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b, - dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e, dynamic/*=F*/ f), - {int count: 1, - int max: 0, - String id, - String reason}) { +Func6 expectAsync6( + T callback(A a, B b, C c, D d, E e, F f), + {int count: 1, + int max: 0, + String id, + String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync6() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, count, max, - id: id, reason: reason) + return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .max6; } @@ -536,15 +502,14 @@ Function expectAsyncUntil(Function callback, bool isDone(), /// [expectAsyncUntil1], [expectAsyncUntil2], [expectAsyncUntil3], /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for /// callbacks with different arity. -Func0 expectAsyncUntil0/**/( - dynamic/*=T*/ callback(), bool isDone(), +Func0 expectAsyncUntil0(T callback(), bool isDone(), {String id, String reason}) { if (Invoker.current == null) { throw new StateError( "expectAsyncUntil0() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, 0, -1, + return new _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone) .max0; } @@ -566,15 +531,14 @@ Func0 expectAsyncUntil0/**/( /// [expectAsyncUntil0], [expectAsyncUntil2], [expectAsyncUntil3], /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for /// callbacks with different arity. -Func1 expectAsyncUntil1/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a), bool isDone(), +Func1 expectAsyncUntil1(T callback(A a), bool isDone(), {String id, String reason}) { if (Invoker.current == null) { throw new StateError( "expectAsyncUntil1() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, 0, -1, + return new _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone) .max1; } @@ -596,16 +560,14 @@ Func1 expectAsyncUntil1/**/( /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil3], /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for /// callbacks with different arity. -Func2 - expectAsyncUntil2/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b), bool isDone(), - {String id, String reason}) { +Func2 expectAsyncUntil2(T callback(A a, B b), bool isDone(), + {String id, String reason}) { if (Invoker.current == null) { throw new StateError( "expectAsyncUntil2() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, 0, -1, + return new _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone) .max2; } @@ -627,19 +589,15 @@ Func2 /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil2], /// [expectAsyncUntil4], [expectAsyncUntil5], and [expectAsyncUntil6] for /// callbacks with different arity. -Func3 - expectAsyncUntil3/**/( - dynamic/*=T*/ callback( - dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c), - bool isDone(), - {String id, - String reason}) { +Func3 expectAsyncUntil3( + T callback(A a, B b, C c), bool isDone(), + {String id, String reason}) { if (Invoker.current == null) { throw new StateError( "expectAsyncUntil3() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, 0, -1, + return new _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone) .max3; } @@ -661,20 +619,15 @@ Func3 /// [expectAsyncUntil0], [expectAsyncUntil1], [expectAsyncUntil2], /// [expectAsyncUntil3], [expectAsyncUntil5], and [expectAsyncUntil6] for /// callbacks with different arity. -Func4 - expectAsyncUntil4/**/( - dynamic/*=T*/ callback( - dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c, dynamic/*=D*/ d), - bool isDone(), - {String id, - String reason}) { +Func4 expectAsyncUntil4( + T callback(A a, B b, C c, D d), bool isDone(), + {String id, String reason}) { if (Invoker.current == null) { throw new StateError( "expectAsyncUntil4() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, 0, -1, + return new _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone) .max4; } @@ -696,20 +649,15 @@ Func4 - expectAsyncUntil5/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b, - dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e), - bool isDone(), - {String id, - String reason}) { +Func5 expectAsyncUntil5( + T callback(A a, B b, C c, D d, E e), bool isDone(), + {String id, String reason}) { if (Invoker.current == null) { throw new StateError( "expectAsyncUntil5() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, 0, -1, + return new _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone) .max5; } @@ -731,20 +679,15 @@ Func5 - expectAsyncUntil6/**/( - dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b, - dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e, dynamic/*=F*/ f), - bool isDone(), - {String id, - String reason}) { +Func6 expectAsyncUntil6( + T callback(A a, B b, C c, D d, E e, F f), bool isDone(), + {String id, String reason}) { if (Invoker.current == null) { throw new StateError( "expectAsyncUntil() may only be called within a test."); } - return new _ExpectedFunction/**/(callback, 0, -1, + return new _ExpectedFunction(callback, 0, -1, id: id, reason: reason, isDone: isDone) .max6; } diff --git a/lib/src/runner/browser/browser_manager.dart b/lib/src/runner/browser/browser_manager.dart index 841b0b3b5..896672036 100644 --- a/lib/src/runner/browser/browser_manager.dart +++ b/lib/src/runner/browser/browser_manager.dart @@ -227,7 +227,7 @@ class BrowserManager { sink.close(); })); - return await _pool.withResource/*>*/(() async { + return await _pool.withResource>(() async { _channel.sink.add({ "command": "loadSuite", "url": url.toString(), diff --git a/lib/src/runner/browser/chrome.dart b/lib/src/runner/browser/chrome.dart index 7c984f17f..7c5f48173 100644 --- a/lib/src/runner/browser/chrome.dart +++ b/lib/src/runner/browser/chrome.dart @@ -70,7 +70,7 @@ class Chrome extends Browser { }; if (!debug) return tryPort(); - return getUnusedPort/*>*/(tryPort); + return getUnusedPort>(tryPort); }, remoteDebuggerCompleter.future); } diff --git a/lib/src/runner/browser/content_shell.dart b/lib/src/runner/browser/content_shell.dart index 0a7009a57..5599a8dd5 100644 --- a/lib/src/runner/browser/content_shell.dart +++ b/lib/src/runner/browser/content_shell.dart @@ -104,7 +104,7 @@ class ContentShell extends Browser { }; if (!debug) return tryPort(); - return getUnusedPort/*>*/(tryPort); + return getUnusedPort>(tryPort); }, observatoryCompleter.future, remoteDebuggerCompleter.future); } diff --git a/lib/src/runner/browser/dartium.dart b/lib/src/runner/browser/dartium.dart index 3e8235b97..aacf4140c 100644 --- a/lib/src/runner/browser/dartium.dart +++ b/lib/src/runner/browser/dartium.dart @@ -116,7 +116,7 @@ class Dartium extends Browser { }; if (!debug) return tryPort(); - return getUnusedPort/*>*/(tryPort); + return getUnusedPort>(tryPort); }, observatoryCompleter.future, remoteDebuggerCompleter.future); } diff --git a/lib/src/runner/configuration.dart b/lib/src/runner/configuration.dart index 06cc76cd7..e6a02b985 100644 --- a/lib/src/runner/configuration.dart +++ b/lib/src/runner/configuration.dart @@ -357,9 +357,9 @@ class Configuration { /// Returns an unmodifiable copy of [input]. /// /// If [input] is `null` or empty, this returns `null`. - static List/**/ _list/**/(Iterable/**/ input) { + static List _list(Iterable input) { if (input == null) return null; - var list = new List/**/ .unmodifiable(input); + var list = new List.unmodifiable(input); if (list.isEmpty) return null; return list; } @@ -373,7 +373,7 @@ class Configuration { } /// Returns an unmodifiable copy of [input] or an empty unmodifiable map. - static Map/**/ _map/**/(Map/**/ input) { + static Map _map(Map input) { if (input == null || input.isEmpty) return const {}; return new Map.unmodifiable(input); } @@ -382,8 +382,7 @@ class Configuration { /// /// This is zone-scoped, so [this] will be the current configuration in any /// asynchronous callbacks transitively created by [body]. - /*=T*/ asCurrent/**/(/*=T*/ body()) => - runZoned(body, zoneValues: {_currentKey: this}); + T asCurrent(T body()) => runZoned(body, zoneValues: {_currentKey: this}); /// Merges this with [other]. /// diff --git a/lib/src/runner/configuration/args.dart b/lib/src/runner/configuration/args.dart index 7427a238b..83b0b05f2 100644 --- a/lib/src/runner/configuration/args.dart +++ b/lib/src/runner/configuration/args.dart @@ -166,7 +166,7 @@ class _Parser { /// Returns the parsed configuration. Configuration parse() { var patterns = (_options['name'] as List) - .map/**/( + .map( (value) => _wrapFormatException('name', () => new RegExp(value))) .toList() ..addAll(_options['plain-name'] as List); @@ -239,7 +239,7 @@ class _Parser { /// Runs [parse] on the value of the option [name], and wraps any /// [FormatException] it throws with additional information. - /*=T*/ _parseOption/**/(String name, /*=T*/ parse(String value)) { + T _parseOption(String name, T parse(String value)) { if (!_options.wasParsed(name)) return null; var value = _options[name]; @@ -250,7 +250,7 @@ class _Parser { /// Runs [parse], and wraps any [FormatException] it throws with additional /// information. - /*=T*/ _wrapFormatException/**/(String name, /*=T*/ parse()) { + T _wrapFormatException(String name, T parse()) { try { return parse(); } on FormatException catch (error) { diff --git a/lib/src/runner/configuration/load.dart b/lib/src/runner/configuration/load.dart index 3a51edd57..1fdfc002b 100644 --- a/lib/src/runner/configuration/load.dart +++ b/lib/src/runner/configuration/load.dart @@ -125,7 +125,7 @@ class _ConfigurationLoader { chainStackTraces: chainStackTraces, foldTraceExcept: foldStackFrames["except"], foldTraceOnly: foldStackFrames["only"]) - .merge(_extractPresets/**/( + .merge(_extractPresets( onPlatform, (map) => new Configuration(onPlatform: map))); var osConfig = onOS[currentOS]; @@ -175,7 +175,7 @@ class _ConfigurationLoader { skipReason: skipReason, testOn: testOn, addTags: addTags) - .merge(_extractPresets/**/( + .merge(_extractPresets( tags, (map) => new Configuration(tags: map))); } @@ -364,9 +364,7 @@ class _ConfigurationLoader { /// contains. /// /// Returns a list of values returned by [forElement]. - List/**/ _getList/**/( - String field, - /*=T*/ forElement(YamlNode elementNode)) { + List _getList(String field, T forElement(YamlNode elementNode)) { var node = _getNode(field, "list", (value) => value is List) as YamlList; if (node == null) return []; return node.nodes.map(forElement).toList(); @@ -376,9 +374,8 @@ class _ConfigurationLoader { /// /// Returns a map with the keys and values returned by [key] and [value]. Each /// of these defaults to asserting that the value is a string. - Map/**/ _getMap/**/(String field, - {/*=K*/ key(YamlNode keyNode), - /*=V*/ value(YamlNode valueNode)}) { + Map _getMap(String field, + {K key(YamlNode keyNode), V value(YamlNode valueNode)}) { var node = _getNode(field, "map", (value) => value is Map) as YamlMap; if (node == null) return {}; @@ -386,14 +383,14 @@ class _ConfigurationLoader { _validate( keyNode, "$field keys must be strings.", (value) => value is String); - return keyNode.value as dynamic/*=K*/; + return keyNode.value as K; }; value ??= (valueNode) { _validate(valueNode, "$field values must be strings.", (value) => value is String); - return valueNode.value as dynamic/*=V*/; + return valueNode.value as V; }; return mapMap(node.nodes, @@ -419,10 +416,7 @@ class _ConfigurationLoader { /// /// If [parse] throws a [FormatException], it's wrapped to include [node]'s /// span. - /*=T*/ _parseNode/**/( - YamlNode node, - String name, - /*=T*/ parse(String value)) { + T _parseNode(YamlNode node, String name, T parse(String value)) { _validate(node, "$name must be a string.", (value) => value is String); try { @@ -438,7 +432,7 @@ class _ConfigurationLoader { /// /// If [parse] throws a [FormatException], it's wrapped to include [field]'s /// span. - /*=T*/ _parseValue/**/(String field, /*=T*/ parse(String value)) { + T _parseValue(String field, T parse(String value)) { var node = _document.nodes[field]; if (node == null) return null; return _parseNode(node, field, parse); @@ -467,12 +461,12 @@ class _ConfigurationLoader { /// logic into a parent [Configuration], leaving only maps to /// [SuiteConfiguration]s. The [create] function is used to construct /// [Configuration]s from the resolved maps. - Configuration _extractPresets/**/(Map/**/ map, - Configuration create(Map/**/ map)) { + Configuration _extractPresets(Map map, + Configuration create(Map map)) { if (map.isEmpty) return Configuration.empty; - var base = /**/ {}; - var presets = /*>*/ {}; + var base = {}; + var presets = >{}; map.forEach((key, config) { base[key] = config.suiteDefaults; config.presets.forEach((preset, presetConfig) { @@ -484,7 +478,7 @@ class _ConfigurationLoader { return base.isEmpty ? Configuration.empty : create(base); } else { var newPresets = - mapMap/*, String, Configuration>*/( + mapMap, String, Configuration>( presets, value: (_, map) => create(map)); return create(base).change(presets: newPresets); diff --git a/lib/src/runner/configuration/suite.dart b/lib/src/runner/configuration/suite.dart index 47aae094e..c41f88c45 100644 --- a/lib/src/runner/configuration/suite.dart +++ b/lib/src/runner/configuration/suite.dart @@ -202,15 +202,15 @@ class SuiteConfiguration { /// Returns an unmodifiable copy of [input]. /// /// If [input] is `null` or empty, this returns `null`. - static List/**/ _list/**/(Iterable/**/ input) { + static List _list(Iterable input) { if (input == null) return null; - var list = new List/**/ .unmodifiable(input); + var list = new List.unmodifiable(input); if (list.isEmpty) return null; return list; } /// Returns an unmodifiable copy of [input] or an empty unmodifiable map. - static Map/**/ _map/**/(Map/**/ input) { + static Map _map(Map input) { if (input == null || input.isEmpty) return const {}; return new Map.unmodifiable(input); } diff --git a/lib/src/runner/parse_metadata.dart b/lib/src/runner/parse_metadata.dart index 746956ac3..7eaf83f37 100644 --- a/lib/src/runner/parse_metadata.dart +++ b/lib/src/runner/parse_metadata.dart @@ -485,11 +485,10 @@ class _Parser { /// /// By default, returns [Expression] keys and values. These can be overridden /// with the [key] and [value] parameters. - Map/**/ _parseMap/**/(Expression expression, - {/*=K*/ key(Expression expression), - /*=V*/ value(Expression expression)}) { - if (key == null) key = (expression) => expression as dynamic/*=K*/; - if (value == null) value = (expression) => expression as dynamic/*=V*/; + Map _parseMap(Expression expression, + {K key(Expression expression), V value(Expression expression)}) { + if (key == null) key = (expression) => expression as K; + if (value == null) value = (expression) => expression as V; if (expression is! MapLiteral) { throw new SourceSpanFormatException( diff --git a/lib/src/utils.dart b/lib/src/utils.dart index fd17f04b8..f545e7425 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -278,10 +278,9 @@ Future maybeFirst(Stream stream) { /// /// If the subscription is canceled, any pending operations are canceled as /// well. -Stream/**/ inCompletionOrder/**/( - Iterable*/ > operations) { +Stream inCompletionOrder(Iterable> operations) { var operationSet = operations.toSet(); - var controller = new StreamController/**/( + var controller = new StreamController( sync: true, onCancel: () { return Future.wait(operationSet.map((operation) => operation.cancel()));