Commit c04f712a authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

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.
parent d6ec71d2
...@@ -177,7 +177,7 @@ class RunCommand extends RunCommandBase { ...@@ -177,7 +177,7 @@ class RunCommand extends RunCommandBase {
void printNoConnectedDevices() { void printNoConnectedDevices() {
super.printNoConnectedDevices(); super.printNoConnectedDevices();
if (getCurrentHostPlatform() == HostPlatform.darwin_x64 && if (getCurrentHostPlatform() == HostPlatform.darwin_x64 &&
Xcode.instance.isInstalledAndMeetsVersionCheck) { xcode.isInstalledAndMeetsVersionCheck) {
printStatus(''); printStatus('');
printStatus('To run on a simulator, launch it first: open -a Simulator.app'); printStatus('To run on a simulator, launch it first: open -a Simulator.app');
printStatus(''); printStatus('');
......
...@@ -16,8 +16,6 @@ import 'mac.dart'; ...@@ -16,8 +16,6 @@ import 'mac.dart';
IOSWorkflow get iosWorkflow => context.putIfAbsent(IOSWorkflow, () => new IOSWorkflow()); IOSWorkflow get iosWorkflow => context.putIfAbsent(IOSWorkflow, () => new IOSWorkflow());
Xcode get xcode => Xcode.instance;
class IOSWorkflow extends DoctorValidator implements Workflow { class IOSWorkflow extends DoctorValidator implements Workflow {
IOSWorkflow() : super('iOS toolchain - develop for iOS devices'); IOSWorkflow() : super('iOS toolchain - develop for iOS devices');
......
...@@ -35,6 +35,8 @@ const PythonModule kPythonSix = const PythonModule('six'); ...@@ -35,6 +35,8 @@ const PythonModule kPythonSix = const PythonModule('six');
IMobileDevice get iMobileDevice => context.putIfAbsent(IMobileDevice, () => const IMobileDevice()); IMobileDevice get iMobileDevice => context.putIfAbsent(IMobileDevice, () => const IMobileDevice());
Xcode get xcode => context.putIfAbsent(Xcode, () => new Xcode());
class PythonModule { class PythonModule {
const PythonModule(this.name); const PythonModule(this.name);
...@@ -120,9 +122,6 @@ class Xcode { ...@@ -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; bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory;
String _xcodeSelectPath; String _xcodeSelectPath;
......
...@@ -45,7 +45,7 @@ class IOSSimulatorUtils { ...@@ -45,7 +45,7 @@ class IOSSimulatorUtils {
static IOSSimulatorUtils get instance => context[IOSSimulatorUtils]; static IOSSimulatorUtils get instance => context[IOSSimulatorUtils];
List<IOSSimulator> getAttachedDevices() { List<IOSSimulator> getAttachedDevices() {
if (!Xcode.instance.isInstalledAndMeetsVersionCheck) if (!xcode.isInstalledAndMeetsVersionCheck)
return <IOSSimulator>[]; return <IOSSimulator>[];
return SimControl.instance.getConnectedDevices().map((SimDevice device) { return SimControl.instance.getConnectedDevices().map((SimDevice device) {
...@@ -587,8 +587,7 @@ class IOSSimulator extends Device { ...@@ -587,8 +587,7 @@ class IOSSimulator extends Device {
} }
bool get _xcodeVersionSupportsScreenshot { bool get _xcodeVersionSupportsScreenshot {
return Xcode.instance.xcodeMajorVersion > 8 || return xcode.xcodeMajorVersion > 8 || (xcode.xcodeMajorVersion == 8 && xcode.xcodeMinorVersion >= 2);
(Xcode.instance.xcodeMajorVersion == 8 && Xcode.instance.xcodeMinorVersion >= 2);
} }
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment