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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_class_member; 5 library test.services.refactoring.rename_class_member;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/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:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import '../../utils.dart'; 12 import '../../utils.dart';
13 import 'abstract_rename.dart'; 13 import 'abstract_rename.dart';
14 14
15 main() { 15 main() {
16 initializeTestEnvironment(); 16 initializeTestEnvironment();
17 defineReflectiveTests(RenameClassMemberTest); 17 defineReflectiveTests(RenameClassMemberTest);
18 } 18 }
19 19
20 @reflectiveTest 20 @reflectiveTest
21 class RenameClassMemberTest extends RenameRefactoringTest { 21 class RenameClassMemberTest extends RenameRefactoringTest {
22 test_checkFinalConditions_classNameConflict_sameClass() async {
23 indexTestUnit('''
24 class NewName {
25 void test() {}
26 }
27 ''');
28 createRenameRefactoringAtString('test() {}');
29 // check status
30 refactoring.newName = 'NewName';
31 RefactoringStatus status = await refactoring.checkFinalConditions();
32 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
33 expectedMessage:
34 "Renamed method has the same name as the declaring class 'NewName'." ,
35 expectedContextSearch: 'test() {}');
36 }
37
38 test_checkFinalConditions_classNameConflict_subClass() async {
39 indexTestUnit('''
40 class A {
41 void test() {} // 1
42 }
43 class NewName extends A {
44 void test() {} // 2
45 }
46 ''');
47 createRenameRefactoringAtString('test() {} // 1');
48 // check status
49 refactoring.newName = 'NewName';
50 RefactoringStatus status = await refactoring.checkFinalConditions();
51 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
52 expectedMessage:
53 "Renamed method has the same name as the declaring class 'NewName'." ,
54 expectedContextSearch: 'test() {} // 2');
55 }
56
57 test_checkFinalConditions_classNameConflict_superClass() async {
58 indexTestUnit('''
59 class NewName {
60 void test() {} // 1
61 }
62 class B extends NewName {
63 void test() {} // 2
64 }
65 ''');
66 createRenameRefactoringAtString('test() {} // 2');
67 // check status
68 refactoring.newName = 'NewName';
69 RefactoringStatus status = await refactoring.checkFinalConditions();
70 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
71 expectedMessage:
72 "Renamed method has the same name as the declaring class 'NewName'." ,
73 expectedContextSearch: 'test() {} // 1');
74 }
75
22 test_checkFinalConditions_hasMember_MethodElement() async { 76 test_checkFinalConditions_hasMember_MethodElement() async {
23 indexTestUnit(''' 77 indexTestUnit('''
24 class A { 78 class A {
25 test() {} 79 test() {}
26 newName() {} // existing 80 newName() {} // existing
27 } 81 }
28 '''); 82 ''');
29 createRenameRefactoringAtString('test() {}'); 83 createRenameRefactoringAtString('test() {}');
30 // check status 84 // check status
31 refactoring.newName = 'newName'; 85 refactoring.newName = 'newName';
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 // validate change 836 // validate change
783 return assertSuccessfulRefactoring(''' 837 return assertSuccessfulRefactoring('''
784 class A<NewName> { 838 class A<NewName> {
785 NewName field; 839 NewName field;
786 List<NewName> items; 840 List<NewName> items;
787 NewName method(NewName p) => null; 841 NewName method(NewName p) => null;
788 } 842 }
789 '''); 843 ''');
790 } 844 }
791 } 845 }
OLDNEW
« 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