| 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.refactoring.rename_import; | 5 library test.services.refactoring.rename_import; |
| 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_testing/reflective_tests.dart'; | 8 import 'package:analysis_testing/reflective_tests.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // validate change | 86 // validate change |
| 87 return assertSuccessfulRename(''' | 87 return assertSuccessfulRename(''' |
| 88 import 'dart:math' as test; | 88 import 'dart:math' as test; |
| 89 import 'dart:async' as newName; | 89 import 'dart:async' as newName; |
| 90 main() { | 90 main() { |
| 91 newName.Future f; | 91 newName.Future f; |
| 92 } | 92 } |
| 93 '''); | 93 '''); |
| 94 } | 94 } |
| 95 | 95 |
| 96 test_createChange_change_onPrefixElement() { |
| 97 indexTestUnit(''' |
| 98 import 'dart:async' as test; |
| 99 import 'dart:math' as test; |
| 100 main() { |
| 101 test.Future f; |
| 102 test.PI; |
| 103 test.E; |
| 104 } |
| 105 '''); |
| 106 // configure refactoring |
| 107 createRenameRefactoringAtString('test.PI'); |
| 108 expect(refactoring.refactoringName, 'Rename Import Prefix'); |
| 109 expect(refactoring.oldName, 'test'); |
| 110 refactoring.newName = 'newName'; |
| 111 // validate change |
| 112 return assertSuccessfulRename(''' |
| 113 import 'dart:async' as test; |
| 114 import 'dart:math' as newName; |
| 115 main() { |
| 116 test.Future f; |
| 117 newName.PI; |
| 118 newName.E; |
| 119 } |
| 120 '''); |
| 121 } |
| 122 |
| 96 test_createChange_change_function() { | 123 test_createChange_change_function() { |
| 97 indexTestUnit(''' | 124 indexTestUnit(''' |
| 98 import 'dart:math' as test; | 125 import 'dart:math' as test; |
| 99 import 'dart:async' as test; | 126 import 'dart:async' as test; |
| 100 main() { | 127 main() { |
| 101 test.max(1, 2); | 128 test.max(1, 2); |
| 102 test.Future f; | 129 test.Future f; |
| 103 } | 130 } |
| 104 '''); | 131 '''); |
| 105 // configure refactoring | 132 // configure refactoring |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 167 } |
| 141 '''); | 168 '''); |
| 142 } | 169 } |
| 143 | 170 |
| 144 void _createRefactoring(String search) { | 171 void _createRefactoring(String search) { |
| 145 ImportDirective directive = | 172 ImportDirective directive = |
| 146 findNodeAtString(search, (node) => node is ImportDirective); | 173 findNodeAtString(search, (node) => node is ImportDirective); |
| 147 createRenameRefactoringForElement(directive.element); | 174 createRenameRefactoringForElement(directive.element); |
| 148 } | 175 } |
| 149 } | 176 } |
| OLD | NEW |