tool: use switch expressions (#125930)
This commit is contained in:
@@ -611,16 +611,11 @@ enum HostPlatform {
|
||||
}
|
||||
|
||||
String getNameForHostPlatform(HostPlatform platform) {
|
||||
switch (platform) {
|
||||
case HostPlatform.darwin_x64:
|
||||
return 'darwin-x64';
|
||||
case HostPlatform.darwin_arm64:
|
||||
return 'darwin-arm64';
|
||||
case HostPlatform.linux_x64:
|
||||
return 'linux-x64';
|
||||
case HostPlatform.linux_arm64:
|
||||
return 'linux-arm64';
|
||||
case HostPlatform.windows_x64:
|
||||
return 'windows-x64';
|
||||
}
|
||||
return switch (platform) {
|
||||
HostPlatform.darwin_x64 => 'darwin-x64',
|
||||
HostPlatform.darwin_arm64 => 'darwin-arm64',
|
||||
HostPlatform.linux_x64 => 'linux-x64',
|
||||
HostPlatform.linux_arm64 => 'linux-arm64',
|
||||
HostPlatform.windows_x64 => 'windows-x64'
|
||||
};
|
||||
}
|
||||
|
||||
@@ -614,14 +614,11 @@ List<DarwinArch> defaultMacOSArchsForEnvironment(Artifacts artifacts) {
|
||||
// instructions are then built into architecture-specific binaries, which are
|
||||
// merged into a universal binary using the `lipo` tool.
|
||||
String getDartNameForDarwinArch(DarwinArch arch) {
|
||||
switch (arch) {
|
||||
case DarwinArch.armv7:
|
||||
return 'armv7';
|
||||
case DarwinArch.arm64:
|
||||
return 'arm64';
|
||||
case DarwinArch.x86_64:
|
||||
return 'x64';
|
||||
}
|
||||
return switch (arch) {
|
||||
DarwinArch.armv7 => 'armv7',
|
||||
DarwinArch.arm64 => 'arm64',
|
||||
DarwinArch.x86_64 => 'x64'
|
||||
};
|
||||
}
|
||||
|
||||
// Returns Apple's name for the specified target architecture.
|
||||
@@ -633,14 +630,11 @@ String getDartNameForDarwinArch(DarwinArch arch) {
|
||||
// For consistency with developer expectations, Flutter outputs also use these
|
||||
// architecture names in its build products for Darwin target platforms.
|
||||
String getNameForDarwinArch(DarwinArch arch) {
|
||||
switch (arch) {
|
||||
case DarwinArch.armv7:
|
||||
return 'armv7';
|
||||
case DarwinArch.arm64:
|
||||
return 'arm64';
|
||||
case DarwinArch.x86_64:
|
||||
return 'x86_64';
|
||||
}
|
||||
return switch (arch) {
|
||||
DarwinArch.armv7 => 'armv7',
|
||||
DarwinArch.arm64 => 'arm64',
|
||||
DarwinArch.x86_64 => 'x86_64'
|
||||
};
|
||||
}
|
||||
|
||||
DarwinArch getIOSArchForName(String arch) {
|
||||
@@ -758,29 +752,21 @@ AndroidArch getAndroidArchForName(String platform) {
|
||||
}
|
||||
|
||||
String getNameForAndroidArch(AndroidArch arch) {
|
||||
switch (arch) {
|
||||
case AndroidArch.armeabi_v7a:
|
||||
return 'armeabi-v7a';
|
||||
case AndroidArch.arm64_v8a:
|
||||
return 'arm64-v8a';
|
||||
case AndroidArch.x86_64:
|
||||
return 'x86_64';
|
||||
case AndroidArch.x86:
|
||||
return 'x86';
|
||||
}
|
||||
return switch (arch) {
|
||||
AndroidArch.armeabi_v7a => 'armeabi-v7a',
|
||||
AndroidArch.arm64_v8a => 'arm64-v8a',
|
||||
AndroidArch.x86_64 => 'x86_64',
|
||||
AndroidArch.x86 => 'x86'
|
||||
};
|
||||
}
|
||||
|
||||
String getPlatformNameForAndroidArch(AndroidArch arch) {
|
||||
switch (arch) {
|
||||
case AndroidArch.armeabi_v7a:
|
||||
return 'android-arm';
|
||||
case AndroidArch.arm64_v8a:
|
||||
return 'android-arm64';
|
||||
case AndroidArch.x86_64:
|
||||
return 'android-x64';
|
||||
case AndroidArch.x86:
|
||||
return 'android-x86';
|
||||
}
|
||||
return switch (arch) {
|
||||
AndroidArch.armeabi_v7a => 'android-arm',
|
||||
AndroidArch.arm64_v8a => 'android-arm64',
|
||||
AndroidArch.x86_64 => 'android-x64',
|
||||
AndroidArch.x86 => 'android-x86'
|
||||
};
|
||||
}
|
||||
|
||||
String fuchsiaArchForTargetPlatform(TargetPlatform targetPlatform) {
|
||||
@@ -1059,18 +1045,13 @@ String getNameForTargetPlatformArch(TargetPlatform platform) {
|
||||
}
|
||||
|
||||
String getNameForHostPlatformArch(HostPlatform platform) {
|
||||
switch (platform) {
|
||||
case HostPlatform.darwin_x64:
|
||||
return 'x64';
|
||||
case HostPlatform.darwin_arm64:
|
||||
return 'arm64';
|
||||
case HostPlatform.linux_x64:
|
||||
return 'x64';
|
||||
case HostPlatform.linux_arm64:
|
||||
return 'arm64';
|
||||
case HostPlatform.windows_x64:
|
||||
return 'x64';
|
||||
}
|
||||
return switch (platform) {
|
||||
HostPlatform.darwin_x64 => 'x64',
|
||||
HostPlatform.darwin_arm64 => 'arm64',
|
||||
HostPlatform.linux_x64 => 'x64',
|
||||
HostPlatform.linux_arm64 => 'arm64',
|
||||
HostPlatform.windows_x64 => 'x64'
|
||||
};
|
||||
}
|
||||
|
||||
String? _uncapitalize(String? s) {
|
||||
|
||||
@@ -1160,18 +1160,13 @@ class InvalidatedReason {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
switch (kind) {
|
||||
case InvalidatedReasonKind.inputMissing:
|
||||
return 'The following inputs were missing: ${data.join(',')}';
|
||||
case InvalidatedReasonKind.inputChanged:
|
||||
return 'The following inputs have updated contents: ${data.join(',')}';
|
||||
case InvalidatedReasonKind.outputChanged:
|
||||
return 'The following outputs have updated contents: ${data.join(',')}';
|
||||
case InvalidatedReasonKind.outputMissing:
|
||||
return 'The following outputs were missing: ${data.join(',')}';
|
||||
case InvalidatedReasonKind.outputSetChanged:
|
||||
return 'The following outputs were removed from the output set: ${data.join(',')}';
|
||||
}
|
||||
return switch (kind) {
|
||||
InvalidatedReasonKind.inputMissing => 'The following inputs were missing: ${data.join(',')}',
|
||||
InvalidatedReasonKind.inputChanged => 'The following inputs have updated contents: ${data.join(',')}',
|
||||
InvalidatedReasonKind.outputChanged => 'The following outputs have updated contents: ${data.join(',')}',
|
||||
InvalidatedReasonKind.outputMissing => 'The following outputs were missing: ${data.join(',')}',
|
||||
InvalidatedReasonKind.outputSetChanged => 'The following outputs were removed from the output set: ${data.join(',')}'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -578,12 +578,10 @@ Future<void> diagnoseXcodeBuildFailure(XcodeBuildResult result, Usage flutterUsa
|
||||
enum XcodeBuildAction { build, archive }
|
||||
|
||||
String xcodeBuildActionToString(XcodeBuildAction action) {
|
||||
switch (action) {
|
||||
case XcodeBuildAction.build:
|
||||
return 'build';
|
||||
case XcodeBuildAction.archive:
|
||||
return 'archive';
|
||||
}
|
||||
return switch (action) {
|
||||
XcodeBuildAction.build => 'build',
|
||||
XcodeBuildAction.archive => 'archive'
|
||||
};
|
||||
}
|
||||
|
||||
class XcodeBuildResult {
|
||||
|
||||
@@ -252,15 +252,11 @@ FlutterProject setUpFlutterProject(Directory directory) {
|
||||
class FakeMacOSApp extends Fake implements MacOSApp {
|
||||
@override
|
||||
String executable(BuildInfo buildInfo) {
|
||||
switch (buildInfo) {
|
||||
case BuildInfo.debug:
|
||||
return 'debug/executable';
|
||||
case BuildInfo.profile:
|
||||
return 'profile/executable';
|
||||
case BuildInfo.release:
|
||||
return 'release/executable';
|
||||
default:
|
||||
throw StateError('');
|
||||
}
|
||||
return switch (buildInfo) {
|
||||
BuildInfo.debug => 'debug/executable',
|
||||
BuildInfo.profile => 'profile/executable',
|
||||
BuildInfo.release => 'release/executable',
|
||||
_ => throw StateError('')
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,20 +40,14 @@ HttpMethod _fromMethodString(String value) {
|
||||
}
|
||||
|
||||
String _toMethodString(HttpMethod method) {
|
||||
switch (method) {
|
||||
case HttpMethod.get:
|
||||
return 'GET';
|
||||
case HttpMethod.put:
|
||||
return 'PUT';
|
||||
case HttpMethod.delete:
|
||||
return 'DELETE';
|
||||
case HttpMethod.post:
|
||||
return 'POST';
|
||||
case HttpMethod.patch:
|
||||
return 'PATCH';
|
||||
case HttpMethod.head:
|
||||
return 'HEAD';
|
||||
}
|
||||
return switch (method) {
|
||||
HttpMethod.get => 'GET',
|
||||
HttpMethod.put => 'PUT',
|
||||
HttpMethod.delete => 'DELETE',
|
||||
HttpMethod.post => 'POST',
|
||||
HttpMethod.patch => 'PATCH',
|
||||
HttpMethod.head => 'HEAD'
|
||||
};
|
||||
}
|
||||
|
||||
/// Create a fake request that configures the [FakeHttpClient] to respond
|
||||
|
||||
Reference in New Issue
Block a user