Unverified Commit 0f9d66aa authored by Kevin Moore's avatar Kevin Moore Committed by GitHub

tool: use switch expressions (#125930)

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