| 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/protocol2.dart'; | 7 import 'package:analysis_server/src/protocol2.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:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 class A { | 64 class A { |
| 65 A.test() {} | 65 A.test() {} |
| 66 } | 66 } |
| 67 '''); | 67 '''); |
| 68 createRenameRefactoringAtString('test() {}'); | 68 createRenameRefactoringAtString('test() {}'); |
| 69 expect(refactoring.oldName, 'test'); | 69 expect(refactoring.oldName, 'test'); |
| 70 // null | 70 // null |
| 71 refactoring.newName = null; | 71 refactoring.newName = null; |
| 72 assertRefactoringStatus( | 72 assertRefactoringStatus( |
| 73 refactoring.checkNewName(), | 73 refactoring.checkNewName(), |
| 74 RefactoringProblemSeverity.ERROR, | 74 RefactoringProblemSeverity.FATAL, |
| 75 expectedMessage: "Constructor name must not be null."); | 75 expectedMessage: "Constructor name must not be null."); |
| 76 // same | 76 // same |
| 77 refactoring.newName = 'test'; | 77 refactoring.newName = 'test'; |
| 78 assertRefactoringStatus( | 78 assertRefactoringStatus( |
| 79 refactoring.checkNewName(), | 79 refactoring.checkNewName(), |
| 80 RefactoringProblemSeverity.FATAL, | 80 RefactoringProblemSeverity.FATAL, |
| 81 expectedMessage: "The new name must be different than the current name."
); | 81 expectedMessage: "The new name must be different than the current name."
); |
| 82 // empty | 82 // empty |
| 83 refactoring.newName = ''; | 83 refactoring.newName = ''; |
| 84 assertRefactoringStatusOK(refactoring.checkNewName()); | 84 assertRefactoringStatusOK(refactoring.checkNewName()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 '''); | 186 '''); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void _createConstructorDeclarationRefactoring(String search) { | 189 void _createConstructorDeclarationRefactoring(String search) { |
| 190 ConstructorElement element = | 190 ConstructorElement element = |
| 191 findNodeElementAtString(search, (node) => node is ConstructorDeclaration
); | 191 findNodeElementAtString(search, (node) => node is ConstructorDeclaration
); |
| 192 createRenameRefactoringForElement(element); | 192 createRenameRefactoringForElement(element); |
| 193 } | 193 } |
| 194 } | 194 } |
| OLD | NEW |