Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(675)

Unified Diff: pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart

Issue 1398213004: Warn about conflict before renamed class member and enclosing class name. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/rename_class_member.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ef91205f45c594f4d46750108105f9e4446e40f7..43a0a351b947f763636e4034b07c2598a3f4a198 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
@@ -19,6 +19,60 @@ main() {
@reflectiveTest
class RenameClassMemberTest extends RenameRefactoringTest {
+ test_checkFinalConditions_classNameConflict_sameClass() async {
+ indexTestUnit('''
+class NewName {
+ void test() {}
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'NewName';
+ RefactoringStatus status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Renamed method has the same name as the declaring class 'NewName'.",
+ expectedContextSearch: 'test() {}');
+ }
+
+ test_checkFinalConditions_classNameConflict_subClass() async {
+ indexTestUnit('''
+class A {
+ void test() {} // 1
+}
+class NewName extends A {
+ void test() {} // 2
+}
+''');
+ createRenameRefactoringAtString('test() {} // 1');
+ // check status
+ refactoring.newName = 'NewName';
+ RefactoringStatus status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Renamed method has the same name as the declaring class 'NewName'.",
+ expectedContextSearch: 'test() {} // 2');
+ }
+
+ test_checkFinalConditions_classNameConflict_superClass() async {
+ indexTestUnit('''
+class NewName {
+ void test() {} // 1
+}
+class B extends NewName {
+ void test() {} // 2
+}
+''');
+ createRenameRefactoringAtString('test() {} // 2');
+ // check status
+ refactoring.newName = 'NewName';
+ RefactoringStatus status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Renamed method has the same name as the declaring class 'NewName'.",
+ expectedContextSearch: 'test() {} // 1');
+ }
+
test_checkFinalConditions_hasMember_MethodElement() async {
indexTestUnit('''
class A {
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/rename_class_member.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698