Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1040 | 1040 |
| 1041 method() {} | 1041 method() {} |
| 1042 } | 1042 } |
| 1043 main() { | 1043 main() { |
| 1044 new A.named(1, 2.0); | 1044 new A.named(1, 2.0); |
| 1045 } | 1045 } |
| 1046 '''); | 1046 '''); |
| 1047 _assertLinkedGroup(change.linkedEditGroups[0], ['named(int ', 'named(1']); | 1047 _assertLinkedGroup(change.linkedEditGroups[0], ['named(int ', 'named(1']); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 test_createConstructor_named_emptyClassBody() async { | |
| 1051 resolveTestUnit(''' | |
| 1052 class A {} | |
| 1053 main() { | |
| 1054 new A.named(1); | |
| 1055 } | |
| 1056 '''); | |
| 1057 await assertHasFix( | |
| 1058 DartFixKind.CREATE_CONSTRUCTOR, | |
| 1059 ''' | |
| 1060 class A { | |
| 1061 A.named(int i) { | |
|
Brian Wilkerson
2016/08/16 21:58:17
If it has an empty body, should we just produce a
scheglov
2016/08/16 22:13:06
Good idea.
Thank you.
Fixed.
| |
| 1062 } | |
| 1063 } | |
| 1064 main() { | |
| 1065 new A.named(1); | |
| 1066 } | |
| 1067 '''); | |
| 1068 _assertLinkedGroup(change.linkedEditGroups[0], ['named(int ', 'named(1']); | |
| 1069 } | |
| 1070 | |
| 1050 test_createConstructorForFinalFields_inTopLevelMethod() async { | 1071 test_createConstructorForFinalFields_inTopLevelMethod() async { |
| 1051 resolveTestUnit(''' | 1072 resolveTestUnit(''' |
| 1052 main() { | 1073 main() { |
| 1053 final int v; | 1074 final int v; |
| 1054 } | 1075 } |
| 1055 '''); | 1076 '''); |
| 1056 await assertNoFix(DartFixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS); | 1077 await assertNoFix(DartFixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS); |
| 1057 } | 1078 } |
| 1058 | 1079 |
| 1059 test_createConstructorForFinalFields_topLevelField() async { | 1080 test_createConstructorForFinalFields_topLevelField() async { |
| (...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2562 String endString = expectedCode.substring(endOffset, endOffset + 25); | 2583 String endString = expectedCode.substring(endOffset, endOffset + 25); |
| 2563 expect(endString, contains('m1')); | 2584 expect(endString, contains('m1')); |
| 2564 expect(endString, isNot(contains('m2'))); | 2585 expect(endString, isNot(contains('m2'))); |
| 2565 expect(endString, isNot(contains('m3'))); | 2586 expect(endString, isNot(contains('m3'))); |
| 2566 expect(endString, isNot(contains('m4'))); | 2587 expect(endString, isNot(contains('m4'))); |
| 2567 expect(endString, isNot(contains('m5'))); | 2588 expect(endString, isNot(contains('m5'))); |
| 2568 expect(endString, isNot(contains('m6'))); | 2589 expect(endString, isNot(contains('m6'))); |
| 2569 } | 2590 } |
| 2570 } | 2591 } |
| 2571 | 2592 |
| 2593 test_createMissingOverrides_method_emptyClassBody() async { | |
| 2594 resolveTestUnit(''' | |
| 2595 abstract class A { | |
| 2596 void foo(); | |
| 2597 } | |
| 2598 | |
| 2599 class B extends A {} | |
| 2600 '''); | |
| 2601 await assertHasFix( | |
| 2602 DartFixKind.CREATE_MISSING_OVERRIDES, | |
| 2603 ''' | |
| 2604 abstract class A { | |
| 2605 void foo(); | |
| 2606 } | |
| 2607 | |
| 2608 class B extends A { | |
| 2609 @override | |
| 2610 void foo() { | |
| 2611 // TODO: implement foo | |
| 2612 } | |
| 2613 } | |
| 2614 '''); | |
| 2615 } | |
| 2616 | |
| 2572 test_createMissingOverrides_operator() async { | 2617 test_createMissingOverrides_operator() async { |
| 2573 resolveTestUnit(''' | 2618 resolveTestUnit(''' |
| 2574 abstract class A { | 2619 abstract class A { |
| 2575 int operator [](int index); | 2620 int operator [](int index); |
| 2576 void operator []=(int index, String value); | 2621 void operator []=(int index, String value); |
| 2577 } | 2622 } |
| 2578 | 2623 |
| 2579 class B extends A { | 2624 class B extends A { |
| 2580 } | 2625 } |
| 2581 '''); | 2626 '''); |
| (...skipping 2750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5332 @override | 5377 @override |
| 5333 void t() { } | 5378 void t() { } |
| 5334 } | 5379 } |
| 5335 '''); | 5380 '''); |
| 5336 } | 5381 } |
| 5337 | 5382 |
| 5338 void verifyResult(String expectedResult) { | 5383 void verifyResult(String expectedResult) { |
| 5339 expect(resultCode, expectedResult); | 5384 expect(resultCode, expectedResult); |
| 5340 } | 5385 } |
| 5341 } | 5386 } |
| OLD | NEW |