set literal conversions (#27811)

This commit is contained in:
Phil Quitslund
2019-03-06 11:05:16 -08:00
committed by GitHub
parent 608b03c79b
commit 802eca29d2
54 changed files with 133 additions and 138 deletions

View File

@@ -401,7 +401,7 @@ Set<String> _findFlutterDependencies(String srcPath, List<String> errors, { bool
return Directory(srcPath).listSync(recursive: true).where((FileSystemEntity entity) {
return entity is File && path.extension(entity.path) == '.dart';
}).map<Set<String>>((FileSystemEntity entity) {
final Set<String> result = Set<String>();
final Set<String> result = <String>{};
final File file = entity;
for (String line in file.readAsLinesSync()) {
Match match = _importPattern.firstMatch(line);
@@ -419,7 +419,7 @@ Set<String> _findFlutterDependencies(String srcPath, List<String> errors, { bool
}
return result;
}).reduce((Set<String> value, Set<String> element) {
value ??= Set<String>();
value ??= <String>{};
value.addAll(element);
return value;
});
@@ -434,7 +434,7 @@ List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
final List<T> result = _deepSearch<T>(
map,
key,
(seen == null ? Set<T>.from(<T>[start]) : Set<T>.from(seen))..add(key),
(seen == null ? <T>{start} : Set<T>.from(seen))..add(key),
);
if (result != null) {
result.insert(0, start);
@@ -543,7 +543,7 @@ Future<void> _verifyGeneratedPluginRegistrants(String flutterRoot) async {
}
}
final Set<String> outOfDate = Set<String>();
final Set<String> outOfDate = <String>{};
for (String package in packageToRegistrants.keys) {
final Map<File, String> fileToContent = <File, String>{};

View File

@@ -1382,7 +1382,7 @@ String zalgo(math.Random random, int targetLength, { bool includeSpacingCombinin
0x16F7E, 0x1D165, 0x1D166, 0x1D16D, 0x1D16E, 0x1D16F, 0x1D170,
0x1D171, 0x1D172,
];
final Set<int> these = Set<int>();
final Set<int> these = <int>{};
int combiningCount = enclosingCombiningMarks.length + nonspacingCombiningMarks.length;
if (includeSpacingCombiningMarks)
combiningCount += spacingCombiningMarks.length;

View File

@@ -80,7 +80,7 @@ final Map<LocaleInfo, Map<String, dynamic>> localeToResourceAttributes = <Locale
/// the first Hant Chinese locale as a default by repeating the data. If an
/// explicit match is later found, we can reference this set to see if we should
/// overwrite the existing assumed data.
final Set<LocaleInfo> assumedLocales = Set<LocaleInfo>();
final Set<LocaleInfo> assumedLocales = <LocaleInfo>{};
/// Return `s` as a Dart-parseable raw string in single or double quotes.
///
@@ -124,15 +124,15 @@ String generateTranslationBundles() {
final Map<String, Set<String>> languageToScriptCodes = <String, Set<String>>{};
// Used to calculate if there are any corresponding countries for a given language and script.
final Map<LocaleInfo, Set<String>> languageAndScriptToCountryCodes = <LocaleInfo, Set<String>>{};
final Set<String> allResourceIdentifiers = Set<String>();
final Set<String> allResourceIdentifiers = <String>{};
for (LocaleInfo locale in localeToResources.keys.toList()..sort()) {
if (locale.scriptCode != null) {
languageToScriptCodes[locale.languageCode] ??= Set<String>();
languageToScriptCodes[locale.languageCode] ??= <String>{};
languageToScriptCodes[locale.languageCode].add(locale.scriptCode);
}
if (locale.countryCode != null && locale.scriptCode != null) {
final LocaleInfo key = LocaleInfo.fromString(locale.languageCode + '_' + locale.scriptCode);
languageAndScriptToCountryCodes[key] ??= Set<String>();
languageAndScriptToCountryCodes[key] ??= <String>{};
languageAndScriptToCountryCodes[key].add(locale.countryCode);
}
languageToLocales[locale.languageCode] ??= <LocaleInfo>[];

View File

@@ -71,7 +71,7 @@ const Map<String, String> kIdentifierRewrites = <String, String>{
};
final Set<String> kMirroredIcons = Set<String>.from(<String>[
const Set<String> kMirroredIcons = <String>{
// This list is obtained from:
// http://google.github.io/material-design-icons/#icons-in-rtl
'arrow_back',
@@ -145,7 +145,7 @@ final Set<String> kMirroredIcons = Set<String>.from(<String>[
'view_list',
'view_quilt',
'wrap_text',
]);
};
void main(List<String> args) {
// If we're run from the `tools` dir, set the cwd to the repo root.