From c04f712a23854adce17c4b4af28e83d180b484af Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 15 Jun 2017 19:24:07 -0700 Subject: [PATCH] Refactor Xcode instance lookup (#10763) Use a top-level getter in mac.dart rather than a static instance getter and a top-level getter in ios_workflow.dart. Makes this code consistent with how we do context lookups elsewhere. --- packages/flutter_tools/lib/src/commands/run.dart | 2 +- packages/flutter_tools/lib/src/ios/ios_workflow.dart | 2 -- packages/flutter_tools/lib/src/ios/mac.dart | 5 ++--- packages/flutter_tools/lib/src/ios/simulators.dart | 5 ++--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 7f84958f3a..bc596fb1b0 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -177,7 +177,7 @@ class RunCommand extends RunCommandBase { void printNoConnectedDevices() { super.printNoConnectedDevices(); if (getCurrentHostPlatform() == HostPlatform.darwin_x64 && - Xcode.instance.isInstalledAndMeetsVersionCheck) { + xcode.isInstalledAndMeetsVersionCheck) { printStatus(''); printStatus('To run on a simulator, launch it first: open -a Simulator.app'); printStatus(''); diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index 9f6e0de02b..35ee3ba7a4 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -16,8 +16,6 @@ import 'mac.dart'; IOSWorkflow get iosWorkflow => context.putIfAbsent(IOSWorkflow, () => new IOSWorkflow()); -Xcode get xcode => Xcode.instance; - class IOSWorkflow extends DoctorValidator implements Workflow { IOSWorkflow() : super('iOS toolchain - develop for iOS devices'); diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 5e2337a77f..a646650620 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -35,6 +35,8 @@ const PythonModule kPythonSix = const PythonModule('six'); IMobileDevice get iMobileDevice => context.putIfAbsent(IMobileDevice, () => const IMobileDevice()); +Xcode get xcode => context.putIfAbsent(Xcode, () => new Xcode()); + class PythonModule { const PythonModule(this.name); @@ -120,9 +122,6 @@ class Xcode { } } - /// Returns [Xcode] active in the current app context. - static Xcode get instance => context.putIfAbsent(Xcode, () => new Xcode()); - bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory; String _xcodeSelectPath; diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index e5f37acf37..5a57b382db 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -45,7 +45,7 @@ class IOSSimulatorUtils { static IOSSimulatorUtils get instance => context[IOSSimulatorUtils]; List getAttachedDevices() { - if (!Xcode.instance.isInstalledAndMeetsVersionCheck) + if (!xcode.isInstalledAndMeetsVersionCheck) return []; return SimControl.instance.getConnectedDevices().map((SimDevice device) { @@ -587,8 +587,7 @@ class IOSSimulator extends Device { } bool get _xcodeVersionSupportsScreenshot { - return Xcode.instance.xcodeMajorVersion > 8 || - (Xcode.instance.xcodeMajorVersion == 8 && Xcode.instance.xcodeMinorVersion >= 2); + return xcode.xcodeMajorVersion > 8 || (xcode.xcodeMajorVersion == 8 && xcode.xcodeMinorVersion >= 2); } @override