set literal conversions (#27811)
This commit is contained in:
@@ -682,7 +682,7 @@ class GradleProject {
|
||||
.trim();
|
||||
|
||||
// Extract build types and product flavors.
|
||||
final Set<String> variants = Set<String>();
|
||||
final Set<String> variants = <String>{};
|
||||
for (String s in tasks.split('\n')) {
|
||||
final Match match = _assembleTaskPattern.matchAsPrefix(s);
|
||||
if (match != null) {
|
||||
@@ -691,8 +691,8 @@ class GradleProject {
|
||||
variants.add(variant);
|
||||
}
|
||||
}
|
||||
final Set<String> buildTypes = Set<String>();
|
||||
final Set<String> productFlavors = Set<String>();
|
||||
final Set<String> buildTypes = <String>{};
|
||||
final Set<String> productFlavors = <String>{};
|
||||
for (final String variant1 in variants) {
|
||||
for (final String variant2 in variants) {
|
||||
if (variant2.startsWith(variant1) && variant2 != variant1) {
|
||||
|
||||
@@ -320,7 +320,7 @@ Future<DevFSContent> _obtainLicenses(
|
||||
// example, a package might itself contain code from multiple third-party
|
||||
// sources, and might need to include a license for each one.)
|
||||
final Map<String, Set<String>> packageLicenses = <String, Set<String>>{};
|
||||
final Set<String> allPackages = Set<String>();
|
||||
final Set<String> allPackages = <String>{};
|
||||
for (String packageName in packageMap.map.keys) {
|
||||
final Uri package = packageMap.map[packageName];
|
||||
if (package != null && package.scheme == 'file') {
|
||||
@@ -342,7 +342,7 @@ Future<DevFSContent> _obtainLicenses(
|
||||
packageNames = <String>[packageName];
|
||||
licenseText = rawLicense;
|
||||
}
|
||||
packageLicenses.putIfAbsent(licenseText, () => Set<String>())
|
||||
packageLicenses.putIfAbsent(licenseText, () => <String>{})
|
||||
..addAll(packageNames);
|
||||
allPackages.addAll(packageNames);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class AOTSnapshotter {
|
||||
final String vmServicePath = fs.path.join(skyEnginePkg, 'sdk_ext', 'vmservice_io.dart');
|
||||
|
||||
final List<String> inputPaths = <String>[uiPath, vmServicePath, mainPath];
|
||||
final Set<String> outputPaths = Set<String>();
|
||||
final Set<String> outputPaths = <String>{};
|
||||
|
||||
final String depfilePath = fs.path.join(outputDir.path, 'snapshot.d');
|
||||
final List<String> genSnapshotArgs = <String>[
|
||||
@@ -458,7 +458,7 @@ class JITSnapshotter {
|
||||
genSnapshotArgs.addAll(extraGenSnapshotOptions);
|
||||
}
|
||||
|
||||
final Set<String> outputPaths = Set<String>();
|
||||
final Set<String> outputPaths = <String>{};
|
||||
outputPaths.addAll(<String>[isolateSnapshotData]);
|
||||
if (!createPatch) {
|
||||
outputPaths.add(isolateSnapshotInstructions);
|
||||
|
||||
@@ -146,7 +146,7 @@ String getDisplayPath(String fullPath) {
|
||||
/// available.
|
||||
class ItemListNotifier<T> {
|
||||
ItemListNotifier() {
|
||||
_items = Set<T>();
|
||||
_items = <T>{};
|
||||
}
|
||||
|
||||
ItemListNotifier.from(List<T> items) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class AnalyzeContinuously extends AnalyzeBase {
|
||||
|
||||
String analysisTarget;
|
||||
bool firstAnalysis = true;
|
||||
Set<String> analyzedPaths = Set<String>();
|
||||
Set<String> analyzedPaths = <String>{};
|
||||
Map<String, List<AnalysisError>> analysisErrors = <String, List<AnalysisError>>{};
|
||||
Stopwatch analysisTimer;
|
||||
int lastErrorCount = 0;
|
||||
|
||||
@@ -52,7 +52,7 @@ class ChannelCommand extends FlutterCommand {
|
||||
// Beware: currentBranch could contain PII. See getBranchName().
|
||||
final String currentChannel = FlutterVersion.instance.channel;
|
||||
final String currentBranch = FlutterVersion.instance.getBranchName();
|
||||
final Set<String> seenChannels = Set<String>();
|
||||
final Set<String> seenChannels = <String>{};
|
||||
final List<String> rawOutput = <String>[];
|
||||
|
||||
showAll = showAll || currentChannel != currentBranch;
|
||||
|
||||
@@ -612,7 +612,7 @@ String _createUTIIdentifier(String organization, String name) {
|
||||
return segments.join('.');
|
||||
}
|
||||
|
||||
final Set<String> _packageDependencies = Set<String>.from(<String>[
|
||||
const Set<String> _packageDependencies = <String>{
|
||||
'analyzer',
|
||||
'args',
|
||||
'async',
|
||||
@@ -639,7 +639,7 @@ final Set<String> _packageDependencies = Set<String>.from(<String>[
|
||||
'utf',
|
||||
'watcher',
|
||||
'yaml',
|
||||
]);
|
||||
};
|
||||
|
||||
/// Return null if the project name is legal. Return a validation message if
|
||||
/// we should disallow the project name.
|
||||
|
||||
@@ -121,7 +121,7 @@ class IdeConfigCommand extends FlutterCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final Set<String> manifest = Set<String>();
|
||||
final Set<String> manifest = <String>{};
|
||||
final List<FileSystemEntity> flutterFiles = _flutterRoot.listSync(recursive: true);
|
||||
for (FileSystemEntity entity in flutterFiles) {
|
||||
final String relativePath = fs.path.relative(entity.path, from: _flutterRoot.absolute.path);
|
||||
|
||||
@@ -200,7 +200,7 @@ class UpdatePackagesCommand extends FlutterCommand {
|
||||
// First, collect up the explicit dependencies:
|
||||
final List<PubspecYaml> pubspecs = <PubspecYaml>[];
|
||||
final Map<String, PubspecDependency> dependencies = <String, PubspecDependency>{};
|
||||
final Set<String> specialDependencies = Set<String>();
|
||||
final Set<String> specialDependencies = <String>{};
|
||||
for (Directory directory in packages) { // these are all the directories with pubspec.yamls we care about
|
||||
printTrace('Reading pubspec.yaml from: ${directory.path}');
|
||||
PubspecYaml pubspec;
|
||||
@@ -279,7 +279,7 @@ class UpdatePackagesCommand extends FlutterCommand {
|
||||
for (PubspecDependency dependency in pubspec.dependencies) {
|
||||
if (dependency.kind == DependencyKind.normal) {
|
||||
tree._versions[package] = version;
|
||||
tree._dependencyTree[package] ??= Set<String>();
|
||||
tree._dependencyTree[package] ??= <String>{};
|
||||
tree._dependencyTree[package].add(dependency.name);
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ class UpdatePackagesCommand extends FlutterCommand {
|
||||
throwToolExit('Package $to not found in the dependency tree.');
|
||||
|
||||
final Queue<_DependencyLink> traversalQueue = Queue<_DependencyLink>();
|
||||
final Set<String> visited = Set<String>();
|
||||
final Set<String> visited = <String>{};
|
||||
final List<_DependencyLink> paths = <_DependencyLink>[];
|
||||
|
||||
traversalQueue.addFirst(_DependencyLink(from: null, to: from));
|
||||
@@ -625,8 +625,8 @@ class PubspecYaml {
|
||||
void apply(PubDependencyTree versions, Set<String> specialDependencies) {
|
||||
assert(versions != null);
|
||||
final List<String> output = <String>[]; // the string data to output to the file, line by line
|
||||
final Set<String> directDependencies = Set<String>(); // packages this pubspec directly depends on (i.e. not transitive)
|
||||
final Set<String> devDependencies = Set<String>();
|
||||
final Set<String> directDependencies = <String>{}; // packages this pubspec directly depends on (i.e. not transitive)
|
||||
final Set<String> devDependencies = <String>{};
|
||||
Section section = Section.other; // the section we're currently handling
|
||||
|
||||
// the line number where we're going to insert the transitive dependencies.
|
||||
@@ -723,8 +723,8 @@ class PubspecYaml {
|
||||
final List<String> transitiveDevDependencyOutput = <String>[];
|
||||
|
||||
// Which dependencies we need to handle for the transitive and dev dependency sections.
|
||||
final Set<String> transitiveDependencies = Set<String>();
|
||||
final Set<String> transitiveDevDependencies = Set<String>();
|
||||
final Set<String> transitiveDependencies = <String>{};
|
||||
final Set<String> transitiveDevDependencies = <String>{};
|
||||
|
||||
// Merge the lists of dependencies we've seen in this file from dependencies, dev dependencies,
|
||||
// and the dependencies we know this file mentions that are already pinned
|
||||
@@ -735,7 +735,7 @@ class PubspecYaml {
|
||||
|
||||
// Create a new set to hold the list of packages we've already processed, so
|
||||
// that we don't redundantly process them multiple times.
|
||||
final Set<String> done = Set<String>();
|
||||
final Set<String> done = <String>{};
|
||||
for (String package in directDependencies)
|
||||
transitiveDependencies.addAll(versions.getTransitiveDependenciesFor(package, seen: done, exclude: implied));
|
||||
for (String package in devDependencies)
|
||||
@@ -752,7 +752,7 @@ class PubspecYaml {
|
||||
transitiveDevDependencyOutput.add(' $package: ${versions.versionFor(package)} $kTransitiveMagicString');
|
||||
|
||||
// Build a sorted list of all dependencies for the checksum.
|
||||
final Set<String> checksumDependencies = Set<String>()
|
||||
final Set<String> checksumDependencies = <String>{}
|
||||
..addAll(directDependencies)
|
||||
..addAll(devDependencies)
|
||||
..addAll(transitiveDependenciesAsList)
|
||||
|
||||
@@ -11,7 +11,7 @@ class DependencyChecker {
|
||||
DependencyChecker(this.builder, this.assets);
|
||||
|
||||
final DartDependencySetBuilder builder;
|
||||
final Set<String> _dependencies = Set<String>();
|
||||
final Set<String> _dependencies = <String>{};
|
||||
final AssetBundle assets;
|
||||
|
||||
/// Returns [true] if any components have been modified after [threshold] or
|
||||
|
||||
@@ -403,7 +403,7 @@ class DevFS {
|
||||
final Directory rootDirectory;
|
||||
String _packagesFilePath;
|
||||
final Map<Uri, DevFSContent> _entries = <Uri, DevFSContent>{};
|
||||
final Set<String> assetPathsToEvict = Set<String>();
|
||||
final Set<String> assetPathsToEvict = <String>{};
|
||||
|
||||
final List<Future<Map<String, dynamic>>> _pendingOperations =
|
||||
<Future<Map<String, dynamic>>>[];
|
||||
@@ -533,7 +533,7 @@ class DevFS {
|
||||
// run with no changes is supposed to be fast (considering that it is
|
||||
// initiated by user key press).
|
||||
final List<String> invalidatedFiles = <String>[];
|
||||
final Set<Uri> filesUris = Set<Uri>();
|
||||
final Set<Uri> filesUris = <Uri>{};
|
||||
for (Uri uri in dirtyEntries.keys.toList()) {
|
||||
if (!uri.path.startsWith(assetBuildDirPrefix)) {
|
||||
final DevFSContent content = dirtyEntries[uri];
|
||||
|
||||
@@ -391,9 +391,9 @@ void _validateFonts(YamlList fonts, List<String> errors) {
|
||||
if (fonts == null) {
|
||||
return;
|
||||
}
|
||||
final Set<int> fontWeights = Set<int>.from(const <int>[
|
||||
const Set<int> fontWeights = <int>{
|
||||
100, 200, 300, 400, 500, 600, 700, 800, 900,
|
||||
]);
|
||||
};
|
||||
for (final YamlMap fontMap in fonts) {
|
||||
for (dynamic key in fontMap.keys.where((dynamic key) => key != 'family' && key != 'fonts')) {
|
||||
errors.add('Unexpected child "$key" found under "fonts".');
|
||||
|
||||
@@ -733,7 +733,7 @@ Future<bool> upgradePbxProjWithFlutterAssets(IosProject project) async {
|
||||
|
||||
final RegExp oldAssets = RegExp(r'\/\* (flutter_assets|app\.flx)');
|
||||
final StringBuffer buffer = StringBuffer();
|
||||
final Set<String> printedStatuses = Set<String>();
|
||||
final Set<String> printedStatuses = <String>{};
|
||||
|
||||
for (final String line in lines) {
|
||||
final Match match = oldAssets.firstMatch(line);
|
||||
|
||||
@@ -43,12 +43,12 @@ class FlutterVersion {
|
||||
String _repositoryUrl;
|
||||
String get repositoryUrl => _repositoryUrl;
|
||||
|
||||
static Set<String> officialChannels = Set<String>.from(<String>[
|
||||
static const Set<String> officialChannels = <String>{
|
||||
'master',
|
||||
'dev',
|
||||
'beta',
|
||||
'stable',
|
||||
]);
|
||||
};
|
||||
|
||||
/// This maps old branch names to the names of branches that replaced them.
|
||||
///
|
||||
|
||||
@@ -272,7 +272,7 @@ class VMService {
|
||||
final Map<String, StreamController<ServiceEvent>> _eventControllers =
|
||||
<String, StreamController<ServiceEvent>>{};
|
||||
|
||||
final Set<String> _listeningFor = Set<String>();
|
||||
final Set<String> _listeningFor = <String>{};
|
||||
|
||||
/// Whether our connection to the VM service has been closed;
|
||||
bool get isClosed => _peer.isClosed;
|
||||
@@ -749,7 +749,7 @@ class VM extends ServiceObjectOwner {
|
||||
|
||||
void _removeDeadIsolates(List<Isolate> newIsolates) {
|
||||
// Build a set of new isolates.
|
||||
final Set<String> newIsolateSet = Set<String>();
|
||||
final Set<String> newIsolateSet = <String>{};
|
||||
for (Isolate iso in newIsolates)
|
||||
newIsolateSet.add(iso.id);
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ void main() {
|
||||
const String packageName = 'doubleslashpkg';
|
||||
await _createPackage(fs, packageName, 'somefile.txt', doubleSlash: true);
|
||||
|
||||
final Set<String> fileFilter = Set<String>();
|
||||
final Set<String> fileFilter = <String>{};
|
||||
final List<Uri> pkgUris = <Uri>[fs.path.toUri(basePath)]..addAll(_packages.values);
|
||||
for (Uri pkgUri in pkgUris) {
|
||||
if (!pkgUri.isAbsolute) {
|
||||
|
||||
@@ -114,7 +114,7 @@ void main() {
|
||||
pathToReload: anyNamed('pathToReload'),
|
||||
)).thenAnswer((Invocation _) => Future<UpdateFSReport>.value(
|
||||
UpdateFSReport(success: true, syncedBytes: 1000, invalidatedSourcesCount: 1)));
|
||||
when(mockDevFs.assetPathsToEvict).thenReturn(Set<String>());
|
||||
when(mockDevFs.assetPathsToEvict).thenReturn(<String>{});
|
||||
when(mockDevFs.baseUri).thenReturn(Uri.file('test'));
|
||||
|
||||
setUp(() {
|
||||
|
||||
@@ -62,7 +62,7 @@ baz=qux
|
||||
});
|
||||
|
||||
test('is pretty random', () {
|
||||
final Set<String> set = Set<String>();
|
||||
final Set<String> set = <String>{};
|
||||
|
||||
Uuid uuid = Uuid();
|
||||
for (int i = 0; i < 64; i++) {
|
||||
|
||||
Reference in New Issue
Block a user