| 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/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 import 'dart:async'; | 59 import 'dart:async'; |
| 60 import 'dart:math' as newName show Random, min hide max; | 60 import 'dart:math' as newName show Random, min hide max; |
| 61 main() { | 61 main() { |
| 62 Future f; | 62 Future f; |
| 63 newName.Random r; | 63 newName.Random r; |
| 64 newName.min(1, 2); | 64 newName.min(1, 2); |
| 65 } | 65 } |
| 66 '''); | 66 '''); |
| 67 } | 67 } |
| 68 | 68 |
| 69 test_createChange_add_interpolationExpression() { |
| 70 indexTestUnit(r''' |
| 71 import 'dart:async'; |
| 72 main() { |
| 73 Future f; |
| 74 print('Future type: $Future'); |
| 75 } |
| 76 '''); |
| 77 // configure refactoring |
| 78 _createRefactoring("import 'dart:async"); |
| 79 expect(refactoring.refactoringName, 'Rename Import Prefix'); |
| 80 refactoring.newName = 'newName'; |
| 81 // validate change |
| 82 return assertSuccessfulRefactoring(r''' |
| 83 import 'dart:async' as newName; |
| 84 main() { |
| 85 newName.Future f; |
| 86 print('Future type: ${newName.Future}'); |
| 87 } |
| 88 '''); |
| 89 } |
| 90 |
| 69 test_createChange_change_className() { | 91 test_createChange_change_className() { |
| 70 indexTestUnit(''' | 92 indexTestUnit(''' |
| 71 import 'dart:math' as test; | 93 import 'dart:math' as test; |
| 72 import 'dart:async' as test; | 94 import 'dart:async' as test; |
| 73 main() { | 95 main() { |
| 74 test.Future f; | 96 test.Future f; |
| 75 } | 97 } |
| 76 '''); | 98 '''); |
| 77 // configure refactoring | 99 // configure refactoring |
| 78 _createRefactoring("import 'dart:async"); | 100 _createRefactoring("import 'dart:async"); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 expect(refactoring.refactoringName, 'Rename Import Prefix'); | 199 expect(refactoring.refactoringName, 'Rename Import Prefix'); |
| 178 expect(refactoring.oldName, ''); | 200 expect(refactoring.oldName, ''); |
| 179 } | 201 } |
| 180 | 202 |
| 181 void _createRefactoring(String search) { | 203 void _createRefactoring(String search) { |
| 182 ImportDirective directive = | 204 ImportDirective directive = |
| 183 findNodeAtString(search, (node) => node is ImportDirective); | 205 findNodeAtString(search, (node) => node is ImportDirective); |
| 184 createRenameRefactoringForElement(directive.element); | 206 createRenameRefactoringForElement(directive.element); |
| 185 } | 207 } |
| 186 } | 208 } |
| OLD | NEW |