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

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

Issue 945693004: Issue 22288. Rename named parameters in hierarchy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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_local.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_local_test.dart
diff --git a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
index 92c67d9a85b65fd6fe5b40c4dbade47b363e7f2a..89b34f6efb23f5ca069c295b4cc74f08e1f00675 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
@@ -5,19 +5,17 @@
library test.services.refactoring.rename_local;
import 'package:analysis_server/src/protocol.dart';
+import 'package:analysis_server/src/services/correction/status.dart';
import 'package:unittest/unittest.dart';
import '../../reflective_tests.dart';
import 'abstract_rename.dart';
-import 'package:analysis_server/src/services/correction/status.dart';
-
main() {
groupSep = ' | ';
runReflectiveTests(RenameLocalTest);
}
-
@reflectiveTest
class RenameLocalTest extends RenameRefactoringTest {
test_checkFinalConditions_hasLocalFunction_after() async {
@@ -147,6 +145,31 @@ class A {
expectedContextSearch: 'newName);');
}
+ test_checkFinalConditions_shadows_classMember_namedParameter() async {
+ indexTestUnit('''
+class A {
+ foo({test: 1}) {
+ }
+}
+class B extends A {
+ var newName = 1;
+ foo({test: 2}) {
+ print(newName);
+ }
+}
+''');
+ createRenameRefactoringAtString('test: 1}');
+ // check status
+ refactoring.newName = 'newName';
+ RefactoringStatus status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(
+ status,
+ RefactoringProblemSeverity.ERROR,
+ expectedMessage: 'Usage of field "B.newName" declared in "test.dart" '
+ 'will be shadowed by renamed parameter.',
+ expectedContextSearch: 'newName);');
+ }
+
test_checkFinalConditions_shadows_classMemberOK_qualifiedReference() {
indexTestUnit('''
class A {
@@ -411,7 +434,7 @@ main() {
''');
}
- test_createChange_parameter_namedInOtherFile() async {
+ test_createChange_parameter_named_inOtherFile() async {
indexTestUnit('''
class A {
A({test});
@@ -441,6 +464,66 @@ main() {
''');
}
+ test_createChange_parameter_named_updateHierarchy() async {
+ indexUnit('/test2.dart', '''
+library test2;
+class A {
+ void foo({int test: 1}) {
+ print(test);
+ }
+}
+class B extends A {
+ void foo({int test: 2}) {
+ print(test);
+ }
+}
+''');
+ indexTestUnit('''
+import 'test2.dart';
+main() {
+ new A().foo(test: 10);
+ new B().foo(test: 20);
+ new C().foo(test: 30);
+}
+class C extends A {
+ void foo({int test: 3}) {
+ print(test);
+ }
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test: 20');
+ expect(refactoring.refactoringName, 'Rename Parameter');
+ refactoring.newName = 'newName';
+ // validate change
+ await assertSuccessfulRefactoring('''
+import 'test2.dart';
+main() {
+ new A().foo(newName: 10);
+ new B().foo(newName: 20);
+ new C().foo(newName: 30);
+}
+class C extends A {
+ void foo({int newName: 3}) {
+ print(newName);
+ }
+}
+''');
+ assertFileChangeResult('/test2.dart', '''
+library test2;
+class A {
+ void foo({int newName: 1}) {
+ print(newName);
+ }
+}
+class B extends A {
+ void foo({int newName: 2}) {
+ print(newName);
+ }
+}
+''');
+ }
+
test_oldName() {
indexTestUnit('''
main() {
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/rename_local.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698