Add @override annotations to flutter framework
This commit is contained in:
@@ -22,7 +22,7 @@ linter:
|
||||
- avoid_empty_else
|
||||
- always_declare_return_types
|
||||
- always_specify_types
|
||||
# - annotate_overrides # still a lot of work to do before enabling this one
|
||||
- annotate_overrides
|
||||
# - avoid_as # https://github.com/dart-lang/linter/issues/195
|
||||
- avoid_init_to_null
|
||||
# - avoid_return_types_on_setters # https://github.com/dart-lang/linter/issues/202
|
||||
|
||||
@@ -214,6 +214,7 @@ class AdbDevice {
|
||||
/// Device product; can be null. `peregrine_retus`, `nakasi`
|
||||
String get productID => _info['product'];
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
@@ -223,8 +224,10 @@ class AdbDevice {
|
||||
return id == typedOther.id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (modelID == null) {
|
||||
return '$id ($status)';
|
||||
|
||||
@@ -32,7 +32,10 @@ const String _deviceSnapshotPath = '/data/local/tmp/dev_snapshot.bin';
|
||||
class AndroidDevices extends PollingDeviceDiscovery {
|
||||
AndroidDevices() : super('AndroidDevices');
|
||||
|
||||
@override
|
||||
bool get supportsPlatform => true;
|
||||
|
||||
@override
|
||||
List<Device> pollingGetDevices() => getAdbDevices();
|
||||
}
|
||||
|
||||
@@ -50,6 +53,7 @@ class AndroidDevice extends Device {
|
||||
|
||||
bool _isLocalEmulator;
|
||||
|
||||
@override
|
||||
bool get isLocalEmulator {
|
||||
if (_isLocalEmulator == null) {
|
||||
// http://developer.android.com/ndk/guides/abis.html (x86, armeabi-v7a, ...)
|
||||
@@ -152,6 +156,7 @@ class AndroidDevice extends Device {
|
||||
return shaFile.existsSync() ? shaFile.readAsStringSync() : '';
|
||||
}
|
||||
|
||||
@override
|
||||
String get name => modelID;
|
||||
|
||||
@override
|
||||
@@ -279,6 +284,7 @@ class AndroidDevice extends Device {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> stopApp(ApplicationPackage app) {
|
||||
List<String> command = adbCommandForDevice(<String>['shell', 'am', 'force-stop', app.id]);
|
||||
return runCommandAndStreamOutput(command).then((int exitCode) => exitCode == 0);
|
||||
@@ -288,16 +294,19 @@ class AndroidDevice extends Device {
|
||||
@override
|
||||
TargetPlatform get platform => TargetPlatform.android_arm;
|
||||
|
||||
@override
|
||||
void clearLogs() {
|
||||
runSync(adbCommandForDevice(<String>['logcat', '-c']));
|
||||
}
|
||||
|
||||
@override
|
||||
DeviceLogReader get logReader {
|
||||
if (_logReader == null)
|
||||
_logReader = new _AdbLogReader(this);
|
||||
return _logReader;
|
||||
}
|
||||
|
||||
@override
|
||||
DevicePortForwarder get portForwarder {
|
||||
if (_portForwarder == null)
|
||||
_portForwarder = new _AndroidDevicePortForwarder(this);
|
||||
@@ -382,6 +391,7 @@ class AndroidDevice extends Device {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
|
||||
Future<bool> refreshSnapshot(AndroidApk apk, String snapshotPath) async {
|
||||
@@ -488,14 +498,19 @@ class _AdbLogReader extends DeviceLogReader {
|
||||
StreamSubscription<String> _stdoutSubscription;
|
||||
StreamSubscription<String> _stderrSubscription;
|
||||
|
||||
@override
|
||||
Stream<String> get lines => _linesStreamController.stream;
|
||||
|
||||
@override
|
||||
String get name => device.name;
|
||||
|
||||
@override
|
||||
bool get isReading => _process != null;
|
||||
|
||||
@override
|
||||
Future<int> get finished => _process != null ? _process.exitCode : new Future<int>.value(0);
|
||||
|
||||
@override
|
||||
Future<Null> start() async {
|
||||
if (_process != null)
|
||||
throw new StateError('_AdbLogReader must be stopped before it can be started.');
|
||||
@@ -516,6 +531,7 @@ class _AdbLogReader extends DeviceLogReader {
|
||||
_process.exitCode.then(_onExit);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> stop() async {
|
||||
if (_process == null)
|
||||
throw new StateError('_AdbLogReader must be started before it can be stopped.');
|
||||
@@ -540,8 +556,10 @@ class _AdbLogReader extends DeviceLogReader {
|
||||
_linesStreamController.add(line);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => name.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
@@ -560,6 +578,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
|
||||
return int.parse(portString.trim(), onError: (_) => null);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ForwardedPort> get forwardedPorts {
|
||||
final List<ForwardedPort> ports = <ForwardedPort>[];
|
||||
|
||||
@@ -591,6 +610,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
|
||||
return ports;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> forward(int devicePort, { int hostPort }) async {
|
||||
if ((hostPort == null) || (hostPort == 0)) {
|
||||
// Auto select host port.
|
||||
@@ -604,6 +624,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
|
||||
return hostPort;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> unforward(ForwardedPort forwardedPort) async {
|
||||
runCheckedSync(device.adbCommandForDevice(
|
||||
<String>['forward', '--remove', 'tcp:${forwardedPort.hostPort}']
|
||||
|
||||
@@ -175,6 +175,7 @@ class AndroidSdk {
|
||||
_latestVersion = _sdkVersions.isEmpty ? null : _sdkVersions.last;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'AndroidSdk: $directory';
|
||||
}
|
||||
|
||||
@@ -211,10 +212,12 @@ class AndroidSdkVersion implements Comparable<AndroidSdkVersion> {
|
||||
return path.join(sdk.directory, 'build-tools', buildToolsVersion, binaryName);
|
||||
}
|
||||
|
||||
@override
|
||||
int compareTo(AndroidSdkVersion other) {
|
||||
return sdkLevel - other.sdkLevel;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '[${sdk.directory}, SDK version $sdkLevel, build-tools $buildToolsVersion]';
|
||||
|
||||
bool _exists(String path, { bool complain: false }) {
|
||||
|
||||
@@ -7,14 +7,19 @@ import '../globals.dart';
|
||||
import 'android_sdk.dart';
|
||||
|
||||
class AndroidWorkflow extends Workflow {
|
||||
@override
|
||||
String get label => 'Android toolchain';
|
||||
|
||||
@override
|
||||
bool get appliesToHostPlatform => true;
|
||||
|
||||
@override
|
||||
bool get canListDevices => getAdbPath(androidSdk) != null;
|
||||
|
||||
@override
|
||||
bool get canLaunchDevices => androidSdk != null && androidSdk.validateSdkWellFormed(complain: false);
|
||||
|
||||
@override
|
||||
ValidationResult validate() {
|
||||
Validator androidValidator = new Validator(
|
||||
label,
|
||||
@@ -36,5 +41,6 @@ class AndroidWorkflow extends Workflow {
|
||||
return androidValidator.validate();
|
||||
}
|
||||
|
||||
@override
|
||||
void diagnose() => validate().print();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ abstract class ApplicationPackage {
|
||||
|
||||
String get displayName => name;
|
||||
|
||||
@override
|
||||
String toString() => displayName;
|
||||
}
|
||||
|
||||
@@ -95,6 +96,7 @@ class IOSApp extends ApplicationPackage {
|
||||
return new IOSApp(iosProjectDir: projectDir, iosProjectBundleId: value);
|
||||
}
|
||||
|
||||
@override
|
||||
String get displayName => id;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,22 +26,28 @@ abstract class Logger {
|
||||
}
|
||||
|
||||
class StdoutLogger implements Logger {
|
||||
@override
|
||||
bool get isVerbose => false;
|
||||
|
||||
@override
|
||||
void printError(String message, [StackTrace stackTrace]) {
|
||||
stderr.writeln(message);
|
||||
if (stackTrace != null)
|
||||
stderr.writeln(stackTrace);
|
||||
}
|
||||
|
||||
@override
|
||||
void printStatus(String message) => print(message);
|
||||
|
||||
@override
|
||||
void printTrace(String message) { }
|
||||
|
||||
@override
|
||||
void flush() { }
|
||||
}
|
||||
|
||||
class BufferLogger implements Logger {
|
||||
@override
|
||||
bool get isVerbose => false;
|
||||
|
||||
StringBuffer _error = new StringBuffer();
|
||||
@@ -52,33 +58,44 @@ class BufferLogger implements Logger {
|
||||
String get statusText => _status.toString();
|
||||
String get traceText => _trace.toString();
|
||||
|
||||
@override
|
||||
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
|
||||
|
||||
@override
|
||||
void printStatus(String message) => _status.writeln(message);
|
||||
|
||||
@override
|
||||
void printTrace(String message) => _trace.writeln(message);
|
||||
|
||||
@override
|
||||
void flush() { }
|
||||
}
|
||||
|
||||
class VerboseLogger implements Logger {
|
||||
_LogMessage lastMessage;
|
||||
|
||||
@override
|
||||
bool get isVerbose => true;
|
||||
|
||||
@override
|
||||
void printError(String message, [StackTrace stackTrace]) {
|
||||
_emit();
|
||||
lastMessage = new _LogMessage(_LogType.error, message, stackTrace);
|
||||
}
|
||||
|
||||
@override
|
||||
void printStatus(String message) {
|
||||
_emit();
|
||||
lastMessage = new _LogMessage(_LogType.status, message);
|
||||
}
|
||||
|
||||
@override
|
||||
void printTrace(String message) {
|
||||
_emit();
|
||||
lastMessage = new _LogMessage(_LogType.trace, message);
|
||||
}
|
||||
|
||||
@override
|
||||
void flush() => _emit();
|
||||
|
||||
void _emit() {
|
||||
|
||||
@@ -38,12 +38,14 @@ abstract class OperatingSystemUtils {
|
||||
class _PosixUtils extends OperatingSystemUtils {
|
||||
_PosixUtils() : super._private();
|
||||
|
||||
@override
|
||||
ProcessResult makeExecutable(File file) {
|
||||
return Process.runSync('chmod', ['u+x', file.path]);
|
||||
}
|
||||
|
||||
/// Return the path (with symlinks resolved) to the given executable, or `null`
|
||||
/// if `which` was not able to locate the binary.
|
||||
@override
|
||||
File which(String execName) {
|
||||
ProcessResult result = Process.runSync('which', <String>[execName]);
|
||||
if (result.exitCode != 0)
|
||||
@@ -57,10 +59,12 @@ class _WindowsUtils extends OperatingSystemUtils {
|
||||
_WindowsUtils() : super._private();
|
||||
|
||||
// This is a no-op.
|
||||
@override
|
||||
ProcessResult makeExecutable(File file) {
|
||||
return new ProcessResult(0, 0, null, null);
|
||||
}
|
||||
|
||||
@override
|
||||
File which(String execName) {
|
||||
throw new UnimplementedError('_WindowsUtils.which');
|
||||
}
|
||||
|
||||
@@ -136,8 +136,12 @@ String _runWithLoggingSync(List<String> cmd, {
|
||||
}
|
||||
|
||||
class ProcessExit implements Exception {
|
||||
final int exitCode;
|
||||
ProcessExit(this.exitCode);
|
||||
|
||||
final int exitCode;
|
||||
|
||||
String get message => 'ProcessExit: $exitCode';
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
|
||||
@@ -118,8 +118,13 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false);
|
||||
}
|
||||
|
||||
@override
|
||||
String get name => 'analyze';
|
||||
|
||||
@override
|
||||
String get description => 'Analyze the project\'s Dart code.';
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
bool get isFlutterRepo {
|
||||
@@ -760,6 +765,7 @@ class AnalysisError implements Comparable<AnalysisError> {
|
||||
int get startColumn => json['location']['startColumn'];
|
||||
int get offset => json['location']['offset'];
|
||||
|
||||
@override
|
||||
int compareTo(AnalysisError other) {
|
||||
// Sort in order of file path, error location, severity, and message.
|
||||
if (file != other.file)
|
||||
@@ -775,6 +781,7 @@ class AnalysisError implements Comparable<AnalysisError> {
|
||||
return message.compareTo(other.message);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
String relativePath = path.relative(file);
|
||||
return '${severity.toLowerCase().padLeft(7)} • $message • $relativePath:$startLine:$startColumn';
|
||||
|
||||
@@ -136,7 +136,10 @@ class ApkKeystoreInfo {
|
||||
}
|
||||
|
||||
class ApkCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'apk';
|
||||
|
||||
@override
|
||||
final String description = 'Build an Android APK package.';
|
||||
|
||||
ApkCommand() {
|
||||
|
||||
@@ -11,7 +11,10 @@ import '../runner/flutter_command.dart';
|
||||
import '../toolchain.dart';
|
||||
|
||||
class BuildCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'build';
|
||||
|
||||
@override
|
||||
final String description = 'Package your Flutter app into an FLX.';
|
||||
|
||||
BuildCommand() {
|
||||
@@ -42,6 +45,7 @@ class BuildCommand extends FlutterCommand {
|
||||
return await super.run();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
String compilerPath = argResults['compiler'];
|
||||
|
||||
|
||||
@@ -16,8 +16,13 @@ import '../globals.dart';
|
||||
import '../template.dart';
|
||||
|
||||
class CreateCommand extends Command {
|
||||
@override
|
||||
final String name = 'create';
|
||||
|
||||
@override
|
||||
final String description = 'Create a new Flutter project.';
|
||||
|
||||
@override
|
||||
final List<String> aliases = <String>['init'];
|
||||
|
||||
CreateCommand() {
|
||||
@@ -38,6 +43,7 @@ class CreateCommand extends Command {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String get invocation => "${runner.executableName} $name <output directory>";
|
||||
|
||||
@override
|
||||
|
||||
@@ -28,14 +28,20 @@ const String protocolVersion = '0.1.0';
|
||||
class DaemonCommand extends FlutterCommand {
|
||||
DaemonCommand({ bool hideCommand: false }) : _hideCommand = hideCommand;
|
||||
|
||||
@override
|
||||
final String name = 'daemon';
|
||||
|
||||
@override
|
||||
final String description = 'Run a persistent, JSON-RPC based server to communicate with devices.';
|
||||
final bool _hideCommand;
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
@override
|
||||
bool get hidden => _hideCommand;
|
||||
|
||||
@override
|
||||
Future<int> runInProject() {
|
||||
printStatus('Starting device daemon...');
|
||||
|
||||
@@ -155,6 +161,7 @@ abstract class Domain {
|
||||
|
||||
FlutterCommand get command => daemon.daemonCommand;
|
||||
|
||||
@override
|
||||
String toString() => name;
|
||||
|
||||
void handleCommand(String command, dynamic id, dynamic args) {
|
||||
@@ -220,6 +227,7 @@ class DaemonDomain extends Domain {
|
||||
return new Future<Null>.value();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_subscription?.cancel();
|
||||
}
|
||||
@@ -371,6 +379,7 @@ class DeviceDomain extends Domain {
|
||||
return new Future<Null>.value();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (PollingDeviceDiscovery discoverer in _discoverers) {
|
||||
discoverer.dispose();
|
||||
@@ -410,14 +419,17 @@ class NotifyingLogger extends Logger {
|
||||
|
||||
Stream<LogMessage> get onMessage => _messageController.stream;
|
||||
|
||||
@override
|
||||
void printError(String message, [StackTrace stackTrace]) {
|
||||
_messageController.add(new LogMessage('error', message, stackTrace));
|
||||
}
|
||||
|
||||
@override
|
||||
void printStatus(String message) {
|
||||
_messageController.add(new LogMessage('status', message));
|
||||
}
|
||||
|
||||
@override
|
||||
void printTrace(String message) {
|
||||
// This is a lot of traffic to send over the wire.
|
||||
}
|
||||
|
||||
@@ -10,12 +10,19 @@ import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class DevicesCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'devices';
|
||||
|
||||
@override
|
||||
final String description = 'List all connected devices.';
|
||||
|
||||
@override
|
||||
final List<String> aliases = <String>['list'];
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
if (!doctor.canListAnything) {
|
||||
printError("Unable to locate a development device; please run 'flutter doctor' for "
|
||||
|
||||
@@ -10,11 +10,16 @@ import '../runner/flutter_command.dart';
|
||||
import '../runner/version.dart';
|
||||
|
||||
class DoctorCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'doctor';
|
||||
|
||||
@override
|
||||
final String description = 'Show information about the installed tooling.';
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
// general info
|
||||
String flutterRoot = ArtifactStore.flutterRoot;
|
||||
|
||||
@@ -64,8 +64,13 @@ class DriveCommand extends RunCommandBase {
|
||||
help: 'Listen to the given port for a debug connection.');
|
||||
}
|
||||
|
||||
@override
|
||||
final String name = 'drive';
|
||||
|
||||
@override
|
||||
final String description = 'Runs Flutter Driver tests for the current project.';
|
||||
|
||||
@override
|
||||
final List<String> aliases = <String>['driver'];
|
||||
|
||||
Device _device;
|
||||
|
||||
@@ -10,9 +10,13 @@ import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class InstallCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'install';
|
||||
|
||||
@override
|
||||
final String description = 'Install a Flutter app on an attached device.';
|
||||
|
||||
@override
|
||||
bool get requiresDevice => true;
|
||||
|
||||
@override
|
||||
|
||||
@@ -10,9 +10,14 @@ import '../globals.dart';
|
||||
import 'run.dart';
|
||||
|
||||
class ListenCommand extends RunCommandBase {
|
||||
@override
|
||||
final String name = 'listen';
|
||||
|
||||
@override
|
||||
final String description =
|
||||
'Listen for changes to files and reload the running app (Android only).';
|
||||
|
||||
@override
|
||||
final String usageFooter =
|
||||
'By default, only listens to "./" and "./lib/". To listen to additional directories, list them on\n'
|
||||
'the command line.';
|
||||
@@ -22,8 +27,10 @@ class ListenCommand extends RunCommandBase {
|
||||
|
||||
ListenCommand({ this.singleRun: false });
|
||||
|
||||
@override
|
||||
bool get androidOnly => true;
|
||||
|
||||
@override
|
||||
bool get requiresDevice => true;
|
||||
|
||||
@override
|
||||
|
||||
@@ -9,7 +9,10 @@ import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class LogsCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'logs';
|
||||
|
||||
@override
|
||||
final String description = 'Show log output for running Flutter apps.';
|
||||
|
||||
LogsCommand() {
|
||||
@@ -20,10 +23,13 @@ class LogsCommand extends FlutterCommand {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
@override
|
||||
bool get requiresDevice => true;
|
||||
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
Device device = deviceForCommand;
|
||||
|
||||
|
||||
@@ -12,15 +12,20 @@ import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class RefreshCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'refresh';
|
||||
|
||||
@override
|
||||
final String description = 'Build and deploy the Dart code in a Flutter app (Android only).';
|
||||
|
||||
RefreshCommand() {
|
||||
addTargetOption();
|
||||
}
|
||||
|
||||
@override
|
||||
bool get androidOnly => true;
|
||||
|
||||
@override
|
||||
bool get requiresDevice => true;
|
||||
|
||||
@override
|
||||
|
||||
@@ -53,8 +53,13 @@ abstract class RunCommandBase extends FlutterCommand {
|
||||
}
|
||||
|
||||
class RunCommand extends RunCommandBase {
|
||||
@override
|
||||
final String name = 'run';
|
||||
|
||||
@override
|
||||
final String description = 'Run your Flutter app on an attached device.';
|
||||
|
||||
@override
|
||||
final List<String> aliases = <String>['start'];
|
||||
|
||||
RunCommand() {
|
||||
@@ -76,6 +81,7 @@ class RunCommand extends RunCommandBase {
|
||||
help: 'Listen to the given port for a debug connection.');
|
||||
}
|
||||
|
||||
@override
|
||||
bool get requiresDevice => true;
|
||||
|
||||
@override
|
||||
|
||||
@@ -18,7 +18,10 @@ import 'run.dart';
|
||||
const String _kDefaultBundlePath = 'build/app.flx';
|
||||
|
||||
class RunMojoCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'run_mojo';
|
||||
|
||||
@override
|
||||
final String description = 'Run a Flutter app in mojo (from github.com/domokit/mojo).';
|
||||
final bool _hideCommand;
|
||||
|
||||
@@ -37,7 +40,10 @@ class RunMojoCommand extends FlutterCommand {
|
||||
argParser.addOption('devtools-path', help: 'Path to mojo devtools\' mojo_run command.');
|
||||
}
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
@override
|
||||
bool get hidden => _hideCommand;
|
||||
|
||||
// TODO(abarth): Why not use path.absolute?
|
||||
|
||||
@@ -10,9 +10,13 @@ import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class StopCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'stop';
|
||||
|
||||
@override
|
||||
final String description = 'Stop your Flutter app on an attached device.';
|
||||
|
||||
@override
|
||||
bool get requiresDevice => true;
|
||||
|
||||
@override
|
||||
|
||||
@@ -23,8 +23,13 @@ class TestCommand extends FlutterCommand {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String get name => 'test';
|
||||
|
||||
@override
|
||||
String get description => 'Run Flutter unit tests for the current project (Linux only).';
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
@override
|
||||
|
||||
@@ -10,8 +10,13 @@ import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class TraceCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'trace';
|
||||
|
||||
@override
|
||||
final String description = 'Start and stop tracing for a running Flutter app (Android only).';
|
||||
|
||||
@override
|
||||
final String usageFooter =
|
||||
'\`trace\` called with no arguments will automatically start tracing, delay a set amount of\n'
|
||||
'time (controlled by --duration), and stop tracing. To explicitly control tracing, call trace\n'
|
||||
@@ -25,8 +30,10 @@ class TraceCommand extends FlutterCommand {
|
||||
defaultsTo: '10', abbr: 'd', help: 'Duration in seconds to trace.');
|
||||
}
|
||||
|
||||
@override
|
||||
bool get androidOnly => true;
|
||||
|
||||
@override
|
||||
bool get requiresDevice => true;
|
||||
|
||||
@override
|
||||
|
||||
@@ -32,12 +32,17 @@ class UpdatePackagesCommand extends FlutterCommand {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
final String name = 'update-packages';
|
||||
|
||||
@override
|
||||
final String description = 'Update the packages inside the Flutter repo.';
|
||||
|
||||
@override
|
||||
bool get hidden => _hideCommand;
|
||||
final bool _hideCommand;
|
||||
|
||||
@override
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
@override
|
||||
|
||||
@@ -11,7 +11,10 @@ import '../runner/flutter_command.dart';
|
||||
import '../runner/version.dart';
|
||||
|
||||
class UpgradeCommand extends FlutterCommand {
|
||||
@override
|
||||
final String name = 'upgrade';
|
||||
|
||||
@override
|
||||
final String description = 'Upgrade your copy of Flutter.';
|
||||
|
||||
@override
|
||||
|
||||
@@ -111,6 +111,7 @@ abstract class PollingDeviceDiscovery extends DeviceDiscovery {
|
||||
_timer = null;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Device> get devices {
|
||||
if (_items == null)
|
||||
_items = new ItemListNotifier<Device>.from(pollingGetDevices());
|
||||
@@ -131,6 +132,7 @@ abstract class PollingDeviceDiscovery extends DeviceDiscovery {
|
||||
|
||||
void dispose() => stopPolling();
|
||||
|
||||
@override
|
||||
String toString() => '$name device discovery';
|
||||
}
|
||||
|
||||
@@ -189,8 +191,10 @@ abstract class Device {
|
||||
/// Stop an app package on the current device.
|
||||
Future<bool> stopApp(ApplicationPackage app);
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
@@ -199,6 +203,7 @@ abstract class Device {
|
||||
return id == other.id;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => name;
|
||||
|
||||
static void printDevices(List<Device> devices) {
|
||||
@@ -225,6 +230,7 @@ class ForwardedPort {
|
||||
final int hostPort;
|
||||
final int devicePort;
|
||||
|
||||
@override
|
||||
String toString() => 'ForwardedPort HOST:$hostPort to DEVICE:$devicePort';
|
||||
}
|
||||
|
||||
@@ -266,8 +272,12 @@ abstract class DeviceLogReader {
|
||||
/// Completes when the log is finished.
|
||||
Future<int> get finished;
|
||||
|
||||
@override
|
||||
int get hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other);
|
||||
|
||||
@override
|
||||
String toString() => name;
|
||||
}
|
||||
|
||||
@@ -228,8 +228,10 @@ class _AtomValidator extends DoctorValidator {
|
||||
: path.join(env['HOME'], '.atom');
|
||||
}
|
||||
|
||||
@override
|
||||
String get label => 'Atom development environment';
|
||||
|
||||
@override
|
||||
ValidationResult validate() {
|
||||
Validator atomValidator = new Validator(
|
||||
label,
|
||||
@@ -263,5 +265,6 @@ class _AtomValidator extends DoctorValidator {
|
||||
return atomValidator.validate();
|
||||
}
|
||||
|
||||
@override
|
||||
void diagnose() => validate().print();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,10 @@ const String _ideviceinstallerInstructions =
|
||||
class IOSDevices extends PollingDeviceDiscovery {
|
||||
IOSDevices() : super('IOSDevices');
|
||||
|
||||
@override
|
||||
bool get supportsPlatform => Platform.isMacOS;
|
||||
|
||||
@override
|
||||
List<Device> pollingGetDevices() => IOSDevice.getAttachedDevices();
|
||||
}
|
||||
|
||||
@@ -62,14 +65,17 @@ class IOSDevice extends Device {
|
||||
String _pusherPath;
|
||||
String get pusherPath => _pusherPath;
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
||||
_IOSDeviceLogReader _logReader;
|
||||
|
||||
_IOSDevicePortForwarder _portForwarder;
|
||||
|
||||
@override
|
||||
bool get isLocalEmulator => false;
|
||||
|
||||
@override
|
||||
bool get supportsStartPaused => false;
|
||||
|
||||
static List<IOSDevice> getAttachedDevices([IOSDevice mockIOS]) {
|
||||
@@ -226,6 +232,7 @@ class IOSDevice extends Device {
|
||||
@override
|
||||
TargetPlatform get platform => TargetPlatform.ios_arm;
|
||||
|
||||
@override
|
||||
DeviceLogReader get logReader {
|
||||
if (_logReader == null)
|
||||
_logReader = new _IOSDeviceLogReader(this);
|
||||
@@ -233,6 +240,7 @@ class IOSDevice extends Device {
|
||||
return _logReader;
|
||||
}
|
||||
|
||||
@override
|
||||
DevicePortForwarder get portForwarder {
|
||||
if (_portForwarder == null)
|
||||
_portForwarder = new _IOSDevicePortForwarder(this);
|
||||
@@ -240,6 +248,7 @@ class IOSDevice extends Device {
|
||||
return _portForwarder;
|
||||
}
|
||||
|
||||
@override
|
||||
void clearLogs() {
|
||||
}
|
||||
}
|
||||
@@ -256,16 +265,21 @@ class _IOSDeviceLogReader extends DeviceLogReader {
|
||||
StreamSubscription<String> _stdoutSubscription;
|
||||
StreamSubscription<String> _stderrSubscription;
|
||||
|
||||
@override
|
||||
Stream<String> get lines => _linesStreamController.stream;
|
||||
|
||||
@override
|
||||
String get name => device.name;
|
||||
|
||||
@override
|
||||
bool get isReading => _process != null;
|
||||
|
||||
@override
|
||||
Future<int> get finished {
|
||||
return _process != null ? _process.exitCode : new Future<int>.value(0);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> start() async {
|
||||
if (_process != null) {
|
||||
throw new StateError(
|
||||
@@ -282,6 +296,7 @@ class _IOSDeviceLogReader extends DeviceLogReader {
|
||||
_process.exitCode.then(_onExit);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> stop() async {
|
||||
if (_process == null) {
|
||||
throw new StateError(
|
||||
@@ -313,8 +328,10 @@ class _IOSDeviceLogReader extends DeviceLogReader {
|
||||
_linesStreamController.add(line);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => name.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
@@ -329,12 +346,14 @@ class _IOSDevicePortForwarder extends DevicePortForwarder {
|
||||
|
||||
final IOSDevice device;
|
||||
|
||||
@override
|
||||
List<ForwardedPort> get forwardedPorts {
|
||||
final List<ForwardedPort> ports = <ForwardedPort>[];
|
||||
// TODO(chinmaygarde): Implement.
|
||||
return ports;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> forward(int devicePort, {int hostPort: null}) async {
|
||||
if ((hostPort == null) || (hostPort == 0)) {
|
||||
// Auto select host port.
|
||||
@@ -344,6 +363,7 @@ class _IOSDevicePortForwarder extends DevicePortForwarder {
|
||||
return hostPort;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> unforward(ForwardedPort forwardedPort) async {
|
||||
// TODO(chinmaygarde): Implement.
|
||||
}
|
||||
|
||||
@@ -9,17 +9,22 @@ import '../doctor.dart';
|
||||
import 'mac.dart';
|
||||
|
||||
class IOSWorkflow extends Workflow {
|
||||
@override
|
||||
String get label => 'iOS toolchain';
|
||||
|
||||
@override
|
||||
bool get appliesToHostPlatform => Platform.isMacOS;
|
||||
|
||||
// We need xcode (+simctl) to list simulator devices, and idevice_id to list real devices.
|
||||
@override
|
||||
bool get canListDevices => XCode.instance.isInstalledAndMeetsVersionCheck;
|
||||
|
||||
// We need xcode to launch simulator devices, and ideviceinstaller and ios-deploy
|
||||
// for real devices.
|
||||
@override
|
||||
bool get canLaunchDevices => XCode.instance.isInstalledAndMeetsVersionCheck;
|
||||
|
||||
@override
|
||||
ValidationResult validate() {
|
||||
Validator iosValidator = new Validator(
|
||||
label,
|
||||
@@ -101,6 +106,7 @@ class IOSWorkflow extends Workflow {
|
||||
return iosValidator.validate();
|
||||
}
|
||||
|
||||
@override
|
||||
void diagnose() => validate().print();
|
||||
|
||||
bool get hasIdeviceId => exitsHappy(<String>['idevice_id', '-h']);
|
||||
|
||||
@@ -27,7 +27,10 @@ const String _kFlutterTestDevice = 'flutter.test.device';
|
||||
class IOSSimulators extends PollingDeviceDiscovery {
|
||||
IOSSimulators() : super('IOSSimulators');
|
||||
|
||||
@override
|
||||
bool get supportsPlatform => Platform.isMacOS;
|
||||
|
||||
@override
|
||||
List<Device> pollingGetDevices() => IOSSimulatorUtils.instance.getAttachedDevices();
|
||||
}
|
||||
|
||||
@@ -314,8 +317,10 @@ class SimDevice {
|
||||
class IOSSimulator extends Device {
|
||||
IOSSimulator(String id, { this.name }) : super(id);
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
||||
@override
|
||||
bool get isLocalEmulator => true;
|
||||
|
||||
_IOSSimulatorLogReader _logReader;
|
||||
@@ -536,6 +541,7 @@ class IOSSimulator extends Device {
|
||||
@override
|
||||
TargetPlatform get platform => TargetPlatform.ios_x64;
|
||||
|
||||
@override
|
||||
DeviceLogReader get logReader {
|
||||
if (_logReader == null)
|
||||
_logReader = new _IOSSimulatorLogReader(this);
|
||||
@@ -543,6 +549,7 @@ class IOSSimulator extends Device {
|
||||
return _logReader;
|
||||
}
|
||||
|
||||
@override
|
||||
DevicePortForwarder get portForwarder {
|
||||
if (_portForwarder == null)
|
||||
_portForwarder = new _IOSSimulatorDevicePortForwarder(this);
|
||||
@@ -550,6 +557,7 @@ class IOSSimulator extends Device {
|
||||
return _portForwarder;
|
||||
}
|
||||
|
||||
@override
|
||||
void clearLogs() {
|
||||
File logFile = new File(logFilePath);
|
||||
if (logFile.existsSync()) {
|
||||
@@ -585,16 +593,21 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
|
||||
StreamSubscription<String> _systemStdoutSubscription;
|
||||
StreamSubscription<String> _systemStderrSubscription;
|
||||
|
||||
@override
|
||||
Stream<String> get lines => _linesStreamController.stream;
|
||||
|
||||
@override
|
||||
String get name => device.name;
|
||||
|
||||
@override
|
||||
bool get isReading => (_deviceProcess != null) && (_systemProcess != null);
|
||||
|
||||
@override
|
||||
Future<int> get finished {
|
||||
return (_deviceProcess != null) ? _deviceProcess.exitCode : new Future<int>.value(0);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> start() async {
|
||||
if (isReading) {
|
||||
throw new StateError(
|
||||
@@ -630,6 +643,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
|
||||
_systemProcess.exitCode.then(_onSystemExit);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> stop() async {
|
||||
if (!isReading) {
|
||||
throw new StateError(
|
||||
@@ -727,8 +741,10 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
|
||||
_linesStreamController.add(filteredLine);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => device.logFilePath.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
@@ -789,10 +805,12 @@ class _IOSSimulatorDevicePortForwarder extends DevicePortForwarder {
|
||||
|
||||
final List<ForwardedPort> _ports = <ForwardedPort>[];
|
||||
|
||||
@override
|
||||
List<ForwardedPort> get forwardedPorts {
|
||||
return _ports;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> forward(int devicePort, {int hostPort: null}) async {
|
||||
if ((hostPort == null) || (hostPort == 0)) {
|
||||
hostPort = devicePort;
|
||||
@@ -802,6 +820,7 @@ class _IOSSimulatorDevicePortForwarder extends DevicePortForwarder {
|
||||
return hostPort;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Null> unforward(ForwardedPort forwardedPort) async {
|
||||
_ports.remove(forwardedPort);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'flutter_command_runner.dart';
|
||||
typedef bool Validator();
|
||||
|
||||
abstract class FlutterCommand extends Command {
|
||||
@override
|
||||
FlutterCommandRunner get runner => super.runner;
|
||||
|
||||
/// Whether this command needs to be run from the root of a project.
|
||||
@@ -43,6 +44,7 @@ abstract class FlutterCommand extends Command {
|
||||
applicationPackages ??= await ApplicationPackageStore.forConfigs(buildConfigurations);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> run() {
|
||||
Stopwatch stopwatch = new Stopwatch()..start();
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
defaultsTo: 'out/ios_sim_Release/');
|
||||
}
|
||||
|
||||
@override
|
||||
String get usageFooter {
|
||||
return 'Run "flutter -h -v" for verbose help output, including less commonly used options.\n'
|
||||
'\n'
|
||||
@@ -165,6 +166,7 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
return '.';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> run(Iterable<String> args) {
|
||||
return super.run(args).then((dynamic result) {
|
||||
logger.flush();
|
||||
@@ -172,6 +174,7 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> runCommand(ArgResults globalResults) {
|
||||
_globalResults = globalResults;
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ Future<Process> _startProcess(String mainPath, { String packageRoot }) {
|
||||
}
|
||||
|
||||
class FlutterPlatform extends PlatformPlugin {
|
||||
@override
|
||||
StreamChannel<String> loadChannel(String mainPath, TestPlatform platform) {
|
||||
return StreamChannelCompleter.fromFuture(_startTest(mainPath));
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class ZipEntry {
|
||||
class _ArchiveZipBuilder extends ZipBuilder {
|
||||
_ArchiveZipBuilder() : super._();
|
||||
|
||||
@override
|
||||
void createZip(File outFile, Directory zipBuildDir) {
|
||||
Archive archive = new Archive();
|
||||
|
||||
@@ -69,6 +70,7 @@ class _ArchiveZipBuilder extends ZipBuilder {
|
||||
class _ZipToolBuilder extends ZipBuilder {
|
||||
_ZipToolBuilder() : super._();
|
||||
|
||||
@override
|
||||
void createZip(File outFile, Directory zipBuildDir) {
|
||||
if (outFile.existsSync())
|
||||
outFile.deleteSync();
|
||||
|
||||
@@ -69,16 +69,22 @@ void testUsingContext(String description, dynamic testMethod(), {
|
||||
class MockDeviceManager implements DeviceManager {
|
||||
List<Device> devices = <Device>[];
|
||||
|
||||
@override
|
||||
String specifiedDeviceId;
|
||||
|
||||
@override
|
||||
bool get hasSpecifiedDeviceId => specifiedDeviceId != null;
|
||||
|
||||
@override
|
||||
Future<List<Device>> getAllConnectedDevices() => new Future<List<Device>>.value(devices);
|
||||
|
||||
@override
|
||||
Future<Device> getDeviceById(String deviceId) {
|
||||
Device device = devices.firstWhere((Device device) => device.id == deviceId, orElse: () => null);
|
||||
return new Future<Device>.value(device);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Device>> getDevices() async {
|
||||
if (specifiedDeviceId == null) {
|
||||
return getAllConnectedDevices();
|
||||
@@ -93,6 +99,7 @@ class MockDeviceManager implements DeviceManager {
|
||||
|
||||
class MockDoctor extends Doctor {
|
||||
// True for testing.
|
||||
@override
|
||||
bool get canLaunchAnything => true;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,21 +36,31 @@ class MockToolchain extends Toolchain {
|
||||
}
|
||||
|
||||
class MockAndroidDevice extends Mock implements AndroidDevice {
|
||||
@override
|
||||
TargetPlatform get platform => TargetPlatform.android_arm;
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
}
|
||||
|
||||
class MockIOSDevice extends Mock implements IOSDevice {
|
||||
@override
|
||||
TargetPlatform get platform => TargetPlatform.ios_arm;
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
}
|
||||
|
||||
class MockIOSSimulator extends Mock implements IOSSimulator {
|
||||
@override
|
||||
TargetPlatform get platform => TargetPlatform.ios_x64;
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
}
|
||||
|
||||
class MockDeviceLogReader extends DeviceLogReader {
|
||||
@override
|
||||
String get name => 'MockLogReader';
|
||||
|
||||
final StreamController<String> _linesStreamController =
|
||||
@@ -58,6 +68,7 @@ class MockDeviceLogReader extends DeviceLogReader {
|
||||
|
||||
final Completer<int> _finishedCompleter = new Completer<int>();
|
||||
|
||||
@override
|
||||
Stream<String> get lines => _linesStreamController.stream;
|
||||
|
||||
void addLine(String line) {
|
||||
@@ -66,19 +77,23 @@ class MockDeviceLogReader extends DeviceLogReader {
|
||||
|
||||
bool _started = false;
|
||||
|
||||
@override
|
||||
Future<Null> start() async {
|
||||
assert(!_started);
|
||||
_started = true;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isReading => _started;
|
||||
|
||||
@override
|
||||
Future<Null> stop() {
|
||||
assert(_started);
|
||||
_started = false;
|
||||
return new Future<Null>.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> get finished => _finishedCompleter.future;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user