Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 2827863003: Revert "New Lint quick-fix: prefer_collection_literals (#29378)" (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
(...skipping 5940 matching lines...) Expand 10 before | Expand all | Expand 10 after
5951 '''; 5951 ''';
5952 await findLint(src, LintNames.avoid_init_to_null); 5952 await findLint(src, LintNames.avoid_init_to_null);
5953 5953
5954 await applyFix(DartFixKind.REMOVE_INITIALIZER); 5954 await applyFix(DartFixKind.REMOVE_INITIALIZER);
5955 5955
5956 verifyResult(''' 5956 verifyResult('''
5957 var x; 5957 var x;
5958 '''); 5958 ''');
5959 } 5959 }
5960 5960
5961 test_replaceWithLiteral_linkedHashMap_withCommentsInGeneric() async {
5962 String src = '''
5963 final a = /*LINT*/new LinkedHashMap<int,/*comment*/int>();
5964 ''';
5965 await findLint(src, LintNames.prefer_collection_literals);
5966
5967 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
5968
5969 verifyResult('''
5970 final a = <int,/*comment*/int>{};
5971 ''');
5972 }
5973
5974 test_replaceWithLiteral_linkedHashMap_withDynamicGenerics() async {
5975 String src = '''
5976 final a = /*LINT*/new LinkedHashMap<dynamic,dynamic>();
5977 ''';
5978 await findLint(src, LintNames.prefer_collection_literals);
5979
5980 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
5981
5982 verifyResult('''
5983 final a = <dynamic,dynamic>{};
5984 ''');
5985 }
5986
5987 test_replaceWithLiteral_linkedHashMap_withGeneric() async {
5988 String src = '''
5989 final a = /*LINT*/new LinkedHashMap<int,int>();
5990 ''';
5991 await findLint(src, LintNames.prefer_collection_literals);
5992
5993 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
5994
5995 verifyResult('''
5996 final a = <int,int>{};
5997 ''');
5998 }
5999
6000 test_replaceWithLiteral_linkedHashMap_withoutGeneric() async {
6001 String src = '''
6002 final a = /*LINT*/new LinkedHashMap();
6003 ''';
6004 await findLint(src, LintNames.prefer_collection_literals);
6005
6006 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
6007
6008 verifyResult('''
6009 final a = {};
6010 ''');
6011 }
6012
6013 test_replaceWithLiteral_list_withGeneric() async {
6014 String src = '''
6015 final a = /*LINT*/new List<int>();
6016 ''';
6017 await findLint(src, LintNames.prefer_collection_literals);
6018
6019 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
6020
6021 verifyResult('''
6022 final a = <int>[];
6023 ''');
6024 }
6025
6026 test_replaceWithLiteral_list_withoutGeneric() async {
6027 String src = '''
6028 final a = /*LINT*/new List();
6029 ''';
6030 await findLint(src, LintNames.prefer_collection_literals);
6031
6032 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
6033
6034 verifyResult('''
6035 final a = [];
6036 ''');
6037 }
6038
6039 test_replaceWithLiteral_map_withGeneric() async {
6040 String src = '''
6041 final a = /*LINT*/new Map<int,int>();
6042 ''';
6043 await findLint(src, LintNames.prefer_collection_literals);
6044
6045 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
6046
6047 verifyResult('''
6048 final a = <int,int>{};
6049 ''');
6050 }
6051
6052 test_replaceWithLiteral_map_withoutGeneric() async {
6053 String src = '''
6054 final a = /*LINT*/new Map();
6055 ''';
6056 await findLint(src, LintNames.prefer_collection_literals);
6057
6058 await applyFix(DartFixKind.REPLACE_WITH_LITERAL);
6059
6060 verifyResult('''
6061 final a = {};
6062 ''');
6063 }
6064
6065 void verifyResult(String expectedResult) { 5961 void verifyResult(String expectedResult) {
6066 expect(resultCode, expectedResult); 5962 expect(resultCode, expectedResult);
6067 } 5963 }
6068 } 5964 }
6069 5965
6070 @reflectiveTest 5966 @reflectiveTest
6071 class LintFixTest_Driver extends LintFixTest { 5967 class LintFixTest_Driver extends LintFixTest {
6072 @override 5968 @override
6073 bool get enableNewAnalysisDriver => true; 5969 bool get enableNewAnalysisDriver => true;
6074 } 5970 }
(...skipping 13 matching lines...) Expand all
6088 5984
6089 @override 5985 @override
6090 final CompilationUnit unit; 5986 final CompilationUnit unit;
6091 5987
6092 @override 5988 @override
6093 final AnalysisError error; 5989 final AnalysisError error;
6094 5990
6095 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, 5991 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations,
6096 this.analysisContext, this.astProvider, this.unit, this.error); 5992 this.analysisContext, this.astProvider, this.unit, this.error);
6097 } 5993 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698