switch statement cleanup (#148382)

This PR is step 12 in the journey to solve issue #136139 and make the
entire Flutter repo more readable.

Most of it involves implementing switch expressions, and there's also a
few other random things that I wanted to clean up a bit.
This commit is contained in:
Nate
2024-05-16 18:16:06 -06:00
committed by GitHub
parent c4ad1dc1e9
commit fa9992eff6
39 changed files with 301 additions and 529 deletions

View File

@@ -325,26 +325,18 @@ enum SourceElementType {
unknownType,
}
/// Converts the enun type [SourceElementType] to a human readable string.
/// Converts the enum type [SourceElementType] to a human readable string.
String sourceElementTypeAsString(SourceElementType type) {
switch (type) {
case SourceElementType.classType:
return 'class';
case SourceElementType.fieldType:
return 'field';
case SourceElementType.methodType:
return 'method';
case SourceElementType.constructorType:
return 'constructor';
case SourceElementType.typedefType:
return 'typedef';
case SourceElementType.topLevelVariableType:
return 'variable';
case SourceElementType.functionType:
return 'function';
case SourceElementType.unknownType:
return 'unknown';
}
return switch (type) {
SourceElementType.classType => 'class',
SourceElementType.fieldType => 'field',
SourceElementType.methodType => 'method',
SourceElementType.constructorType => 'constructor',
SourceElementType.typedefType => 'typedef',
SourceElementType.topLevelVariableType => 'variable',
SourceElementType.functionType => 'function',
SourceElementType.unknownType => 'unknown',
};
}
/// A class that represents a Dart element in a source file.