Unverified Commit d60e9de7 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove remaining extensions (#76743)

parent fe2708c3
...@@ -255,7 +255,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { ...@@ -255,7 +255,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
if (!result.success) { if (!result.success) {
await diagnoseXcodeBuildFailure(result, globals.flutterUsage, globals.logger); await diagnoseXcodeBuildFailure(result, globals.flutterUsage, globals.logger);
throwToolExit('Encountered error while ${xcodeBuildAction.name}ing for $logTarget.'); throwToolExit('Encountered error while ${xcodeBuildActionToString(xcodeBuildAction)}ing for $logTarget.');
} }
if (buildInfo.codeSizeDirectory != null) { if (buildInfo.codeSizeDirectory != null) {
......
...@@ -34,17 +34,17 @@ class CreateCommand extends CreateBase { ...@@ -34,17 +34,17 @@ class CreateCommand extends CreateBase {
argParser.addOption( argParser.addOption(
'template', 'template',
abbr: 't', abbr: 't',
allowed: FlutterProjectType.values.map<String>((FlutterProjectType type) => type.name), allowed: FlutterProjectType.values.map<String>(flutterProjectTypeToString),
help: 'Specify the type of project to create.', help: 'Specify the type of project to create.',
valueHelp: 'type', valueHelp: 'type',
allowedHelp: <String, String>{ allowedHelp: <String, String>{
FlutterProjectType.app.name: '(default) Generate a Flutter application.', flutterProjectTypeToString(FlutterProjectType.app): '(default) Generate a Flutter application.',
FlutterProjectType.package.name: 'Generate a shareable Flutter project containing modular ' flutterProjectTypeToString(FlutterProjectType.package): 'Generate a shareable Flutter project containing modular '
'Dart code.', 'Dart code.',
FlutterProjectType.plugin.name: 'Generate a shareable Flutter project containing an API ' flutterProjectTypeToString(FlutterProjectType.plugin): 'Generate a shareable Flutter project containing an API '
'in Dart code with a platform-specific implementation for Android, for iOS code, or ' 'in Dart code with a platform-specific implementation for Android, for iOS code, or '
'for both.', 'for both.',
FlutterProjectType.module.name: 'Generate a project to add a Flutter module to an ' flutterProjectTypeToString(FlutterProjectType.module): 'Generate a project to add a Flutter module to an '
'existing Android or iOS application.', 'existing Android or iOS application.',
}, },
defaultsTo: null, defaultsTo: null,
...@@ -168,8 +168,8 @@ class CreateCommand extends CreateBase { ...@@ -168,8 +168,8 @@ class CreateCommand extends CreateBase {
if (detectedProjectType != null && template != detectedProjectType && metadataExists) { if (detectedProjectType != null && template != detectedProjectType && metadataExists) {
// We can only be definitive that this is the wrong type if the .metadata file // We can only be definitive that this is the wrong type if the .metadata file
// exists and contains a type that doesn't match. // exists and contains a type that doesn't match.
throwToolExit("The requested template type '${template.name}' doesn't match the " throwToolExit("The requested template type '${flutterProjectTypeToString(template)}' doesn't match the "
"existing template type of '${detectedProjectType.name}'."); "existing template type of '${flutterProjectTypeToString(detectedProjectType)}'.");
} }
return template; return template;
} }
...@@ -189,7 +189,7 @@ class CreateCommand extends CreateBase { ...@@ -189,7 +189,7 @@ class CreateCommand extends CreateBase {
if (argResults['template'] != null && if (argResults['template'] != null &&
stringToProjectType(stringArg('template') ?? 'app') != FlutterProjectType.app) { stringToProjectType(stringArg('template') ?? 'app') != FlutterProjectType.app) {
throwToolExit('Cannot specify --sample with a project type other than ' throwToolExit('Cannot specify --sample with a project type other than '
'"${FlutterProjectType.app.name}"'); '"${flutterProjectTypeToString(FlutterProjectType.app)}"');
} }
// Fetch the sample from the server. // Fetch the sample from the server.
sampleCode = await _fetchSampleFromServer(stringArg('sample')); sampleCode = await _fetchSampleFromServer(stringArg('sample'));
......
...@@ -25,14 +25,14 @@ enum FlutterProjectType { ...@@ -25,14 +25,14 @@ enum FlutterProjectType {
plugin, plugin,
} }
extension FlutterProjectTypeExtension on FlutterProjectType { String flutterProjectTypeToString(FlutterProjectType type) {
String get name => getEnumName(this); return getEnumName(type);
} }
FlutterProjectType stringToProjectType(String value) { FlutterProjectType stringToProjectType(String value) {
FlutterProjectType result; FlutterProjectType result;
for (final FlutterProjectType type in FlutterProjectType.values) { for (final FlutterProjectType type in FlutterProjectType.values) {
if (value == type.name) { if (value == flutterProjectTypeToString(type)) {
result = type; result = type;
break; break;
} }
......
...@@ -346,10 +346,10 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -346,10 +346,10 @@ Future<XcodeBuildResult> buildXcodeProject({
initialBuildStatus?.cancel(); initialBuildStatus?.cancel();
initialBuildStatus = null; initialBuildStatus = null;
globals.printStatus( globals.printStatus(
'Xcode ${buildAction.name} done.'.padRight(kDefaultStatusPadding + 1) 'Xcode ${xcodeBuildActionToString(buildAction)} done.'.padRight(kDefaultStatusPadding + 1)
+ getElapsedAsSeconds(sw.elapsed).padLeft(5), + getElapsedAsSeconds(sw.elapsed).padLeft(5),
); );
globals.flutterUsage.sendTiming(buildAction.name, 'xcode-ios', Duration(milliseconds: sw.elapsedMilliseconds)); globals.flutterUsage.sendTiming(xcodeBuildActionToString(buildAction), 'xcode-ios', Duration(milliseconds: sw.elapsedMilliseconds));
// Run -showBuildSettings again but with the exact same parameters as the // Run -showBuildSettings again but with the exact same parameters as the
// build. showBuildSettings is reported to occasionally timeout. Here, we give // build. showBuildSettings is reported to occasionally timeout. Here, we give
...@@ -592,9 +592,8 @@ Future<void> diagnoseXcodeBuildFailure(XcodeBuildResult result, Usage flutterUsa ...@@ -592,9 +592,8 @@ Future<void> diagnoseXcodeBuildFailure(XcodeBuildResult result, Usage flutterUsa
/// `clean`, `test`, `analyze`, and `install` are not supported. /// `clean`, `test`, `analyze`, and `install` are not supported.
enum XcodeBuildAction { build, archive } enum XcodeBuildAction { build, archive }
extension XcodeBuildActionExtension on XcodeBuildAction { String xcodeBuildActionToString(XcodeBuildAction action) {
String get name { switch (action) {
switch (this) {
case XcodeBuildAction.build: case XcodeBuildAction.build:
return 'build'; return 'build';
case XcodeBuildAction.archive: case XcodeBuildAction.archive:
...@@ -602,7 +601,6 @@ extension XcodeBuildActionExtension on XcodeBuildAction { ...@@ -602,7 +601,6 @@ extension XcodeBuildActionExtension on XcodeBuildAction {
default: default:
throw UnsupportedError('Unknown Xcode build action'); throw UnsupportedError('Unknown Xcode build action');
} }
}
} }
class XcodeBuildResult { class XcodeBuildResult {
......
...@@ -121,7 +121,7 @@ ${_projectMetadataInformation()} ...@@ -121,7 +121,7 @@ ${_projectMetadataInformation()}
} }
final FlutterProjectMetadata metadata = FlutterProjectMetadata(project.metadataFile, _logger); final FlutterProjectMetadata metadata = FlutterProjectMetadata(project.metadataFile, _logger);
final StringBuffer description = StringBuffer() final StringBuffer description = StringBuffer()
..writeln('**Type**: ${metadata.projectType?.name}') ..writeln('**Type**: ${flutterProjectTypeToString(metadata.projectType)}')
..writeln('**Version**: ${manifest.appVersion}') ..writeln('**Version**: ${manifest.appVersion}')
..writeln('**Material**: ${manifest.usesMaterialDesign}') ..writeln('**Material**: ${manifest.usesMaterialDesign}')
..writeln('**Android X**: ${manifest.usesAndroidX}') ..writeln('**Android X**: ${manifest.usesAndroidX}')
......
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