apply partially the upcoming unnecessary_lambdas (#8810)

This commit is contained in:
Alexandre Ardhuin
2017-03-15 23:09:58 +01:00
committed by GitHub
parent f9ad230f15
commit 2166ea5b7f
33 changed files with 71 additions and 143 deletions

View File

@@ -74,7 +74,7 @@ export 'dart:io'
/// Exits the process with the given [exitCode].
typedef void ExitFunction(int exitCode);
final ExitFunction _defaultExitFunction = (int exitCode) => io.exit(exitCode);
final ExitFunction _defaultExitFunction = io.exit;
ExitFunction _exitFunction = _defaultExitFunction;

View File

@@ -231,9 +231,7 @@ class MaterialFonts {
).then<Null>((Null value) {
cache.setStampFor(kName, cache.getVersionFor(kName));
status.stop();
}).whenComplete(() {
status.cancel();
});
}).whenComplete(status.cancel);
}
}
@@ -376,8 +374,6 @@ class FlutterEngine {
final Status status = logger.startProgress(message, expectSlowOperation: true);
return Cache._downloadFileToCache(Uri.parse(url), dest, true).then<Null>((Null value) {
status.stop();
}).whenComplete(() {
status.cancel();
});
}).whenComplete(status.cancel);
}
}

View File

@@ -169,7 +169,7 @@ class AnalysisServer {
_process.exitCode.whenComplete(() => _process = null);
final Stream<String> errorStream = _process.stderr.transform(UTF8.decoder).transform(const LineSplitter());
errorStream.listen((String error) => printError(error));
errorStream.listen(printError);
final Stream<String> inStream = _process.stdout.transform(UTF8.decoder).transform(const LineSplitter());
inStream.listen(_handleServerResponse);

View File

@@ -88,7 +88,7 @@ class Daemon {
// Start listening.
commandStream.listen(
(Map<String, dynamic> request) => _handleRequest(request),
_handleRequest,
onDone: () {
if (!_onExitCompleter.isCompleted)
_onExitCompleter.complete(0);
@@ -264,7 +264,7 @@ class DaemonDomain extends Domain {
}
Future<Null> shutdown(Map<String, dynamic> args) {
Timer.run(() => daemon.shutdown());
Timer.run(daemon.shutdown);
return new Future<Null>.value();
}

View File

@@ -277,7 +277,7 @@ abstract class Device {
}
static void printDevices(List<Device> devices) {
descriptions(devices).forEach((String msg) => printStatus(msg));
descriptions(devices).forEach(printStatus);
}
}

View File

@@ -609,9 +609,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
_IOSSimulatorLogReader(this.device, ApplicationPackage app) {
_linesController = new StreamController<String>.broadcast(
onListen: () {
_start();
},
onListen: _start,
onCancel: _stop
);
_appName = app == null ? null : app.name.replaceAll('.app', '');

View File

@@ -230,9 +230,7 @@ abstract class ResidentRunner {
throwToolExit('No Flutter view is available');
// Listen for service protocol connection to close.
vmService.done.whenComplete(() {
appFinished();
});
vmService.done.whenComplete(appFinished);
}
/// Returns [true] if the input has been handled by this function.
@@ -321,9 +319,7 @@ abstract class ResidentRunner {
printHelp(details: false);
}
terminal.singleCharMode = true;
terminal.onCharInput.listen((String code) {
processTerminalInput(code);
});
terminal.onCharInput.listen(processTerminalInput);
}
}

View File

@@ -250,7 +250,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
}
// The Android SDK could already have been set by tests.
context.putIfAbsent(AndroidSdk, () => AndroidSdk.locateAndroidSdk());
context.putIfAbsent(AndroidSdk, AndroidSdk.locateAndroidSdk);
if (globalResults['version']) {
flutterUsage.sendCommand('version');

View File

@@ -222,7 +222,7 @@ class _FlutterPlatform extends PlatformPlugin {
processObservatoryPort = detectedPort;
},
startTimeoutTimer: () {
new Future<_InitialResult>.delayed(_kTestStartupTimeout, () => timeout.complete());
new Future<_InitialResult>.delayed(_kTestStartupTimeout, timeout.complete);
},
);
@@ -265,7 +265,7 @@ class _FlutterPlatform extends PlatformPlugin {
final Completer<Null> harnessDone = new Completer<Null>();
final StreamSubscription<dynamic> harnessToTest = controller.stream.listen(
(dynamic event) { testSocket.add(JSON.encode(event)); },
onDone: () { harnessDone.complete(); },
onDone: harnessDone.complete,
onError: (dynamic error, dynamic stack) {
// If you reach here, it's unlikely we're going to be able to really handle this well.
printError('test harness controller stream experienced an unexpected error\ntest: $testPath\nerror: $error');
@@ -285,7 +285,7 @@ class _FlutterPlatform extends PlatformPlugin {
assert(encodedEvent is String); // we shouldn't ever get binary messages
controller.sink.add(JSON.decode(encodedEvent));
},
onDone: () { testDone.complete(); },
onDone: testDone.complete,
onError: (dynamic error, dynamic stack) {
// If you reach here, it's unlikely we're going to be able to really handle this well.
printError('test socket stream experienced an unexpected error\ntest: $testPath\nerror: $error');
@@ -559,9 +559,7 @@ class _FlutterPlatformStreamSinkWrapper<S> implements StreamSink<S> {
(List<dynamic> value) {
_done.complete();
},
onError: (dynamic error, StackTrace stack) {
_done.completeError(error, stack);
},
onError: _done.completeError,
);
return done;
}

View File

@@ -37,9 +37,7 @@ const Duration kLongRequestTimeout = const Duration(minutes: 1);
class VMService {
VMService._(this._peer, this.httpAddress, this.wsAddress, this._requestTimeout) {
_vm = new VM._empty(this);
_peer.listen().catchError((dynamic e, StackTrace stackTrace) {
_connectionError.completeError(e, stackTrace);
});
_peer.listen().catchError(_connectionError.completeError);
_peer.registerMethod('streamNotify', (rpc.Parameters event) {
_handleStreamNotify(event.asMap);
@@ -549,7 +547,7 @@ class VM extends ServiceObjectOwner {
toRemove.add(id);
}
});
toRemove.forEach((String id) => _isolateCache.remove(id));
toRemove.forEach(_isolateCache.remove);
_buildIsolateList();
}

View File

@@ -157,13 +157,8 @@ class _RecordingStream {
_recording.add(new _Response.fromString(element));
_controller.add(element);
},
onError: (dynamic error, StackTrace stackTrace) {
// We currently don't support recording of errors.
_controller.addError(error, stackTrace);
},
onDone: () {
_controller.close();
},
onError: _controller.addError, // We currently don't support recording of errors.
onDone: _controller.close,
);
}