Skip to content

Commit 3f0fd63

Browse files
authored
Generic method cleanup (#1727)
1 parent 298dbe2 commit 3f0fd63

File tree

11 files changed

+31
-37
lines changed

11 files changed

+31
-37
lines changed

lib/src/asset/dart/serialize.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ SourceLocation deserializeLocation(Map location) {
7575
/// Converts [stream] into a serializable map.
7676
///
7777
/// [serializeEvent] is used to serialize each event from the stream.
78-
Map serializeStream/*<T>*/(Stream/*<T>*/ stream, serializeEvent(/*=T*/ event)) {
78+
Map serializeStream<T>(Stream<T> stream, serializeEvent(T event)) {
7979
var receivePort = new ReceivePort();
8080
var map = {'replyTo': receivePort.sendPort};
8181

@@ -95,9 +95,7 @@ Map serializeStream/*<T>*/(Stream/*<T>*/ stream, serializeEvent(/*=T*/ event)) {
9595
/// Converts a serializable map into a [Stream].
9696
///
9797
/// [deserializeEvent] is used to deserialize each event from the stream.
98-
Stream/*<T>*/ deserializeStream/*<T>*/(
99-
Map stream,
100-
/*=T*/ deserializeEvent(event)) {
98+
Stream<T> deserializeStream<T, S>(Map stream, T deserializeEvent(S event)) {
10199
return new LazyStream(() {
102100
var receivePort = new ReceivePort();
103101
stream['replyTo'].send({'replyTo': receivePort.sendPort});
@@ -128,14 +126,14 @@ Stream/*<T>*/ deserializeStream/*<T>*/(
128126
///
129127
/// The returned Future will complete to the value or error returned by
130128
/// [respond].
131-
Future/*<T>*/ call/*<T>*/(SendPort port, message) {
129+
Future<T> call<T>(SendPort port, message) {
132130
var receivePort = new ReceivePort();
133131
port.send({'message': message, 'replyTo': receivePort.sendPort});
134132

135133
return new Future.sync(() async {
136134
var response = await receivePort.first;
137135
if (response['type'] == 'success') {
138-
return response['value'] as dynamic/*=T*/;
136+
return response['value'] as T;
139137
}
140138
assert(response['type'] == 'error');
141139
var exception = deserializeException(response['error']);

lib/src/barback/pub_package_provider.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class PubPackageProvider implements StaticPackageProvider {
6767
return new Asset.fromPath(id, file);
6868
}
6969

70-
var versions = mapMap/*<String, Package, String, Version>*/(
71-
_graph.packages,
70+
var versions = mapMap<String, Package, String, Version>(_graph.packages,
7271
value: (_, package) => package.version);
7372
var contents = readTextFile(file);
7473
contents = preprocess(contents, versions, p.toUri(file));

lib/src/barback/transformer_isolate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class TransformerIsolate {
111111
/// return an empty set.
112112
Future<Set<Transformer>> create(TransformerConfig config) async {
113113
try {
114-
var transformers = (await call/*<List>*/(_port, {
114+
var transformers = (await call<List>(_port, {
115115
'library': _idsToUrls[config.id].toString(),
116116
'mode': _mode.name,
117117
'configuration': JSON.encode(config.configuration)

lib/src/command/build.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class BuildCommand extends BarbackCommand {
9393
}
9494

9595
var assets = await log
96-
.progress/*<AssetSet>*/("Building ${entrypoint.root.name}", () async {
96+
.progress<AssetSet>("Building ${entrypoint.root.name}", () async {
9797
// Register all of the build directories.
9898
// TODO(rnystrom): We don't actually need to bind servers for these, we
9999
// just need to add them to barback's sources. Add support to

lib/src/entrypoint.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ class Entrypoint {
767767
/// Recursively lists the contents of [dir], excluding hidden `.DS_Store`
768768
/// files and `package` files.
769769
Iterable<String> _listDirWithoutPackages(dir) {
770-
return listDir(dir).expand/*<String>*/((file) {
770+
return listDir(dir).expand<String>((file) {
771771
if (p.basename(file) == 'packages') return [];
772772
if (!dirExists(file)) return [];
773773
var fileAndSubfiles = [file];

lib/src/error_group.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ErrorGroup {
6565
///
6666
/// If all members of [this] have already completed successfully or with an
6767
/// error, it's a [StateError] to try to register a new [Future].
68-
Future/*<T>*/ registerFuture/*<T>*/(Future/*<T>*/ future) {
68+
Future<T> registerFuture<T>(Future<T> future) {
6969
if (_isDone) {
7070
throw new StateError("Can't register new members on a complete "
7171
"ErrorGroup.");
@@ -88,7 +88,7 @@ class ErrorGroup {
8888
///
8989
/// If all members of [this] have already completed successfully or with an
9090
/// error, it's a [StateError] to try to register a new [Stream].
91-
Stream/*<T>*/ registerStream/*<T>*/(Stream/*<T>*/ stream) {
91+
Stream<T> registerStream<T>(Stream<T> stream) {
9292
if (_isDone) {
9393
throw new StateError("Can't register new members on a complete "
9494
"ErrorGroup.");

lib/src/io.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Future<String> createFileFromStream(Stream<List<int>> stream, String file) {
197197
// TODO(nweiz): remove extra logging when we figure out the windows bot issue.
198198
log.io("Creating $file from stream.");
199199

200-
return _descriptorPool.withResource/*<Future<String>>*/(() async {
200+
return _descriptorPool.withResource<Future<String>>(() async {
201201
_deleteIfLink(file);
202202
await stream.pipe(new File(file).openWrite());
203203
log.fine("Created $file from stream.");
@@ -653,9 +653,8 @@ Future flushThenExit(int status) {
653653
/// Returns a [EventSink] that pipes all data to [consumer] and a [Future] that
654654
/// will succeed when [EventSink] is closed or fail with any errors that occur
655655
/// while writing.
656-
Pair<EventSink/*<T>*/, Future> consumerToSink/*<T>*/(
657-
StreamConsumer/*<T>*/ consumer) {
658-
var controller = new StreamController/*<T>*/(sync: true);
656+
Pair<EventSink<T>, Future> consumerToSink<T>(StreamConsumer<T> consumer) {
657+
var controller = new StreamController<T>(sync: true);
659658
var done = controller.stream.pipe(consumer);
660659
return new Pair(controller.sink, done);
661660
}
@@ -697,7 +696,7 @@ Future store(Stream stream, EventSink sink,
697696
/// the inherited variables.
698697
Future<PubProcessResult> runProcess(String executable, List<String> args,
699698
{workingDir, Map<String, String> environment, bool runInShell: false}) {
700-
return _descriptorPool.withResource/*<Future<PubProcessResult>>*/(() async {
699+
return _descriptorPool.withResource<Future<PubProcessResult>>(() async {
701700
var result = await _doProcess(Process.run, executable, args,
702701
workingDir: workingDir,
703702
environment: environment,
@@ -869,7 +868,7 @@ void touch(String path) {
869868
///
870869
/// Returns a future that completes to the value that the future returned from
871870
/// [fn] completes to.
872-
Future/*<T>*/ withTempDir/*<T>*/(Future/*<T>*/ fn(String path)) async {
871+
Future<T> withTempDir<T>(Future<T> fn(String path)) async {
873872
var tempDir = createSystemTempDir();
874873
try {
875874
return await fn(tempDir);

lib/src/log.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ void dumpTranscript() {
400400
/// [progress]) that cancels the progress animation, although the total time
401401
/// will still be printed once it finishes. If [fine] is passed, the progress
402402
/// information will only be visible at [Level.FINE].
403-
Future/*<T>*/ progress/*<T>*/(String message, Future/*<T>*/ callback(),
403+
Future<T> progress<T>(String message, Future<T> callback(),
404404
{bool fine: false}) {
405405
_stopProgress();
406406

lib/src/oauth2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void clearCredentials(SystemCache cache) {
7979
/// This takes care of loading and saving the client's credentials, as well as
8080
/// prompting the user for their authorization. It will also re-authorize and
8181
/// re-run [fn] if a recoverable authorization error is detected.
82-
Future withClient(SystemCache cache, Future fn(Client client)) {
82+
Future<T> withClient<T>(SystemCache cache, Future<T> fn(Client client)) {
8383
return _getClient(cache).then((client) {
8484
return fn(client).whenComplete(() {
8585
client.close();

lib/src/package_graph.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ class PackageGraph {
8181

8282
if (_transitiveDependencies == null) {
8383
var closure = transitiveClosure(
84-
mapMap/*<String, Package, String, Iterable<String>>*/(packages,
84+
mapMap<String, Package, String, Iterable<String>>(packages,
8585
value: (_, package) =>
8686
package.dependencies.map((dep) => dep.name)));
8787
_transitiveDependencies =
88-
mapMap/*<String, Set<String>, String, Set<Package>>*/(closure,
88+
mapMap<String, Set<String>, String, Set<Package>>(closure,
8989
value: (depender, names) {
9090
var set = names.map((name) => packages[name]).toSet();
9191
set.add(packages[depender]);

0 commit comments

Comments
 (0)