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_constructor; | 5 library test.services.refactoring.rename_constructor; |
6 | 6 |
7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
8 import 'package:analysis_server/src/services/correction/status.dart'; | 8 import 'package:analysis_server/src/services/correction/status.dart'; |
9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 _createConstructorDeclarationRefactoring('test() {}'); | 48 _createConstructorDeclarationRefactoring('test() {}'); |
49 // check status | 49 // check status |
50 refactoring.newName = 'newName'; | 50 refactoring.newName = 'newName'; |
51 RefactoringStatus status = await refactoring.checkFinalConditions(); | 51 RefactoringStatus status = await refactoring.checkFinalConditions(); |
52 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, | 52 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, |
53 expectedMessage: | 53 expectedMessage: |
54 "Class 'A' already declares method with name 'newName'.", | 54 "Class 'A' already declares method with name 'newName'.", |
55 expectedContextSearch: 'newName() {} // existing'); | 55 expectedContextSearch: 'newName() {} // existing'); |
56 } | 56 } |
57 | 57 |
| 58 test_checkInitialConditions_inSDK() async { |
| 59 indexTestUnit(''' |
| 60 main() { |
| 61 new String.fromCharCodes([]); |
| 62 } |
| 63 '''); |
| 64 createRenameRefactoringAtString('fromCharCodes('); |
| 65 // check status |
| 66 refactoring.newName = 'newName'; |
| 67 RefactoringStatus status = await refactoring.checkInitialConditions(); |
| 68 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, |
| 69 expectedMessage: |
| 70 "The constructor 'String.fromCharCodes' is defined in the SDK, so ca
nnot be renamed."); |
| 71 } |
| 72 |
58 test_checkNewName() { | 73 test_checkNewName() { |
59 indexTestUnit(''' | 74 indexTestUnit(''' |
60 class A { | 75 class A { |
61 A.test() {} | 76 A.test() {} |
62 } | 77 } |
63 '''); | 78 '''); |
64 createRenameRefactoringAtString('test() {}'); | 79 createRenameRefactoringAtString('test() {}'); |
65 expect(refactoring.oldName, 'test'); | 80 expect(refactoring.oldName, 'test'); |
66 // null | 81 // null |
67 refactoring.newName = null; | 82 refactoring.newName = null; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 198 } |
184 '''); | 199 '''); |
185 } | 200 } |
186 | 201 |
187 void _createConstructorDeclarationRefactoring(String search) { | 202 void _createConstructorDeclarationRefactoring(String search) { |
188 ConstructorElement element = findNodeElementAtString( | 203 ConstructorElement element = findNodeElementAtString( |
189 search, (node) => node is ConstructorDeclaration); | 204 search, (node) => node is ConstructorDeclaration); |
190 createRenameRefactoringForElement(element); | 205 createRenameRefactoringForElement(element); |
191 } | 206 } |
192 } | 207 } |
OLD | NEW |