| 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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 '''); | 701 '''); |
| 702 resolveTestUnit(''' | 702 resolveTestUnit(''' |
| 703 import 'libB.dart'; | 703 import 'libB.dart'; |
| 704 main(B b) { | 704 main(B b) { |
| 705 b.foo(); | 705 b.foo(); |
| 706 } | 706 } |
| 707 '''); | 707 '''); |
| 708 await assertHasFix( | 708 await assertHasFix( |
| 709 DartFixKind.CHANGE_TO_STATIC_ACCESS, | 709 DartFixKind.CHANGE_TO_STATIC_ACCESS, |
| 710 ''' | 710 ''' |
| 711 import 'libA.dart'; |
| 711 import 'libB.dart'; | 712 import 'libB.dart'; |
| 712 import 'libA.dart'; | |
| 713 main(B b) { | 713 main(B b) { |
| 714 A.foo(); | 714 A.foo(); |
| 715 } | 715 } |
| 716 '''); | 716 '''); |
| 717 } | 717 } |
| 718 | 718 |
| 719 test_changeToStaticAccess_method_prefixLibrary() async { | 719 test_changeToStaticAccess_method_prefixLibrary() async { |
| 720 resolveTestUnit(''' | 720 resolveTestUnit(''' |
| 721 import 'dart:async' as pref; | 721 import 'dart:async' as pref; |
| 722 main(pref.Future f) { | 722 main(pref.Future f) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 '''); | 772 '''); |
| 773 resolveTestUnit(''' | 773 resolveTestUnit(''' |
| 774 import 'libB.dart'; | 774 import 'libB.dart'; |
| 775 main(B b) { | 775 main(B b) { |
| 776 b.foo; | 776 b.foo; |
| 777 } | 777 } |
| 778 '''); | 778 '''); |
| 779 await assertHasFix( | 779 await assertHasFix( |
| 780 DartFixKind.CHANGE_TO_STATIC_ACCESS, | 780 DartFixKind.CHANGE_TO_STATIC_ACCESS, |
| 781 ''' | 781 ''' |
| 782 import 'libA.dart'; |
| 782 import 'libB.dart'; | 783 import 'libB.dart'; |
| 783 import 'libA.dart'; | |
| 784 main(B b) { | 784 main(B b) { |
| 785 A.foo; | 785 A.foo; |
| 786 } | 786 } |
| 787 '''); | 787 '''); |
| 788 } | 788 } |
| 789 | 789 |
| 790 test_changeTypeAnnotation_BAD_multipleVariables() async { | 790 test_changeTypeAnnotation_BAD_multipleVariables() async { |
| 791 resolveTestUnit(''' | 791 resolveTestUnit(''' |
| 792 main() { | 792 main() { |
| 793 String a, b = 42; | 793 String a, b = 42; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 } | 1232 } |
| 1233 '''); | 1233 '''); |
| 1234 resolveTestUnit(''' | 1234 resolveTestUnit(''' |
| 1235 import 'libB.dart'; | 1235 import 'libB.dart'; |
| 1236 class C extends B { | 1236 class C extends B { |
| 1237 } | 1237 } |
| 1238 '''); | 1238 '''); |
| 1239 await assertHasFix( | 1239 await assertHasFix( |
| 1240 DartFixKind.CREATE_CONSTRUCTOR_SUPER, | 1240 DartFixKind.CREATE_CONSTRUCTOR_SUPER, |
| 1241 ''' | 1241 ''' |
| 1242 import 'libA.dart'; |
| 1242 import 'libB.dart'; | 1243 import 'libB.dart'; |
| 1243 import 'libA.dart'; | |
| 1244 class C extends B { | 1244 class C extends B { |
| 1245 C(A a) : super(a); | 1245 C(A a) : super(a); |
| 1246 } | 1246 } |
| 1247 '''); | 1247 '''); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 test_createConstructorSuperImplicit_named() async { | 1250 test_createConstructorSuperImplicit_named() async { |
| 1251 resolveTestUnit(''' | 1251 resolveTestUnit(''' |
| 1252 class A { | 1252 class A { |
| 1253 A.named(p1, int p2); | 1253 A.named(p1, int p2); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 import 'libB.dart'; | 1556 import 'libB.dart'; |
| 1557 class C { | 1557 class C { |
| 1558 } | 1558 } |
| 1559 main(C c) { | 1559 main(C c) { |
| 1560 c.test = getA(); | 1560 c.test = getA(); |
| 1561 } | 1561 } |
| 1562 '''); | 1562 '''); |
| 1563 await assertHasFix( | 1563 await assertHasFix( |
| 1564 DartFixKind.CREATE_FIELD, | 1564 DartFixKind.CREATE_FIELD, |
| 1565 ''' | 1565 ''' |
| 1566 import 'libA.dart'; |
| 1566 import 'libB.dart'; | 1567 import 'libB.dart'; |
| 1567 import 'libA.dart'; | |
| 1568 class C { | 1568 class C { |
| 1569 A test; | 1569 A test; |
| 1570 } | 1570 } |
| 1571 main(C c) { | 1571 main(C c) { |
| 1572 c.test = getA(); | 1572 c.test = getA(); |
| 1573 } | 1573 } |
| 1574 '''); | 1574 '''); |
| 1575 } | 1575 } |
| 1576 | 1576 |
| 1577 test_createField_setter_generic_BAD() async { | 1577 test_createField_setter_generic_BAD() async { |
| (...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2795 '''); | 2795 '''); |
| 2796 resolveTestUnit(''' | 2796 resolveTestUnit(''' |
| 2797 import 'libB.dart'; | 2797 import 'libB.dart'; |
| 2798 main() { | 2798 main() { |
| 2799 useFunction(test); | 2799 useFunction(test); |
| 2800 } | 2800 } |
| 2801 '''); | 2801 '''); |
| 2802 await assertHasFix( | 2802 await assertHasFix( |
| 2803 DartFixKind.CREATE_FUNCTION, | 2803 DartFixKind.CREATE_FUNCTION, |
| 2804 ''' | 2804 ''' |
| 2805 import 'libA.dart'; |
| 2805 import 'libB.dart'; | 2806 import 'libB.dart'; |
| 2806 import 'libA.dart'; | |
| 2807 main() { | 2807 main() { |
| 2808 useFunction(test); | 2808 useFunction(test); |
| 2809 } | 2809 } |
| 2810 | 2810 |
| 2811 int test(A a) { | 2811 int test(A a) { |
| 2812 } | 2812 } |
| 2813 '''); | 2813 '''); |
| 2814 } | 2814 } |
| 2815 | 2815 |
| 2816 test_creationFunction_forFunctionType_method_enclosingClass_static() async { | 2816 test_creationFunction_forFunctionType_method_enclosingClass_static() async { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 }; | 2969 }; |
| 2970 resolveTestUnit(''' | 2970 resolveTestUnit(''' |
| 2971 library main; | 2971 library main; |
| 2972 int main() async { | 2972 int main() async { |
| 2973 } | 2973 } |
| 2974 '''); | 2974 '''); |
| 2975 await assertHasFix( | 2975 await assertHasFix( |
| 2976 DartFixKind.REPLACE_RETURN_TYPE_FUTURE, | 2976 DartFixKind.REPLACE_RETURN_TYPE_FUTURE, |
| 2977 ''' | 2977 ''' |
| 2978 library main; | 2978 library main; |
| 2979 |
| 2979 import 'dart:async'; | 2980 import 'dart:async'; |
| 2980 Future<int> main() async { | 2981 Future<int> main() async { |
| 2981 } | 2982 } |
| 2982 '''); | 2983 '''); |
| 2983 } | 2984 } |
| 2984 | 2985 |
| 2985 test_illegalAsyncReturnType_asyncLibrary_usePrefix() async { | 2986 test_illegalAsyncReturnType_asyncLibrary_usePrefix() async { |
| 2986 errorFilter = (AnalysisError error) { | 2987 errorFilter = (AnalysisError error) { |
| 2987 return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; | 2988 return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; |
| 2988 }; | 2989 }; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3104 import 'b.dart' show Two; | 3105 import 'b.dart' show Two; |
| 3105 main () { | 3106 main () { |
| 3106 new Two(); | 3107 new Two(); |
| 3107 new One(); | 3108 new One(); |
| 3108 } | 3109 } |
| 3109 '''); | 3110 '''); |
| 3110 performAllAnalysisTasks(); | 3111 performAllAnalysisTasks(); |
| 3111 await assertHasFix( | 3112 await assertHasFix( |
| 3112 DartFixKind.IMPORT_LIBRARY_PROJECT, | 3113 DartFixKind.IMPORT_LIBRARY_PROJECT, |
| 3113 ''' | 3114 ''' |
| 3115 import 'a.dart'; |
| 3114 import 'b.dart' show Two; | 3116 import 'b.dart' show Two; |
| 3115 import 'a.dart'; | |
| 3116 main () { | 3117 main () { |
| 3117 new Two(); | 3118 new Two(); |
| 3118 new One(); | 3119 new One(); |
| 3119 } | 3120 } |
| 3120 '''); | 3121 '''); |
| 3121 } | 3122 } |
| 3122 | 3123 |
| 3123 test_importLibraryProject_withClass_inParentFolder() async { | 3124 test_importLibraryProject_withClass_inParentFolder() async { |
| 3124 testFile = '/project/bin/test.dart'; | 3125 testFile = '/project/bin/test.dart'; |
| 3125 addSource( | 3126 addSource( |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4124 '''); | 4125 '''); |
| 4125 resolveTestUnit(''' | 4126 resolveTestUnit(''' |
| 4126 import 'lib.dart'; | 4127 import 'lib.dart'; |
| 4127 main() { | 4128 main() { |
| 4128 test(getFuture()); | 4129 test(getFuture()); |
| 4129 } | 4130 } |
| 4130 '''); | 4131 '''); |
| 4131 await assertHasFix( | 4132 await assertHasFix( |
| 4132 DartFixKind.CREATE_FUNCTION, | 4133 DartFixKind.CREATE_FUNCTION, |
| 4133 ''' | 4134 ''' |
| 4135 import 'dart:async'; |
| 4134 import 'lib.dart'; | 4136 import 'lib.dart'; |
| 4135 import 'dart:async'; | |
| 4136 main() { | 4137 main() { |
| 4137 test(getFuture()); | 4138 test(getFuture()); |
| 4138 } | 4139 } |
| 4139 | 4140 |
| 4140 void test(Future future) { | 4141 void test(Future future) { |
| 4141 } | 4142 } |
| 4142 '''); | 4143 '''); |
| 4143 } | 4144 } |
| 4144 | 4145 |
| 4145 test_undefinedFunction_create_nullArgument() async { | 4146 test_undefinedFunction_create_nullArgument() async { |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5329 @override | 5330 @override |
| 5330 void t() { } | 5331 void t() { } |
| 5331 } | 5332 } |
| 5332 '''); | 5333 '''); |
| 5333 } | 5334 } |
| 5334 | 5335 |
| 5335 void verifyResult(String expectedResult) { | 5336 void verifyResult(String expectedResult) { |
| 5336 expect(resultCode, expectedResult); | 5337 expect(resultCode, expectedResult); |
| 5337 } | 5338 } |
| 5338 } | 5339 } |
| OLD | NEW |