implicit-casts:false in dev (#45787)
This commit is contained in:
committed by
GitHub
parent
fa0c49d775
commit
ec1a015045
@@ -31,7 +31,7 @@ const String kSnippetsRoot = 'dev/snippets';
|
||||
Future<void> main(List<String> arguments) async {
|
||||
final ArgParser argParser = _createArgsParser();
|
||||
final ArgResults args = argParser.parse(arguments);
|
||||
if (args['help']) {
|
||||
if (args['help'] as bool) {
|
||||
print ('Usage:');
|
||||
print (argParser.usage);
|
||||
exit(0);
|
||||
@@ -111,7 +111,7 @@ Future<void> main(List<String> arguments) async {
|
||||
final List<String> dartdocBaseArgs = <String>[
|
||||
'global',
|
||||
'run',
|
||||
if (args['checked']) '-c',
|
||||
if (args['checked'] as bool) '-c',
|
||||
'dartdoc',
|
||||
];
|
||||
|
||||
@@ -130,8 +130,8 @@ Future<void> main(List<String> arguments) async {
|
||||
final List<String> dartdocArgs = <String>[
|
||||
...dartdocBaseArgs,
|
||||
'--allow-tools',
|
||||
if (args['json']) '--json',
|
||||
if (args['validate-links']) '--validate-links' else '--no-validate-links',
|
||||
if (args['json'] as bool) '--json',
|
||||
if (args['validate-links'] as bool) '--validate-links' else '--no-validate-links',
|
||||
'--link-to-source-excludes', '../../bin/cache',
|
||||
'--link-to-source-root', '../..',
|
||||
'--link-to-source-uri-template', 'https://github.com/flutter/flutter/blob/master/%f%#L%l%',
|
||||
@@ -207,14 +207,14 @@ Future<void> main(List<String> arguments) async {
|
||||
workingDirectory: kDocsRoot,
|
||||
environment: pubEnvironment,
|
||||
));
|
||||
printStream(process.stdout, prefix: args['json'] ? '' : 'dartdoc:stdout: ',
|
||||
filter: args['verbose'] ? const <Pattern>[] : <Pattern>[
|
||||
printStream(process.stdout, prefix: args['json'] as bool ? '' : 'dartdoc:stdout: ',
|
||||
filter: args['verbose'] as bool ? const <Pattern>[] : <Pattern>[
|
||||
RegExp(r'^generating docs for library '), // unnecessary verbosity
|
||||
RegExp(r'^pars'), // unnecessary verbosity
|
||||
],
|
||||
);
|
||||
printStream(process.stderr, prefix: args['json'] ? '' : 'dartdoc:stderr: ',
|
||||
filter: args['verbose'] ? const <Pattern>[] : <Pattern>[
|
||||
printStream(process.stderr, prefix: args['json'] as bool ? '' : 'dartdoc:stderr: ',
|
||||
filter: args['verbose'] as bool ? const <Pattern>[] : <Pattern>[
|
||||
RegExp(r'^ warning: .+: \(.+/\.pub-cache/hosted/pub.dartlang.org/.+\)'), // packages outside our control
|
||||
],
|
||||
);
|
||||
@@ -252,7 +252,7 @@ String getBranchName() {
|
||||
if (gitResult.exitCode != 0)
|
||||
throw 'git status exit with non-zero exit code: ${gitResult.exitCode}';
|
||||
final Match gitBranchMatch = gitBranchRegexp.firstMatch(
|
||||
gitResult.stdout.trim().split('\n').first);
|
||||
(gitResult.stdout as String).trim().split('\n').first);
|
||||
return gitBranchMatch == null ? '' : gitBranchMatch.group(1).split('...').first;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ String gitRevision() {
|
||||
final ProcessResult gitResult = Process.runSync('git', <String>['rev-parse', 'HEAD']);
|
||||
if (gitResult.exitCode != 0)
|
||||
throw 'git rev-parse exit with non-zero exit code: ${gitResult.exitCode}';
|
||||
final String gitRevision = gitResult.stdout.trim();
|
||||
final String gitRevision = (gitResult.stdout as String).trim();
|
||||
|
||||
return gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision;
|
||||
}
|
||||
@@ -454,7 +454,7 @@ List<String> findPackageNames() {
|
||||
}
|
||||
|
||||
/// Finds all packages in the Flutter SDK
|
||||
List<FileSystemEntity> findPackages() {
|
||||
List<Directory> findPackages() {
|
||||
return Directory('packages')
|
||||
.listSync()
|
||||
.where((FileSystemEntity entity) {
|
||||
|
||||
@@ -132,61 +132,61 @@ Future<void> main(List<String> rawArguments) async {
|
||||
|
||||
final ArgResults parsedArguments = argParser.parse(rawArguments);
|
||||
|
||||
if (parsedArguments['help']) {
|
||||
if (parsedArguments['help'] as bool) {
|
||||
print(argParser.usage);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
KeyData data;
|
||||
if (parsedArguments['collect']) {
|
||||
if (parsedArguments['collect'] as bool) {
|
||||
String hidCodes;
|
||||
if (parsedArguments['chromium-hid-codes'] == null) {
|
||||
hidCodes = await getChromiumConversions();
|
||||
} else {
|
||||
hidCodes = File(parsedArguments['chromium-hid-codes']).readAsStringSync();
|
||||
hidCodes = File(parsedArguments['chromium-hid-codes'] as String).readAsStringSync();
|
||||
}
|
||||
|
||||
final String supplementalHidCodes = File(parsedArguments['supplemental-hid-codes']).readAsStringSync();
|
||||
final String supplementalHidCodes = File(parsedArguments['supplemental-hid-codes'] as String).readAsStringSync();
|
||||
hidCodes = '$hidCodes\n$supplementalHidCodes';
|
||||
|
||||
String androidKeyCodes;
|
||||
if (parsedArguments['android-keycodes'] == null) {
|
||||
androidKeyCodes = await getAndroidKeyCodes();
|
||||
} else {
|
||||
androidKeyCodes = File(parsedArguments['android-keycodes']).readAsStringSync();
|
||||
androidKeyCodes = File(parsedArguments['android-keycodes'] as String).readAsStringSync();
|
||||
}
|
||||
|
||||
String androidScanCodes;
|
||||
if (parsedArguments['android-scancodes'] == null) {
|
||||
androidScanCodes = await getAndroidScanCodes();
|
||||
} else {
|
||||
androidScanCodes = File(parsedArguments['android-scancodes']).readAsStringSync();
|
||||
androidScanCodes = File(parsedArguments['android-scancodes'] as String).readAsStringSync();
|
||||
}
|
||||
|
||||
String glfwKeyCodes;
|
||||
if (parsedArguments['glfw-keycodes'] == null) {
|
||||
glfwKeyCodes = await getGlfwKeyCodes();
|
||||
} else {
|
||||
glfwKeyCodes = File(parsedArguments['glfw-keycodes']).readAsStringSync();
|
||||
glfwKeyCodes = File(parsedArguments['glfw-keycodes'] as String).readAsStringSync();
|
||||
}
|
||||
|
||||
final String glfwToDomKey = File(parsedArguments['glfw-domkey']).readAsStringSync();
|
||||
final String androidToDomKey = File(parsedArguments['android-domkey']).readAsStringSync();
|
||||
final String glfwToDomKey = File(parsedArguments['glfw-domkey'] as String).readAsStringSync();
|
||||
final String androidToDomKey = File(parsedArguments['android-domkey'] as String).readAsStringSync();
|
||||
|
||||
data = KeyData(hidCodes, androidScanCodes, androidKeyCodes, androidToDomKey, glfwKeyCodes, glfwToDomKey);
|
||||
|
||||
const JsonEncoder encoder = JsonEncoder.withIndent(' ');
|
||||
File(parsedArguments['data']).writeAsStringSync(encoder.convert(data.toJson()));
|
||||
File(parsedArguments['data'] as String).writeAsStringSync(encoder.convert(data.toJson()));
|
||||
} else {
|
||||
data = KeyData.fromJson(json.decode(await File(parsedArguments['data']).readAsString()));
|
||||
data = KeyData.fromJson(json.decode(await File(parsedArguments['data'] as String).readAsString()) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
final File codeFile = File(parsedArguments['code']);
|
||||
final File codeFile = File(parsedArguments['code'] as String);
|
||||
if (!codeFile.existsSync()) {
|
||||
codeFile.createSync(recursive: true);
|
||||
}
|
||||
|
||||
final File mapsFile = File(parsedArguments['maps']);
|
||||
final File mapsFile = File(parsedArguments['maps'] as String);
|
||||
if (!mapsFile.existsSync()) {
|
||||
mapsFile.createSync(recursive: true);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ $otherComments static const LogicalKeyboardKey $constantName = LogicalKeyboardK
|
||||
// plane.
|
||||
final Key entry = keyData.data.firstWhere((Key item) => item.name == Key.synonyms[name][0]);
|
||||
final Set<String> unionNames = Key.synonyms[name].map<String>((dynamic name) {
|
||||
return upperCamelToLowerCamel(name);
|
||||
return upperCamelToLowerCamel(name as String);
|
||||
}).toSet();
|
||||
printKey(Key.synonymPlane | entry.flutterId, entry.keyLabel, name, Key.getCommentName(name),
|
||||
otherComments: wrapString('This key represents the union of the keys '
|
||||
@@ -100,7 +100,7 @@ $otherComments static const LogicalKeyboardKey $constantName = LogicalKeyboardK
|
||||
String get logicalSynonyms {
|
||||
final StringBuffer synonyms = StringBuffer();
|
||||
for (String name in Key.synonyms.keys) {
|
||||
for (String synonym in Key.synonyms[name]) {
|
||||
for (String synonym in Key.synonyms[name].cast<String>()) {
|
||||
final String keyName = upperCamelToLowerCamel(synonym);
|
||||
synonyms.writeln(' $keyName: $name,');
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ class KeyData {
|
||||
_nameToAndroidKeyCode = _readAndroidKeyCodes(androidKeyCodeHeader);
|
||||
_nameToGlfwKeyCode = _readGlfwKeyCodes(glfwKeyCodeHeader);
|
||||
// Cast Android dom map
|
||||
final Map<String, List<dynamic>> dynamicAndroidNames = json.decode(androidNameMap).cast<String, List<dynamic>>();
|
||||
final Map<String, List<dynamic>> dynamicAndroidNames = (json.decode(androidNameMap) as Map<String, List<dynamic>>).cast<String, List<dynamic>>();
|
||||
_nameToAndroidName = dynamicAndroidNames.map<String, List<String>>((String key, List<dynamic> value) {
|
||||
return MapEntry<String, List<String>>(key, value.cast<String>());
|
||||
});
|
||||
// Cast GLFW dom map
|
||||
final Map<String, List<dynamic>> dynamicGlfwNames = json.decode(glfwNameMap).cast<String, List<dynamic>>();
|
||||
final Map<String, List<dynamic>> dynamicGlfwNames = (json.decode(glfwNameMap) as Map<String, List<dynamic>>).cast<String, List<dynamic>>();
|
||||
_nameToGlfwName = dynamicGlfwNames.map<String, List<String>>((String key, List<dynamic> value) {
|
||||
return MapEntry<String, List<String>>(key, value.cast<String>());
|
||||
});
|
||||
@@ -53,7 +53,7 @@ class KeyData {
|
||||
/// Parses the given JSON data and populates the data structure from it.
|
||||
KeyData.fromJson(Map<String, dynamic> contentMap) {
|
||||
data = <Key>[
|
||||
for (String key in contentMap.keys) Key.fromJsonMapEntry(key, contentMap[key]),
|
||||
for (String key in contentMap.keys) Key.fromJsonMapEntry(key, contentMap[key] as Map<String, List<dynamic>>),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ class KeyData {
|
||||
replaced.forEach((String key, dynamic value) {
|
||||
// Some definition values point to other definitions (e.g #define GLFW_KEY_LAST GLFW_KEY_MENU).
|
||||
if (value is String) {
|
||||
result[key] = replaced[value];
|
||||
result[key] = replaced[value] as int;
|
||||
} else {
|
||||
result[key] = value;
|
||||
result[key] = value as int;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
@@ -285,18 +285,18 @@ class Key {
|
||||
factory Key.fromJsonMapEntry(String name, Map<String, dynamic> map) {
|
||||
return Key(
|
||||
enumName: name,
|
||||
name: map['names']['domkey'],
|
||||
chromiumName: map['names']['chromium'],
|
||||
usbHidCode: map['scanCodes']['usb'],
|
||||
androidKeyNames: map['names']['android']?.cast<String>(),
|
||||
androidScanCodes: map['scanCodes']['android']?.cast<int>(),
|
||||
androidKeyCodes: map['keyCodes']['android']?.cast<int>(),
|
||||
linuxScanCode: map['scanCodes']['linux'],
|
||||
xKbScanCode: map['scanCodes']['xkb'],
|
||||
windowsScanCode: map['scanCodes']['windows'],
|
||||
macOsScanCode: map['scanCodes']['macos'],
|
||||
glfwKeyNames: map['names']['glfw']?.cast<String>(),
|
||||
glfwKeyCodes: map['keyCodes']['glfw']?.cast<int>(),
|
||||
name: map['names']['domkey'] as String,
|
||||
chromiumName: map['names']['chromium'] as String,
|
||||
usbHidCode: map['scanCodes']['usb'] as int,
|
||||
androidKeyNames: (map['names']['android'] as List<dynamic>)?.cast<String>(),
|
||||
androidScanCodes: (map['scanCodes']['android'] as List<dynamic>)?.cast<int>(),
|
||||
androidKeyCodes: (map['keyCodes']['android'] as List<dynamic>)?.cast<int>(),
|
||||
linuxScanCode: map['scanCodes']['linux'] as int,
|
||||
xKbScanCode: map['scanCodes']['xkb'] as int,
|
||||
windowsScanCode: map['scanCodes']['windows'] as int,
|
||||
macOsScanCode: map['scanCodes']['macos'] as int,
|
||||
glfwKeyNames: (map['names']['glfw'] as List<dynamic>)?.cast<String>(),
|
||||
glfwKeyCodes: (map['keyCodes']['glfw'] as List<dynamic>)?.cast<int>(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ class Key {
|
||||
static Map<String, String> get printable {
|
||||
if (_printable == null) {
|
||||
final String printableKeys = File(path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'printable.json',)).readAsStringSync();
|
||||
final Map<String, dynamic> printable = json.decode(printableKeys);
|
||||
final Map<String, dynamic> printable = json.decode(printableKeys) as Map<String, dynamic>;
|
||||
_printable = printable.cast<String, String>();
|
||||
}
|
||||
return _printable;
|
||||
@@ -442,7 +442,7 @@ class Key {
|
||||
static Map<String, List<dynamic>> get synonyms {
|
||||
if (_synonym == null) {
|
||||
final String synonymKeys = File(path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'synonyms.json',)).readAsStringSync();
|
||||
final Map<String, dynamic> synonym = json.decode(synonymKeys);
|
||||
final Map<String, dynamic> synonym = json.decode(synonymKeys) as Map<String, dynamic>;
|
||||
_synonym = synonym.cast<String, List<dynamic>>();
|
||||
}
|
||||
return _synonym;
|
||||
|
||||
@@ -60,7 +60,7 @@ Future<void> generateDocs(String url, String docName, String checkFile) async {
|
||||
if (!af.name.endsWith('/')) {
|
||||
final File file = File('${output.path}/${af.name}');
|
||||
file.createSync(recursive: true);
|
||||
file.writeAsBytesSync(af.content);
|
||||
file.writeAsBytesSync(af.content as List<int>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ void main(List<String> args) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
final String level = argResults[kIncrement];
|
||||
final String commit = argResults[kCommit];
|
||||
final String origin = argResults[kOrigin];
|
||||
final bool justPrint = argResults[kJustPrint];
|
||||
final bool autoApprove = argResults[kYes];
|
||||
final bool help = argResults[kHelp];
|
||||
final String level = argResults[kIncrement] as String;
|
||||
final String commit = argResults[kCommit] as String;
|
||||
final String origin = argResults[kOrigin] as String;
|
||||
final bool justPrint = argResults[kJustPrint] as bool;
|
||||
final bool autoApprove = argResults[kYes] as bool;
|
||||
final bool help = argResults[kHelp] as bool;
|
||||
|
||||
if (help || level == null) {
|
||||
print('roll_dev.dart --increment=level --commit=hash • update the version tags and roll a new dev build.\n');
|
||||
@@ -174,8 +174,8 @@ Match parseFullTag(String version) {
|
||||
|
||||
String getGitOutput(String command, String explanation) {
|
||||
final ProcessResult result = _runGit(command);
|
||||
if (result.stderr.isEmpty && result.exitCode == 0)
|
||||
return result.stdout.trim();
|
||||
if ((result.stderr as String).isEmpty && result.exitCode == 0)
|
||||
return (result.stdout as String).trim();
|
||||
_reportGitFailureAndExit(result, explanation);
|
||||
return null; // for the analyzer's sake
|
||||
}
|
||||
@@ -196,9 +196,9 @@ void _reportGitFailureAndExit(ProcessResult result, String explanation) {
|
||||
} else {
|
||||
print('Failed to $explanation.');
|
||||
}
|
||||
if (result.stdout.isNotEmpty)
|
||||
if ((result.stdout as String).isNotEmpty)
|
||||
print('stdout from git:\n${result.stdout}\n');
|
||||
if (result.stderr.isNotEmpty)
|
||||
if ((result.stderr as String).isNotEmpty)
|
||||
print('stderr from git:\n${result.stderr}\n');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import 'localizations_utils.dart';
|
||||
Map<String, dynamic> loadBundle(File file) {
|
||||
if (!FileSystemEntity.isFileSync(file.path))
|
||||
exitWithError('Unable to find input file: ${file.path}');
|
||||
return json.decode(file.readAsStringSync());
|
||||
return json.decode(file.readAsStringSync()) as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
void encodeBundleTranslations(Map<String, dynamic> bundle) {
|
||||
@@ -41,7 +41,7 @@ void encodeBundleTranslations(Map<String, dynamic> bundle) {
|
||||
// to encode them.
|
||||
if (key.startsWith('@'))
|
||||
continue;
|
||||
final String translation = bundle[key];
|
||||
final String translation = bundle[key] as String;
|
||||
// Rewrite the string as a series of unicode characters in JSON format.
|
||||
// Like "\u0012\u0123\u1234".
|
||||
bundle[key] = translation.runes.map((int code) {
|
||||
|
||||
@@ -108,7 +108,7 @@ Future<void> main(List<String> rawArgs) async {
|
||||
buffer.writeln('const Map<String, Map<String, String>> datePatterns = <String, Map<String, String>> {');
|
||||
patternFiles.forEach((String locale, File data) {
|
||||
if (_supportedLocales().contains(locale)) {
|
||||
final Map<String, dynamic> patterns = json.decode(data.readAsStringSync());
|
||||
final Map<String, dynamic> patterns = json.decode(data.readAsStringSync()) as Map<String, dynamic>;
|
||||
buffer.writeln("'$locale': <String, String>{");
|
||||
patterns.forEach((String key, dynamic value) {
|
||||
assert(value is String);
|
||||
@@ -177,12 +177,13 @@ Set<String> _supportedLocales() {
|
||||
|
||||
Map<String, File> _listIntlData(Directory directory) {
|
||||
final Map<String, File> localeFiles = <String, File>{};
|
||||
for (FileSystemEntity entity in directory.listSync()) {
|
||||
final String filePath = entity.path;
|
||||
if (FileSystemEntity.isFileSync(filePath) && filePath.endsWith('.json')) {
|
||||
final String locale = path.basenameWithoutExtension(filePath);
|
||||
localeFiles[locale] = entity;
|
||||
}
|
||||
final Iterable<File> files = directory
|
||||
.listSync()
|
||||
.whereType<File>()
|
||||
.where((File file) => file.path.endsWith('.json'));
|
||||
for (File file in files) {
|
||||
final String locale = path.basenameWithoutExtension(file.path);
|
||||
localeFiles[locale] = file;
|
||||
}
|
||||
|
||||
final List<String> locales = localeFiles.keys.toList(growable: false);
|
||||
|
||||
@@ -154,9 +154,9 @@ int sortFilesByPath (FileSystemEntity a, FileSystemEntity b) {
|
||||
}
|
||||
|
||||
List<String> genMethodParameters(Map<String, dynamic> bundle, String key, String type) {
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'];
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'] as Map<String, dynamic>;
|
||||
if (attributesMap != null && attributesMap.containsKey('placeholders')) {
|
||||
final Map<String, dynamic> placeholders = attributesMap['placeholders'];
|
||||
final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>;
|
||||
return placeholders.keys.map((String parameter) => '$type $parameter').toList();
|
||||
}
|
||||
return <String>[];
|
||||
@@ -164,14 +164,14 @@ List<String> genMethodParameters(Map<String, dynamic> bundle, String key, String
|
||||
|
||||
List<String> genIntlMethodArgs(Map<String, dynamic> bundle, String key) {
|
||||
final List<String> attributes = <String>['name: \'$key\''];
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'];
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'] as Map<String, dynamic>;
|
||||
if (attributesMap != null) {
|
||||
if (attributesMap.containsKey('description')) {
|
||||
final String description = attributesMap['description'];
|
||||
final String description = attributesMap['description'] as String;
|
||||
attributes.add('desc: ${generateString(description)}');
|
||||
}
|
||||
if (attributesMap.containsKey('placeholders')) {
|
||||
final Map<String, dynamic> placeholders = attributesMap['placeholders'];
|
||||
final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>;
|
||||
if (placeholders.isNotEmpty) {
|
||||
final String args = placeholders.keys.join(', ');
|
||||
attributes.add('args: <Object>[$args]');
|
||||
@@ -183,15 +183,15 @@ List<String> genIntlMethodArgs(Map<String, dynamic> bundle, String key) {
|
||||
|
||||
String genSimpleMethod(Map<String, dynamic> bundle, String key) {
|
||||
String genSimpleMethodMessage(Map<String, dynamic> bundle, String key) {
|
||||
String message = bundle[key];
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'];
|
||||
final Map<String, dynamic> placeholders = attributesMap['placeholders'];
|
||||
String message = bundle[key] as String;
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'] as Map<String, dynamic>;
|
||||
final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>;
|
||||
for (String placeholder in placeholders.keys)
|
||||
message = message.replaceAll('{$placeholder}', '\$$placeholder');
|
||||
return generateString(message);
|
||||
}
|
||||
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'];
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'] as Map<String, dynamic>;
|
||||
if (attributesMap == null)
|
||||
exitWithError(
|
||||
'Resource attribute "@$key" was not found. Please ensure that each '
|
||||
@@ -208,18 +208,18 @@ String genSimpleMethod(Map<String, dynamic> bundle, String key) {
|
||||
|
||||
return getterMethodTemplate
|
||||
.replaceAll('@methodName', key)
|
||||
.replaceAll('@message', '${generateString(bundle[key])}')
|
||||
.replaceAll('@message', '${generateString(bundle[key] as String)}')
|
||||
.replaceAll('@intlMethodArgs', genIntlMethodArgs(bundle, key).join(',\n '));
|
||||
}
|
||||
|
||||
String genPluralMethod(Map<String, dynamic> bundle, String key) {
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'];
|
||||
final Map<String, dynamic> attributesMap = bundle['@$key'] as Map<String, dynamic>;
|
||||
assert(attributesMap != null && attributesMap.containsKey('placeholders'));
|
||||
final Iterable<String> placeholders = attributesMap['placeholders'].keys;
|
||||
final Iterable<String> placeholders = attributesMap['placeholders'].keys as Iterable<String>;
|
||||
|
||||
// To make it easier to parse the plurals message, temporarily replace each
|
||||
// "{placeholder}" parameter with "#placeholder#".
|
||||
String message = bundle[key];
|
||||
String message = bundle[key] as String;
|
||||
for (String placeholder in placeholders)
|
||||
message = message.replaceAll('{$placeholder}', '#$placeholder#');
|
||||
|
||||
@@ -354,13 +354,13 @@ Future<void> main(List<String> arguments) async {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
final String arbPathString = results['arb-dir'];
|
||||
final String outputFileString = results['output-localization-file'];
|
||||
final String arbPathString = results['arb-dir'] as String;
|
||||
final String outputFileString = results['output-localization-file'] as String;
|
||||
|
||||
final Directory l10nDirectory = Directory(arbPathString);
|
||||
final File templateArbFile = File(path.join(l10nDirectory.path, results['template-arb-file']));
|
||||
final File templateArbFile = File(path.join(l10nDirectory.path, results['template-arb-file'] as String));
|
||||
final File outputFile = File(path.join(l10nDirectory.path, outputFileString));
|
||||
final String stringsClassName = results['output-class'];
|
||||
final String stringsClassName = results['output-class'] as String;
|
||||
|
||||
if (!l10nDirectory.existsSync())
|
||||
exitWithError(
|
||||
@@ -395,8 +395,8 @@ Future<void> main(List<String> arguments) async {
|
||||
final RegExp arbFilenameRE = RegExp(r'(\w+)\.arb$');
|
||||
if (arbFilenameRE.hasMatch(entityPath)) {
|
||||
final File arbFile = File(entityPath);
|
||||
final Map<String, dynamic> arbContents = json.decode(arbFile.readAsStringSync());
|
||||
String localeString = arbContents['@@locale'];
|
||||
final Map<String, dynamic> arbContents = json.decode(arbFile.readAsStringSync()) as Map<String, dynamic>;
|
||||
String localeString = arbContents['@@locale'] as String;
|
||||
|
||||
if (localeString == null) {
|
||||
final RegExp arbFilenameLocaleRE = RegExp(r'^[^_]*_(\w+)\.arb$');
|
||||
@@ -430,7 +430,7 @@ Future<void> main(List<String> arguments) async {
|
||||
|
||||
Map<String, dynamic> bundle;
|
||||
try {
|
||||
bundle = json.decode(templateArbFile.readAsStringSync());
|
||||
bundle = json.decode(templateArbFile.readAsStringSync()) as Map<String, dynamic>;
|
||||
} on FileSystemException catch (e) {
|
||||
exitWithError('Unable to read input arb file: $e');
|
||||
} on FormatException catch (e) {
|
||||
@@ -447,7 +447,7 @@ Future<void> main(List<String> arguments) async {
|
||||
'Invalid key format: $key \n It has to be in camel case, cannot start '
|
||||
'with a number, and cannot contain non-alphanumeric characters.'
|
||||
);
|
||||
if (pluralValueRE.hasMatch(bundle[key]))
|
||||
if (pluralValueRE.hasMatch(bundle[key] as String))
|
||||
classMethods.add(genPluralMethod(bundle, key));
|
||||
else
|
||||
classMethods.add(genSimpleMethod(bundle, key));
|
||||
|
||||
@@ -136,7 +136,7 @@ String generateArbBasedLocalizationSubclasses({
|
||||
|
||||
final Map<String, String> languageResources = localeToResources[languageLocale];
|
||||
for (String key in allKeys) {
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key];
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key] as Map<String, dynamic>;
|
||||
output.writeln(generateGetter(key, languageResources[key], attributes, languageLocale));
|
||||
}
|
||||
output.writeln('}');
|
||||
@@ -158,7 +158,7 @@ String generateArbBasedLocalizationSubclasses({
|
||||
for (String key in scriptResources.keys.toList()..sort()) {
|
||||
if (languageResources[key] == scriptResources[key])
|
||||
continue;
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key];
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key] as Map<String, dynamic>;
|
||||
output.writeln(generateGetter(key, scriptResources[key], attributes, languageLocale));
|
||||
}
|
||||
output.writeln('}');
|
||||
@@ -183,7 +183,7 @@ String generateArbBasedLocalizationSubclasses({
|
||||
// When script fallback contains the key, we compare to it instead of language fallback.
|
||||
if (scriptResources.containsKey(key) ? scriptResources[key] == localeResources[key] : languageResources[key] == localeResources[key])
|
||||
continue;
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key];
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key] as Map<String, dynamic>;
|
||||
output.writeln(generateGetter(key, localeResources[key], attributes, languageLocale));
|
||||
}
|
||||
output.writeln('}');
|
||||
@@ -207,7 +207,7 @@ String generateArbBasedLocalizationSubclasses({
|
||||
for (String key in localeResources.keys) {
|
||||
if (languageResources[key] == localeResources[key])
|
||||
continue;
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key];
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key] as Map<String, dynamic>;
|
||||
output.writeln(generateGetter(key, localeResources[key], attributes, languageLocale));
|
||||
}
|
||||
output.writeln('}');
|
||||
@@ -380,7 +380,7 @@ $factoryDeclaration
|
||||
/// Used by [generateGetter] below.
|
||||
String generateType(Map<String, dynamic> attributes) {
|
||||
if (attributes != null) {
|
||||
switch (attributes['x-flutter-type']) {
|
||||
switch (attributes['x-flutter-type'] as String) {
|
||||
case 'icuShortTimePattern':
|
||||
return 'TimeOfDayFormat';
|
||||
case 'scriptCategory':
|
||||
@@ -401,7 +401,7 @@ String generateKey(String key, Map<String, dynamic> attributes) {
|
||||
if (attributes != null) {
|
||||
if (attributes.containsKey('parameters'))
|
||||
return '${key}Raw';
|
||||
switch (attributes['x-flutter-type']) {
|
||||
switch (attributes['x-flutter-type'] as String) {
|
||||
case 'icuShortTimePattern':
|
||||
return '${key}Raw';
|
||||
}
|
||||
@@ -443,7 +443,7 @@ String generateValue(String value, Map<String, dynamic> attributes, LocaleInfo l
|
||||
return null;
|
||||
// cupertino_en.arb doesn't use x-flutter-type.
|
||||
if (attributes != null) {
|
||||
switch (attributes['x-flutter-type']) {
|
||||
switch (attributes['x-flutter-type'] as String) {
|
||||
case 'icuShortTimePattern':
|
||||
if (!_icuTimeOfDayToEnum.containsKey(value)) {
|
||||
throw Exception(
|
||||
|
||||
@@ -114,10 +114,8 @@ class LocaleInfo implements Comparable<LocaleInfo> {
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (!(other is LocaleInfo))
|
||||
return false;
|
||||
final LocaleInfo otherLocale = other;
|
||||
return originalString == otherLocale.originalString;
|
||||
return other is LocaleInfo
|
||||
&& other.originalString == originalString;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -167,13 +165,13 @@ void loadMatchingArbsIntoBundleMaps({
|
||||
void populateResources(LocaleInfo locale, File file) {
|
||||
final Map<String, String> resources = localeToResources[locale];
|
||||
final Map<String, dynamic> attributes = localeToResourceAttributes[locale];
|
||||
final Map<String, dynamic> bundle = json.decode(file.readAsStringSync());
|
||||
final Map<String, dynamic> bundle = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
|
||||
for (String key in bundle.keys) {
|
||||
// The ARB file resource "attributes" for foo are called @foo.
|
||||
if (key.startsWith('@'))
|
||||
attributes[key.substring(1)] = bundle[key];
|
||||
else
|
||||
resources[key] = bundle[key];
|
||||
resources[key] = bundle[key] as String;
|
||||
}
|
||||
}
|
||||
// Only pre-assume scriptCode if there is a country or script code to assume off of.
|
||||
@@ -247,9 +245,9 @@ GeneratorOptions parseArgs(List<String> rawArgs) {
|
||||
defaultsTo: false,
|
||||
);
|
||||
final argslib.ArgResults args = argParser.parse(rawArgs);
|
||||
final bool writeToFile = args['overwrite'];
|
||||
final bool materialOnly = args['material'];
|
||||
final bool cupertinoOnly = args['cupertino'];
|
||||
final bool writeToFile = args['overwrite'] as bool;
|
||||
final bool materialOnly = args['material'] as bool;
|
||||
final bool cupertinoOnly = args['cupertino'] as bool;
|
||||
|
||||
return GeneratorOptions(writeToFile: writeToFile, materialOnly: materialOnly, cupertinoOnly: cupertinoOnly);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ void validateEnglishLocalizations(File file) {
|
||||
throw ValidationError(errorMessages.toString());
|
||||
}
|
||||
|
||||
final Map<String, dynamic> bundle = json.decode(file.readAsStringSync());
|
||||
final Map<String, dynamic> bundle = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
|
||||
|
||||
for (String resourceId in bundle.keys) {
|
||||
if (resourceId.startsWith('@'))
|
||||
@@ -67,11 +67,11 @@ void validateEnglishLocalizations(File file) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String description = atResource['description'];
|
||||
final String description = atResource['description'] as String;
|
||||
if (description == null)
|
||||
errorMessages.writeln('No description specified for $atResourceId');
|
||||
|
||||
final String plural = atResource['plural'];
|
||||
final String plural = atResource['plural'] as String;
|
||||
final String resourceId = atResourceId.substring(1);
|
||||
if (plural != null) {
|
||||
final String resourceIdOther = '${resourceId}Other';
|
||||
|
||||
@@ -25,7 +25,7 @@ void main(List<String> args) {
|
||||
|
||||
final ArgResults results = argParser.parse(args);
|
||||
|
||||
if (results['help']) {
|
||||
if (results['help'] as bool) {
|
||||
print('Generate n copies of flutter_gallery.\n');
|
||||
print('usage: dart mega_gallery.dart <options>');
|
||||
print(argParser.usage);
|
||||
@@ -33,9 +33,9 @@ void main(List<String> args) {
|
||||
}
|
||||
|
||||
final Directory source = Directory(_normalize('examples/flutter_gallery'));
|
||||
final Directory out = Directory(_normalize(results['out']));
|
||||
final Directory out = Directory(_normalize(results['out'] as String));
|
||||
|
||||
if (results['delete']) {
|
||||
if (results['delete'] as bool) {
|
||||
if (out.existsSync()) {
|
||||
print('Deleting ${out.path}');
|
||||
out.deleteSync(recursive: true);
|
||||
@@ -55,7 +55,7 @@ void main(List<String> args) {
|
||||
final SourceStats stats = getStatsFor(_dir(source, 'lib'));
|
||||
copies = (kTargetLineCount / stats.lines).round();
|
||||
} else {
|
||||
copies = int.parse(results['copies']);
|
||||
copies = int.parse(results['copies'] as String);
|
||||
}
|
||||
|
||||
print('Making $copies copies of flutter_gallery.');
|
||||
@@ -89,7 +89,7 @@ void main(List<String> args) {
|
||||
_file(out, '.dartignore').writeAsStringSync('');
|
||||
|
||||
// Count source lines and number of files; tell how to run it.
|
||||
print(' ${path.relative(results["out"])} : ${getStatsFor(out)}');
|
||||
print(' ${path.relative(results["out"] as String)} : ${getStatsFor(out)}');
|
||||
}
|
||||
|
||||
// TODO(devoncarew): Create an entry-point that builds a UI with all `n` copies.
|
||||
|
||||
@@ -158,12 +158,12 @@ void main(List<String> args) {
|
||||
argParser.addFlag(kOptionDryRun, defaultsTo: false);
|
||||
final ArgResults argResults = argParser.parse(args);
|
||||
|
||||
final File iconFile = File(path.absolute(argResults[kOptionIconsPath]));
|
||||
final File iconFile = File(path.absolute(argResults[kOptionIconsPath] as String));
|
||||
if (!iconFile.existsSync()) {
|
||||
stderr.writeln('Icons file not found: ${iconFile.path}');
|
||||
exit(1);
|
||||
}
|
||||
final File codepointsFile = File(path.absolute(argResults[kOptionCodepointsPath]));
|
||||
final File codepointsFile = File(path.absolute(argResults[kOptionCodepointsPath] as String));
|
||||
if (!codepointsFile.existsSync()) {
|
||||
stderr.writeln('Codepoints file not found: ${codepointsFile.path}');
|
||||
exit(1);
|
||||
@@ -173,7 +173,7 @@ void main(List<String> args) {
|
||||
final String codepointData = codepointsFile.readAsStringSync();
|
||||
final String newIconData = regenerateIconsFile(iconData, codepointData);
|
||||
|
||||
if (argResults[kOptionDryRun])
|
||||
if (argResults[kOptionDryRun] as bool)
|
||||
stdout.writeln(newIconData);
|
||||
else
|
||||
iconFile.writeAsStringSync(newIconData);
|
||||
|
||||
@@ -56,7 +56,7 @@ void main(List<String> args) {
|
||||
|
||||
final ArgResults argResults = parser.parse(args);
|
||||
|
||||
if (argResults['help'] ||
|
||||
if (argResults['help'] as bool ||
|
||||
!argResults.wasParsed('output') ||
|
||||
!argResults.wasParsed('asset-name') ||
|
||||
argResults.rest.isEmpty) {
|
||||
@@ -71,20 +71,20 @@ void main(List<String> args) {
|
||||
final StringBuffer generatedSb = StringBuffer();
|
||||
|
||||
if (argResults.wasParsed('header')) {
|
||||
generatedSb.write(File(argResults['header']).readAsStringSync());
|
||||
generatedSb.write(File(argResults['header'] as String).readAsStringSync());
|
||||
generatedSb.write('\n');
|
||||
}
|
||||
|
||||
if (argResults['codegen_comment'])
|
||||
if (argResults['codegen_comment'] as bool)
|
||||
generatedSb.write(kCodegenComment);
|
||||
|
||||
if (argResults.wasParsed('part-of'))
|
||||
generatedSb.write('part of ${argResults['part-of']};\n');
|
||||
|
||||
final Animation animation = Animation.fromFrameData(frames);
|
||||
generatedSb.write(animation.toDart('_AnimatedIconData', argResults['asset-name']));
|
||||
generatedSb.write(animation.toDart('_AnimatedIconData', argResults['asset-name'] as String));
|
||||
|
||||
final File outFile = File(argResults['output']);
|
||||
final File outFile = File(argResults['output'] as String);
|
||||
outFile.writeAsStringSync(generatedSb.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ List<SvgPath> _interpretSvgGroup(List<XmlNode> children, _Transform transform) {
|
||||
for (XmlNode node in children) {
|
||||
if (node.nodeType != XmlNodeType.ELEMENT)
|
||||
continue;
|
||||
final XmlElement element = node;
|
||||
final XmlElement element = node as XmlElement;
|
||||
|
||||
if (element.name.local == 'path') {
|
||||
paths.add(SvgPath.fromElement(element).applyTransform(transform));
|
||||
@@ -270,9 +270,9 @@ class FrameData {
|
||||
bool operator ==(Object other) {
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final FrameData typedOther = other;
|
||||
return size == typedOther.size
|
||||
&& const ListEquality<SvgPath>().equals(paths, typedOther.paths);
|
||||
return other is FrameData
|
||||
&& other.size == size
|
||||
&& const ListEquality<SvgPath>().equals(other.paths, paths);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -322,10 +322,10 @@ class SvgPath {
|
||||
bool operator ==(Object other) {
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final SvgPath typedOther = other;
|
||||
return id == typedOther.id
|
||||
&& opacity == typedOther.opacity
|
||||
&& const ListEquality<SvgPathCommand>().equals(commands, typedOther.commands);
|
||||
return other is SvgPath
|
||||
&& other.id == id
|
||||
&& other.opacity == opacity
|
||||
&& const ListEquality<SvgPathCommand>().equals(other.commands, commands);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -371,9 +371,9 @@ class SvgPathCommand {
|
||||
bool operator ==(Object other) {
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final SvgPathCommand typedOther = other;
|
||||
return type == typedOther.type
|
||||
&& const ListEquality<Point<double>>().equals(points, typedOther.points);
|
||||
return other is SvgPathCommand
|
||||
&& other.type == type
|
||||
&& const ListEquality<Point<double>>().equals(other.points, points);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -554,7 +554,7 @@ XmlElement _extractSvgElement(XmlDocument document) {
|
||||
return document.children.singleWhere(
|
||||
(XmlNode node) => node.nodeType == XmlNodeType.ELEMENT &&
|
||||
_asElement(node).name.local == 'svg'
|
||||
);
|
||||
) as XmlElement;
|
||||
}
|
||||
|
||||
XmlElement _asElement(XmlNode node) => node;
|
||||
XmlElement _asElement(XmlNode node) => node as XmlElement;
|
||||
|
||||
@@ -622,7 +622,7 @@ class PathMatcher extends Matcher {
|
||||
if (item.runtimeType != actual.runtimeType)
|
||||
return false;
|
||||
|
||||
final SvgPath other = item;
|
||||
final SvgPath other = item as SvgPath;
|
||||
if (other.id != actual.id || other.opacity != actual.opacity)
|
||||
return false;
|
||||
|
||||
@@ -666,7 +666,7 @@ class PathAnimationMatcher extends Matcher {
|
||||
if (item.runtimeType != expected.runtimeType)
|
||||
return false;
|
||||
|
||||
final PathAnimation other = item;
|
||||
final PathAnimation other = item as PathAnimation;
|
||||
|
||||
if (!const ListEquality<double>().equals(other.opacities, expected.opacities))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user