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 '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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 main() { | 720 main() { |
721 A a = new A(); | 721 A a = new A(); |
722 a..ma().useFunction(test); | 722 a..ma().useFunction(test); |
723 } | 723 } |
724 | 724 |
725 int test(double a, String b) { | 725 int test(double a, String b) { |
726 } | 726 } |
727 '''); | 727 '''); |
728 } | 728 } |
729 | 729 |
| 730 void test_creationFunction_forFunctionType_coreFunction() { |
| 731 _indexTestUnit(''' |
| 732 main() { |
| 733 useFunction(g: test); |
| 734 } |
| 735 useFunction({Function g}) {} |
| 736 '''); |
| 737 assertHasFix(FixKind.CREATE_FUNCTION, ''' |
| 738 main() { |
| 739 useFunction(g: test); |
| 740 } |
| 741 useFunction({Function g}) {} |
| 742 |
| 743 test() { |
| 744 } |
| 745 '''); |
| 746 } |
| 747 |
730 void test_creationFunction_forFunctionType_dynamicArgument() { | 748 void test_creationFunction_forFunctionType_dynamicArgument() { |
731 _indexTestUnit(''' | 749 _indexTestUnit(''' |
732 main() { | 750 main() { |
733 useFunction(test); | 751 useFunction(test); |
734 } | 752 } |
735 useFunction(int g(a, b)) {} | 753 useFunction(int g(a, b)) {} |
736 '''); | 754 '''); |
737 assertHasFix(FixKind.CREATE_FUNCTION, ''' | 755 assertHasFix(FixKind.CREATE_FUNCTION, ''' |
738 main() { | 756 main() { |
739 useFunction(test); | 757 useFunction(test); |
(...skipping 16 matching lines...) Expand all Loading... |
756 main() { | 774 main() { |
757 useFunction(test); | 775 useFunction(test); |
758 } | 776 } |
759 useFunction(int g(double a, String b)) {} | 777 useFunction(int g(double a, String b)) {} |
760 | 778 |
761 int test(double a, String b) { | 779 int test(double a, String b) { |
762 } | 780 } |
763 '''); | 781 '''); |
764 } | 782 } |
765 | 783 |
| 784 void test_creationFunction_forFunctionType_function_namedArgument() { |
| 785 _indexTestUnit(''' |
| 786 main() { |
| 787 useFunction(g: test); |
| 788 } |
| 789 useFunction({int g(double a, String b)}) {} |
| 790 '''); |
| 791 assertHasFix(FixKind.CREATE_FUNCTION, ''' |
| 792 main() { |
| 793 useFunction(g: test); |
| 794 } |
| 795 useFunction({int g(double a, String b)}) {} |
| 796 |
| 797 int test(double a, String b) { |
| 798 } |
| 799 '''); |
| 800 } |
| 801 |
766 void test_creationFunction_forFunctionType_method_enclosingClass_static() { | 802 void test_creationFunction_forFunctionType_method_enclosingClass_static() { |
767 _indexTestUnit(''' | 803 _indexTestUnit(''' |
768 class A { | 804 class A { |
769 static foo() { | 805 static foo() { |
770 useFunction(test); | 806 useFunction(test); |
771 } | 807 } |
772 } | 808 } |
773 useFunction(int g(double a, String b)) {} | 809 useFunction(int g(double a, String b)) {} |
774 '''); | 810 '''); |
775 assertHasFix(FixKind.CREATE_METHOD, ''' | 811 assertHasFix(FixKind.CREATE_METHOD, ''' |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 positions.add(new Position(testFile, offset)); | 1976 positions.add(new Position(testFile, offset)); |
1941 } | 1977 } |
1942 return positions; | 1978 return positions; |
1943 } | 1979 } |
1944 | 1980 |
1945 void _indexTestUnit(String code) { | 1981 void _indexTestUnit(String code) { |
1946 resolveTestUnit(code); | 1982 resolveTestUnit(code); |
1947 index.indexUnit(context, testUnit); | 1983 index.indexUnit(context, testUnit); |
1948 } | 1984 } |
1949 } | 1985 } |
OLD | NEW |