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

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

Issue 563333002: Issue 19799. Merge getter/setter pairs into fields when create missing overrides. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak for number of generated elements. Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.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 'package:analysis_server/src/protocol.dart' hide AnalysisError; 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
8 import 'package:analysis_server/src/services/correction/fix.dart'; 8 import 'package:analysis_server/src/services/correction/fix.dart';
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 10 import 'package:analysis_server/src/services/index/local_memory_index.dart';
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 492
493 class B extends A { 493 class B extends A {
494 @override 494 @override
495 Map<aaa.Future, List<aaa.Future>> g(aaa.Future p) { 495 Map<aaa.Future, List<aaa.Future>> g(aaa.Future p) {
496 // TODO: implement g 496 // TODO: implement g
497 } 497 }
498 } 498 }
499 '''); 499 ''');
500 } 500 }
501 501
502 void test_createMissingOverrides_mergeToField_getterSetter() {
503 _indexTestUnit('''
504 class A {
505 int ma;
506 void mb() {}
507 double mc;
508 }
509
510 class B implements A {
511 }
512 ''');
513 assertHasFix(FixKind.CREATE_MISSING_OVERRIDES, '''
514 class A {
515 int ma;
516 void mb() {}
517 double mc;
518 }
519
520 class B implements A {
521 int ma;
522
523 double mc;
524
525 @override
526 void mb() {
527 // TODO: implement mb
528 }
529 }
530 ''');
531 }
532
502 void test_createMissingOverrides_method() { 533 void test_createMissingOverrides_method() {
503 _indexTestUnit(''' 534 _indexTestUnit('''
504 abstract class A { 535 abstract class A {
505 m1(); 536 m1();
506 int m2(); 537 int m2();
507 String m3(int p1, double p2, Map<int, List<String>> p3); 538 String m3(int p1, double p2, Map<int, List<String>> p3);
508 String m4(p1, p2); 539 String m4(p1, p2);
509 String m5(p1, [int p2 = 2, int p3, p4 = 4]); 540 String m5(p1, [int p2 = 2, int p3, p4 = 4]);
510 String m6(p1, {int p2: 2, int p3, p4: 4}); 541 String m6(p1, {int p2: 2, int p3, p4: 4});
511 } 542 }
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 'dart:math'; 1302 'dart:math';
1272 main() { 1303 main() {
1273 } 1304 }
1274 '''); 1305 ''');
1275 assertHasFix(FixKind.REMOVE_UNUSED_IMPORT, ''' 1306 assertHasFix(FixKind.REMOVE_UNUSED_IMPORT, '''
1276 main() { 1307 main() {
1277 } 1308 }
1278 '''); 1309 ''');
1279 } 1310 }
1280 1311
1281 void test_replaceVarWithDynamic() {
1282 checkHasSingleError = false;
1283 _indexTestUnit('''
1284 class A {
1285 Map<String, var> m;
1286 }
1287 ''');
1288 assertHasFix(FixKind.REPLACE_VAR_WITH_DYNAMIC, '''
1289 class A {
1290 Map<String, dynamic> m;
1291 }
1292 ''');
1293 }
1294
1295 void test_replaceImportUri_inProject() { 1312 void test_replaceImportUri_inProject() {
1296 testFile = '/project/bin/test.dart'; 1313 testFile = '/project/bin/test.dart';
1297 addSource('/project/foo/bar/lib.dart', ''); 1314 addSource('/project/foo/bar/lib.dart', '');
1298 _indexTestUnit(''' 1315 _indexTestUnit('''
1299 import 'no/matter/lib.dart'; 1316 import 'no/matter/lib.dart';
1300 '''); 1317 ''');
1301 performAllAnalysisTasks(); 1318 performAllAnalysisTasks();
1302 assertHasFix(FixKind.REPLACE_IMPORT_URI, ''' 1319 assertHasFix(FixKind.REPLACE_IMPORT_URI, '''
1303 import '../foo/bar/lib.dart'; 1320 import '../foo/bar/lib.dart';
1304 '''); 1321 ''');
1305 } 1322 }
1306 1323
1307 void test_replaceImportUri_package() { 1324 void test_replaceImportUri_package() {
1308 _configureMyPkg(''); 1325 _configureMyPkg('');
1309 _indexTestUnit(''' 1326 _indexTestUnit('''
1310 import 'no/matter/my_lib.dart'; 1327 import 'no/matter/my_lib.dart';
1311 '''); 1328 ''');
1312 performAllAnalysisTasks(); 1329 performAllAnalysisTasks();
1313 assertHasFix(FixKind.REPLACE_IMPORT_URI, ''' 1330 assertHasFix(FixKind.REPLACE_IMPORT_URI, '''
1314 import 'package:my_pkg/my_lib.dart'; 1331 import 'package:my_pkg/my_lib.dart';
1315 '''); 1332 ''');
1316 } 1333 }
1317 1334
1335 void test_replaceVarWithDynamic() {
1336 checkHasSingleError = false;
1337 _indexTestUnit('''
1338 class A {
1339 Map<String, var> m;
1340 }
1341 ''');
1342 assertHasFix(FixKind.REPLACE_VAR_WITH_DYNAMIC, '''
1343 class A {
1344 Map<String, dynamic> m;
1345 }
1346 ''');
1347 }
1348
1318 void test_replaceWithConstInstanceCreation() { 1349 void test_replaceWithConstInstanceCreation() {
1319 _indexTestUnit(''' 1350 _indexTestUnit('''
1320 class A { 1351 class A {
1321 const A(); 1352 const A();
1322 } 1353 }
1323 const a = new A(); 1354 const a = new A();
1324 '''); 1355 ''');
1325 assertHasFix(FixKind.USE_CONST, ''' 1356 assertHasFix(FixKind.USE_CONST, '''
1326 class A { 1357 class A {
1327 const A(); 1358 const A();
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 positions.add(new Position(testFile, offset)); 1940 positions.add(new Position(testFile, offset));
1910 } 1941 }
1911 return positions; 1942 return positions;
1912 } 1943 }
1913 1944
1914 void _indexTestUnit(String code) { 1945 void _indexTestUnit(String code) {
1915 resolveTestUnit(code); 1946 resolveTestUnit(code);
1916 index.indexUnit(context, testUnit); 1947 index.indexUnit(context, testUnit);
1917 } 1948 }
1918 } 1949 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698