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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/src/services/correction/status.dart'; | 7 import 'package:analysis_server/src/services/correction/status.dart'; |
8 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; | 8 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; |
9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
10 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 10 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 RefactoringStatus status = await refactoring.checkInitialConditions(); | 887 RefactoringStatus status = await refactoring.checkInitialConditions(); |
888 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, | 888 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, |
889 expectedMessage: | 889 expectedMessage: |
890 'Cannot extract closure as method, it references 1 external variable
(s).'); | 890 'Cannot extract closure as method, it references 1 external variable
(s).'); |
891 } | 891 } |
892 | 892 |
893 test_fromTopLevelVariableInitializerClosure() async { | 893 test_fromTopLevelVariableInitializerClosure() async { |
894 await indexTestUnit(''' | 894 await indexTestUnit(''' |
895 var X = 1; | 895 var X = 1; |
896 | 896 |
897 var Y = () { | 897 dynamic Y = () { |
898 return 1 + X; | 898 return 1 + X; |
899 }; | 899 }; |
900 '''); | 900 '''); |
901 _createRefactoringForString('1 + X'); | 901 _createRefactoringForString('1 + X'); |
902 // apply refactoring | 902 // apply refactoring |
903 return _assertSuccessfulRefactoring(''' | 903 return _assertSuccessfulRefactoring(''' |
904 var X = 1; | 904 var X = 1; |
905 | 905 |
906 var Y = () { | 906 dynamic Y = () { |
907 return res(); | 907 return res(); |
908 }; | 908 }; |
909 | 909 |
910 num res() => 1 + X; | 910 int res() => 1 + X; |
911 '''); | 911 '''); |
912 } | 912 } |
913 | 913 |
914 test_getExtractGetter_expression_true_binaryExpression() async { | 914 test_getExtractGetter_expression_true_binaryExpression() async { |
915 await indexTestUnit(''' | 915 await indexTestUnit(''' |
916 main() { | 916 main() { |
917 print(1 + 2); | 917 print(1 + 2); |
918 } | 918 } |
919 '''); | 919 '''); |
920 _createRefactoringForString('1 + 2'); | 920 _createRefactoringForString('1 + 2'); |
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2833 * Returns a deep copy of [refactoring] parameters. | 2833 * Returns a deep copy of [refactoring] parameters. |
2834 * There was a bug masked by updating parameter instances shared between the | 2834 * There was a bug masked by updating parameter instances shared between the |
2835 * refactoring and the test. | 2835 * refactoring and the test. |
2836 */ | 2836 */ |
2837 List<RefactoringMethodParameter> _getParametersCopy() { | 2837 List<RefactoringMethodParameter> _getParametersCopy() { |
2838 return refactoring.parameters.map((p) { | 2838 return refactoring.parameters.map((p) { |
2839 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); | 2839 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); |
2840 }).toList(); | 2840 }).toList(); |
2841 } | 2841 } |
2842 } | 2842 } |
OLD | NEW |