| Index: pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
|
| diff --git a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
|
| index d7b1626c05f51a73733dc479f048afc8210a785d..e88a94c2de37f762d16246d4175135bc516feaa4 100644
|
| --- a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
|
| +++ b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
|
| @@ -5,9 +5,9 @@
|
| library test.services.refactoring.rename_class_member;
|
|
|
| import 'package:analysis_server/src/protocol.dart';
|
| -import '../../reflective_tests.dart';
|
| import 'package:unittest/unittest.dart';
|
|
|
| +import '../../reflective_tests.dart';
|
| import 'abstract_rename.dart';
|
|
|
|
|
| @@ -19,28 +19,6 @@ main() {
|
|
|
| @ReflectiveTestCase()
|
| class RenameClassMemberTest extends RenameRefactoringTest {
|
| - test_checkFinalConditions_OK_noShadow() {
|
| - indexTestUnit('''
|
| -class A {
|
| - int newName;
|
| -}
|
| -class B {
|
| - test() {}
|
| -}
|
| -class C extends A {
|
| - main() {
|
| - print(newName);
|
| - }
|
| -}
|
| -''');
|
| - createRenameRefactoringAtString('test() {}');
|
| - // check status
|
| - refactoring.newName = 'newName';
|
| - return refactoring.checkFinalConditions().then((status) {
|
| - assertRefactoringStatusOK(status);
|
| - });
|
| - }
|
| -
|
| test_checkFinalConditions_hasMember_MethodElement() {
|
| indexTestUnit('''
|
| class A {
|
| @@ -60,13 +38,17 @@ class A {
|
| });
|
| }
|
|
|
| - test_checkFinalConditions_shadowed_byLocal_OK_qualifiedReference() {
|
| + test_checkFinalConditions_OK_noShadow() {
|
| indexTestUnit('''
|
| class A {
|
| + int newName;
|
| +}
|
| +class B {
|
| test() {}
|
| +}
|
| +class C extends A {
|
| main() {
|
| - var newName;
|
| - this.test(); // marker
|
| + print(newName);
|
| }
|
| }
|
| ''');
|
| @@ -78,12 +60,13 @@ class A {
|
| });
|
| }
|
|
|
| - test_checkFinalConditions_shadowed_byLocal_OK_renamedNotUsed() {
|
| + test_checkFinalConditions_shadowed_byLocal_inSameClass() {
|
| indexTestUnit('''
|
| class A {
|
| test() {}
|
| main() {
|
| var newName;
|
| + test(); // marker
|
| }
|
| }
|
| ''');
|
| @@ -91,14 +74,21 @@ class A {
|
| // check status
|
| refactoring.newName = 'newName';
|
| return refactoring.checkFinalConditions().then((status) {
|
| - assertRefactoringStatusOK(status);
|
| + assertRefactoringStatus(
|
| + status,
|
| + RefactoringProblemSeverity.ERROR,
|
| + expectedMessage:
|
| + "Usage of renamed method will be shadowed by local variable 'newName'.",
|
| + expectedContextSearch: 'test(); // marker');
|
| });
|
| }
|
|
|
| - test_checkFinalConditions_shadowed_byLocal_inSameClass() {
|
| + test_checkFinalConditions_shadowed_byLocal_inSubClass() {
|
| indexTestUnit('''
|
| class A {
|
| test() {}
|
| +}
|
| +class B extends A {
|
| main() {
|
| var newName;
|
| test(); // marker
|
| @@ -118,15 +108,30 @@ class A {
|
| });
|
| }
|
|
|
| - test_checkFinalConditions_shadowed_byLocal_inSubClass() {
|
| + test_checkFinalConditions_shadowed_byLocal_OK_qualifiedReference() {
|
| indexTestUnit('''
|
| class A {
|
| test() {}
|
| + main() {
|
| + var newName;
|
| + this.test(); // marker
|
| + }
|
| }
|
| -class B extends A {
|
| +''');
|
| + createRenameRefactoringAtString('test() {}');
|
| + // check status
|
| + refactoring.newName = 'newName';
|
| + return refactoring.checkFinalConditions().then((status) {
|
| + assertRefactoringStatusOK(status);
|
| + });
|
| + }
|
| +
|
| + test_checkFinalConditions_shadowed_byLocal_OK_renamedNotUsed() {
|
| + indexTestUnit('''
|
| +class A {
|
| + test() {}
|
| main() {
|
| var newName;
|
| - test(); // marker
|
| }
|
| }
|
| ''');
|
| @@ -134,12 +139,7 @@ class B extends A {
|
| // check status
|
| refactoring.newName = 'newName';
|
| return refactoring.checkFinalConditions().then((status) {
|
| - assertRefactoringStatus(
|
| - status,
|
| - RefactoringProblemSeverity.ERROR,
|
| - expectedMessage:
|
| - "Usage of renamed method will be shadowed by local variable 'newName'.",
|
| - expectedContextSearch: 'test(); // marker');
|
| + assertRefactoringStatusOK(status);
|
| });
|
| }
|
|
|
| @@ -189,15 +189,17 @@ class B extends A {
|
| });
|
| }
|
|
|
| - test_checkFinalConditions_shadowsSuper_MethodElement() {
|
| + test_checkFinalConditions_shadowsSuper_inSubClass_FieldElement() {
|
| indexTestUnit('''
|
| class A {
|
| - test() {}
|
| + int newName; // marker
|
| }
|
| class B extends A {
|
| - newName() {} // marker
|
| + test() {}
|
| +}
|
| +class C extends B {
|
| main() {
|
| - test();
|
| + print(newName);
|
| }
|
| }
|
| ''');
|
| @@ -208,22 +210,20 @@ class B extends A {
|
| assertRefactoringStatus(
|
| status,
|
| RefactoringProblemSeverity.ERROR,
|
| - expectedMessage: "Renamed method will be shadowed by method 'B.newName'.",
|
| - expectedContextSearch: 'newName() {} // marker');
|
| + expectedMessage: "Renamed method will shadow field 'A.newName'.",
|
| + expectedContextSearch: 'newName; // marker');
|
| });
|
| }
|
|
|
| - test_checkFinalConditions_shadowsSuper_inSubClass_FieldElement() {
|
| + test_checkFinalConditions_shadowsSuper_MethodElement() {
|
| indexTestUnit('''
|
| class A {
|
| - int newName; // marker
|
| -}
|
| -class B extends A {
|
| test() {}
|
| }
|
| -class C extends B {
|
| +class B extends A {
|
| + newName() {} // marker
|
| main() {
|
| - print(newName);
|
| + test();
|
| }
|
| }
|
| ''');
|
| @@ -234,8 +234,8 @@ class C extends B {
|
| assertRefactoringStatus(
|
| status,
|
| RefactoringProblemSeverity.ERROR,
|
| - expectedMessage: "Renamed method will shadow field 'A.newName'.",
|
| - expectedContextSearch: 'newName; // marker');
|
| + expectedMessage: "Renamed method will be shadowed by method 'B.newName'.",
|
| + expectedContextSearch: 'newName() {} // marker');
|
| });
|
| }
|
|
|
|
|