Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 32ce9c7

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Enable prefer_collection_literals in three packages
Other than the following changes, all of the changes were made by dartfix: - the analysis options files - one line to enable the fix through dartfix (missed in an earlier CL) - three places where a bug in the fix produced invalid code (issue and fix TBD) Change-Id: If8660700792561805f4d1c96ccecd81abcebfeb8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131209 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 3c22953 commit 32ce9c7

File tree

66 files changed

+154
-155
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

+154
-155
lines changed

pkg/analysis_server/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ linter:
3838
- camel_case_extensions
3939
#- omit_local_variable_types # 8650
4040
- prefer_adjacent_string_concatenation
41-
#- prefer_collection_literals # 130
41+
- prefer_collection_literals
4242
- prefer_conditional_assignment
4343
#- prefer_final_fields # 35
4444
- prefer_for_elements_to_map_fromIterable

pkg/analysis_server/benchmark/benchmarks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class CompoundBenchMarkResult extends BenchMarkResult {
219219

220220
CompoundBenchMarkResult combined = CompoundBenchMarkResult(name);
221221
List<String> keys =
222-
(Set<String>()..addAll(results.keys)..addAll(o.results.keys)).toList();
222+
(<String>{}..addAll(results.keys)..addAll(o.results.keys)).toList();
223223

224224
for (String key in keys) {
225225
combined.add(key, _combine(results[key], o.results[key]));

pkg/analysis_server/benchmark/integration/driver.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Driver extends IntegrationTestMixin {
153153
class Measurement {
154154
final String tag;
155155
final bool notification;
156-
final List<Duration> elapsedTimes = List<Duration>();
156+
final List<Duration> elapsedTimes = <Duration>[];
157157
int errorCount = 0;
158158
int unexpectedResultCount = 0;
159159

@@ -223,7 +223,7 @@ class Measurement {
223223
* while running the analysis server
224224
*/
225225
class Results {
226-
Map<String, Measurement> measurements = Map<String, Measurement>();
226+
Map<String, Measurement> measurements = <String, Measurement>{};
227227

228228
/**
229229
* Display results on stdout.

pkg/analysis_server/benchmark/integration/input_converter.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import 'operation.dart';
2323
abstract class CommonInputConverter extends Converter<String, Operation> {
2424
static final ERROR_PREFIX = 'Server responded with an error: ';
2525
final Logger logger = Logger('InstrumentationInputConverter');
26-
final Set<String> eventsSeen = Set<String>();
26+
final Set<String> eventsSeen = <String>{};
2727

2828
/**
2929
* A mapping from request/response id to request json
@@ -256,7 +256,7 @@ abstract class CommonInputConverter extends Converter<String, Operation> {
256256
return result;
257257
}
258258
if (json is Map) {
259-
Map<String, dynamic> result = Map<String, dynamic>();
259+
Map<String, dynamic> result = <String, dynamic>{};
260260
json.forEach((origKey, value) {
261261
result[translateSrcPaths(origKey)] = translateSrcPaths(value);
262262
});

pkg/analysis_server/benchmark/integration/instrumentation_input_converter.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final int COLON = ':'.codeUnitAt(0);
1818
* into a series of operations to be sent to the analysis server.
1919
*/
2020
class InstrumentationInputConverter extends CommonInputConverter {
21-
final Set<String> codesSeen = Set<String>();
21+
final Set<String> codesSeen = <String>{};
2222

2323
/**
2424
* [readBuffer] holds the contents of the file being read from disk
@@ -106,7 +106,7 @@ class InstrumentationInputConverter extends CommonInputConverter {
106106
* Extract fields from the given [line].
107107
*/
108108
static List<String> _parseFields(String line) {
109-
List<String> fields = List<String>();
109+
List<String> fields = <String>[];
110110
int index = 0;
111111
StringBuffer sb = StringBuffer();
112112
while (index < line.length) {

pkg/analysis_server/lib/src/analysis_server_abstract.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ abstract class AbstractAnalysisServer {
7272
final ServerPerformance performanceDuringStartup = ServerPerformance();
7373

7474
/// The set of the files that are currently priority.
75-
final Set<String> priorityFiles = Set<String>();
75+
final Set<String> priorityFiles = <String>{};
7676

7777
final List<String> analyzableFilePatterns = <String>[
7878
'**/*.${AnalysisEngine.SUFFIX_DART}',

pkg/analysis_server/lib/src/computer/computer_closingLabels.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class DartUnitClosingLabelsComputer {
1515
final LineInfo _lineInfo;
1616
final CompilationUnit _unit;
1717
final List<ClosingLabel> _closingLabels = [];
18-
final Set<ClosingLabel> hasNestingSet = Set();
19-
final Set<ClosingLabel> isSingleLineSet = Set();
18+
final Set<ClosingLabel> hasNestingSet = {};
19+
final Set<ClosingLabel> isSingleLineSet = {};
2020

2121
DartUnitClosingLabelsComputer(this._lineInfo, this._unit);
2222

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class ContextInfo {
120120
* be watched for changes. I believe the use case for watching these files
121121
* is no longer relevant.
122122
*/
123-
Set<String> _dependencies = Set<String>();
123+
Set<String> _dependencies = <String>{};
124124

125125
/**
126126
* The analysis driver that was created for the [folder].
@@ -1062,7 +1062,7 @@ class ContextManagerImpl implements ContextManager {
10621062
// TODO(paulberry): We shouldn't be using JavaFile here because it
10631063
// makes the code untestable (see dartbug.com/23909).
10641064
JavaFile packagesDirOrFile = JavaFile(packageRoot);
1065-
Map<String, List<Folder>> packageMap = Map<String, List<Folder>>();
1065+
Map<String, List<Folder>> packageMap = <String, List<Folder>>{};
10661066
if (packagesDirOrFile.isDirectory()) {
10671067
for (JavaFile file in packagesDirOrFile.listFiles()) {
10681068
// Ensure symlinks in packages directory are canonicalized

pkg/analysis_server/lib/src/domain_analysis.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class AnalysisDomainHandler extends AbstractRequestHandler {
484484
// options
485485
var params = AnalysisUpdateOptionsParams.fromRequest(request);
486486
AnalysisOptions newOptions = params.options;
487-
List<OptionUpdater> updaters = List<OptionUpdater>();
487+
List<OptionUpdater> updaters = <OptionUpdater>[];
488488
if (newOptions.generateDart2jsHints != null) {
489489
updaters.add((engine.AnalysisOptionsImpl options) {
490490
options.dart2jsHint = newOptions.generateDart2jsHints;

pkg/analysis_server/lib/src/domain_completion.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
4141
/**
4242
* The completion services that the client is currently subscribed.
4343
*/
44-
final Set<CompletionService> subscriptions = Set<CompletionService>();
44+
final Set<CompletionService> subscriptions = <CompletionService>{};
4545

4646
/**
4747
* The next completion response id.
@@ -354,8 +354,8 @@ class CompletionDomainHandler extends AbstractRequestHandler {
354354
Set<String> includedElementNames;
355355
List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags;
356356
if (subscriptions.contains(CompletionService.AVAILABLE_SUGGESTION_SETS)) {
357-
includedElementKinds = Set<ElementKind>();
358-
includedElementNames = Set<String>();
357+
includedElementKinds = <ElementKind>{};
358+
includedElementNames = <String>{};
359359
includedSuggestionRelevanceTags = <IncludedSuggestionRelevanceTag>[];
360360
}
361361

0 commit comments

Comments
 (0)