Skip to content

Commit 4071889

Browse files
srawlinscommit-bot@chromium.org
authored andcommitted
Fix pedantic 0.9 lints around collection literals and spreads
Change-Id: I64277c36fbeb4ea7a1bb429a8e0a40203520c883 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128380 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 83eeab1 commit 4071889

File tree

66 files changed

+217
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+217
-212
lines changed

pkg/analyzer/lib/dart/ast/ast.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,8 +3069,8 @@ abstract class ImportDirective implements NamespaceDirective {
30693069
// hides and shows
30703070
//
30713071
NodeList<Combinator> combinators1 = import1.combinators;
3072-
List<String> allHides1 = List<String>();
3073-
List<String> allShows1 = List<String>();
3072+
List<String> allHides1 = <String>[];
3073+
List<String> allShows1 = <String>[];
30743074
int length1 = combinators1.length;
30753075
for (int i = 0; i < length1; i++) {
30763076
Combinator combinator = combinators1[i];
@@ -3092,8 +3092,8 @@ abstract class ImportDirective implements NamespaceDirective {
30923092
}
30933093
}
30943094
NodeList<Combinator> combinators2 = import2.combinators;
3095-
List<String> allHides2 = List<String>();
3096-
List<String> allShows2 = List<String>();
3095+
List<String> allHides2 = <String>[];
3096+
List<String> allShows2 = <String>[];
30973097
int length2 = combinators2.length;
30983098
for (int i = 0; i < length2; i++) {
30993099
Combinator combinator = combinators2[i];

pkg/analyzer/lib/error/listener.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ class ErrorReporter {
217217
Map<String, Set<Element>> nameToElementMap = {};
218218
for (_TypeToConvert typeToConvert in typeGroup) {
219219
for (Element element in typeToConvert.allElements()) {
220-
Set<Element> elements = nameToElementMap.putIfAbsent(
221-
element.name, () => Set<Element>());
220+
Set<Element> elements =
221+
nameToElementMap.putIfAbsent(element.name, () => <Element>{});
222222
elements.add(element);
223223
}
224224
}
@@ -311,7 +311,7 @@ class _TypeToConvert {
311311

312312
List<Element> allElements() {
313313
if (_allElements == null) {
314-
Set<Element> elements = Set<Element>();
314+
Set<Element> elements = <Element>{};
315315

316316
void addElementsFrom(DartType type) {
317317
if (type is FunctionType) {

pkg/analyzer/lib/src/dart/analysis/cache.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:collection';
6-
75
/**
86
* LRU cache of objects.
97
*/
108
class Cache<K, V> {
119
final int _maxSizeBytes;
1210
final int Function(V) _meter;
1311

14-
final _map = LinkedHashMap<K, V>();
12+
final _map = <K, V>{};
1513
int _currentSizeBytes = 0;
1614

1715
Cache(this._maxSizeBytes, this._meter);

pkg/analyzer/lib/src/dart/analysis/defined_names.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ DefinedNames computeDefinedNames(CompilationUnit unit) {
5151
* Defined top-level and class member names.
5252
*/
5353
class DefinedNames {
54-
final Set<String> topLevelNames = Set<String>();
55-
final Set<String> classMemberNames = Set<String>();
54+
final Set<String> topLevelNames = <String>{};
55+
final Set<String> classMemberNames = <String>{};
5656
}

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:collection';
76
import 'dart:typed_data';
87

98
import 'package:analyzer/dart/analysis/analysis_context.dart' as api;
@@ -151,7 +150,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
151150
2 + AnalysisOptions.signatureLength + _declaredVariablesSignatureLength);
152151

153152
/// The set of priority files, that should be analyzed sooner.
154-
final _priorityFiles = LinkedHashSet<String>();
153+
final _priorityFiles = <String>{};
155154

156155
/// The mapping from the files for which analysis was requested using
157156
/// [getResult] to the [Completer]s to report the result.
@@ -204,7 +203,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
204203
final _requestedParts = <String, List<Completer<ResolvedUnitResult>>>{};
205204

206205
/// The set of part files that are currently scheduled for analysis.
207-
final _partsToAnalyze = LinkedHashSet<String>();
206+
final _partsToAnalyze = <String>{};
208207

209208
/// The controller for the [results] stream.
210209
final _resultController = StreamController<ResolvedUnitResult>();
@@ -1722,7 +1721,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
17221721
String min = _twoDigits(time.minute);
17231722
String sec = _twoDigits(time.second);
17241723
String ms = _threeDigits(time.millisecond);
1725-
String key = 'exception_${time.year}$m$d' '_$h$min$sec' + '_$ms';
1724+
String key = 'exception_${time.year}$m${d}_$h$min${sec}_$ms';
17261725

17271726
_byteStore.put(key, bytes);
17281727
return key;
@@ -2202,7 +2201,7 @@ class _FilesDefiningClassMemberNameTask {
22022201
final Completer<List<String>> completer = Completer<List<String>>();
22032202

22042203
final List<String> definingFiles = <String>[];
2205-
final Set<String> checkedFiles = Set<String>();
2204+
final Set<String> checkedFiles = <String>{};
22062205
final List<String> filesToCheck = <String>[];
22072206

22082207
_FilesDefiningClassMemberNameTask(this.driver, this.name);

pkg/analyzer/lib/src/dart/analysis/file_state.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class FileState {
301301
* directly or indirectly referenced files.
302302
*/
303303
Set<FileState> get transitiveFiles {
304-
var transitiveFiles = Set<FileState>();
304+
var transitiveFiles = <FileState>{};
305305

306306
void appendReferenced(FileState file) {
307307
if (transitiveFiles.add(file)) {
@@ -487,22 +487,24 @@ class FileState {
487487
.putIfAbsent(file, () => <FileState>[])
488488
.add(this);
489489
}
490-
_libraryFiles = [this]..addAll(_partedFiles);
490+
_libraryFiles = [this, ..._partedFiles];
491491

492492
// Compute referenced files.
493-
_directReferencedFiles = Set<FileState>()
494-
..addAll(_importedFiles)
495-
..addAll(_exportedFiles)
496-
..addAll(_partedFiles);
497-
_directReferencedLibraries = Set<FileState>()
498-
..addAll(_importedFiles)
499-
..addAll(_exportedFiles);
493+
_directReferencedFiles = <FileState>{
494+
..._importedFiles,
495+
..._exportedFiles,
496+
..._partedFiles,
497+
};
498+
_directReferencedLibraries = <FileState>{
499+
..._importedFiles,
500+
..._exportedFiles,
501+
};
500502

501503
// Update mapping from subtyped names to files.
502504
for (var name in _driverUnlinkedUnit.subtypedNames) {
503505
var files = _fsState._subtypedNameToFiles[name];
504506
if (files == null) {
505-
files = Set<FileState>();
507+
files = <FileState>{};
506508
_fsState._subtypedNameToFiles[name] = files;
507509
}
508510
files.add(this);
@@ -735,7 +737,7 @@ class FileSystemState {
735737
/**
736738
* All known file paths.
737739
*/
738-
final Set<String> knownFilePaths = Set<String>();
740+
final Set<String> knownFilePaths = <String>{};
739741

740742
/**
741743
* All known files.

pkg/analyzer/lib/src/dart/analysis/file_tracker.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:collection';
6-
75
import 'package:analyzer/src/dart/analysis/file_state.dart';
86
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
97

@@ -47,37 +45,37 @@ class FileTracker {
4745
/**
4846
* The set of added files.
4947
*/
50-
final addedFiles = LinkedHashSet<String>();
48+
final addedFiles = <String>{};
5149

5250
/**
5351
* The set of files were reported as changed through [changeFile] and not
5452
* checked for actual changes yet.
5553
*/
56-
final _changedFiles = LinkedHashSet<String>();
54+
final _changedFiles = <String>{};
5755

5856
/**
5957
* The set of files that are currently scheduled for analysis, which were
6058
* reported as changed through [changeFile].
6159
*/
62-
var _pendingChangedFiles = LinkedHashSet<String>();
60+
var _pendingChangedFiles = <String>{};
6361

6462
/**
6563
* The set of files that are currently scheduled for analysis, which directly
6664
* import a changed file.
6765
*/
68-
var _pendingImportFiles = LinkedHashSet<String>();
66+
var _pendingImportFiles = <String>{};
6967

7068
/**
7169
* The set of files that are currently scheduled for analysis, which have an
7270
* error or a warning, which might be fixed by a changed file.
7371
*/
74-
var _pendingErrorFiles = LinkedHashSet<String>();
72+
var _pendingErrorFiles = <String>{};
7573

7674
/**
7775
* The set of files that are currently scheduled for analysis, and don't
7876
* have any special relation with changed files.
7977
*/
80-
var _pendingFiles = LinkedHashSet<String>();
78+
var _pendingFiles = <String>{};
8179

8280
FileTracker(this._logger, this._fsState, this._changeHook);
8381

@@ -238,10 +236,10 @@ class FileTracker {
238236
if (anyApiChanged) {
239237
_logger.writeln('API signatures mismatch found.');
240238
// TODO(scheglov) schedule analysis of only affected files
241-
var pendingChangedFiles = LinkedHashSet<String>();
242-
var pendingImportFiles = LinkedHashSet<String>();
243-
var pendingErrorFiles = LinkedHashSet<String>();
244-
var pendingFiles = LinkedHashSet<String>();
239+
var pendingChangedFiles = <String>{};
240+
var pendingImportFiles = <String>{};
241+
var pendingErrorFiles = <String>{};
242+
var pendingFiles = <String>{};
245243

246244
// Add the changed file.
247245
if (addedFiles.contains(path)) {

pkg/analyzer/lib/src/dart/analysis/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
884884
*/
885885
ConstructorElement _getActualConstructorElement(
886886
ConstructorElement constructor) {
887-
Set<ConstructorElement> seenConstructors = Set<ConstructorElement>();
887+
Set<ConstructorElement> seenConstructors = <ConstructorElement>{};
888888
while (constructor != null &&
889889
constructor.isSynthetic &&
890890
constructor.redirectedConstructor != null) {

pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ class LibraryAnalyzer {
9494
*
9595
* TODO(scheglov) Remove after https://github.com/dart-lang/sdk/issues/31925
9696
*/
97-
final Set<ConstantEvaluationTarget> _libraryConstants = Set();
97+
final Set<ConstantEvaluationTarget> _libraryConstants = {};
9898

99-
final Set<ConstantEvaluationTarget> _constants = Set();
99+
final Set<ConstantEvaluationTarget> _constants = {};
100100

101101
LibraryAnalyzer(
102102
this._analysisOptions,
@@ -558,7 +558,7 @@ class LibraryAnalyzer {
558558
ErrorReporter libraryErrorReporter = _getErrorReporter(_library);
559559

560560
LibraryIdentifier libraryNameNode;
561-
var seenPartSources = Set<Source>();
561+
var seenPartSources = <Source>{};
562562
var directivesToResolve = <Directive>[];
563563
int partIndex = 0;
564564
for (Directive directive in definingCompilationUnit.directives) {

pkg/analyzer/lib/src/dart/analysis/library_graph.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class LibraryCycle {
2222
final List<FileState> libraries = [];
2323

2424
/// The library cycles that this cycle references directly.
25-
final Set<LibraryCycle> directDependencies = Set<LibraryCycle>();
25+
final Set<LibraryCycle> directDependencies = <LibraryCycle>{};
2626

2727
/// The cycles that use this cycle, used to [invalidate] transitively.
2828
final List<LibraryCycle> _directUsers = [];

0 commit comments

Comments
 (0)