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

Unified Diff: editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameUnitMemberRefactoringImplTest.java

Issue 23498016: Update only unique references during rename refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
Index: editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameUnitMemberRefactoringImplTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameUnitMemberRefactoringImplTest.java b/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameUnitMemberRefactoringImplTest.java
index 7f876aa652906644ee9617552339b667e5cf057e..a7b1e41e9385b369afd51dd5431583af2ae0cad6 100644
--- a/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameUnitMemberRefactoringImplTest.java
+++ b/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameUnitMemberRefactoringImplTest.java
@@ -14,6 +14,7 @@
package com.google.dart.engine.services.internal.refactoring;
+import com.google.dart.engine.ast.CompilationUnit;
import com.google.dart.engine.services.change.Change;
import com.google.dart.engine.services.status.RefactoringStatusSeverity;
import com.google.dart.engine.source.Source;
@@ -500,6 +501,75 @@ public class RenameUnitMemberRefactoringImplTest extends RenameRefactoringImplTe
// check_createChange_PropertyAccessorElement("test = 1");
// }
+ public void test_createChange_oneLibInTwoContexts() throws Exception {
+ String libCode = "test() {}";
+ String code = makeSource(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "import 'Lib.dart';",
+ "main() {",
+ " test();",
+ "}");
+ // index unit in separate context
+ Source source2;
+ {
+ ContextHelper helper = new ContextHelper();
+ helper.addSource("/Lib.dart", libCode);
+ source2 = helper.addSource("/Test2.dart", code);
+ CompilationUnit unit = helper.analyzeSingleUnitLibrary(source2);
+ index.indexUnit(helper.context, unit);
+ }
+ // index unit Lib.dart in "test"
+ addSource("/Lib.dart", libCode);
+ indexTestUnit(code);
+ // configure refactoring
+ createRenameRefactoring("test()");
+ assertEquals("Rename Top-Level Function", refactoring.getRefactoringName());
+ refactoring.setNewName("newName");
+ // validate change
+ assertSuccessfulRename(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "import 'Lib.dart';",
+ "main() {",
+ " newName();",
+ "}");
+ assertChangeResult(
+ refactoringChange,
+ source2,
+ makeSource(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "import 'Lib.dart';",
+ "main() {",
+ " newName();",
+ "}"));
+ }
+
+ public void test_createChange_oneUnitInTwoContexts() throws Exception {
+ String code = makeSource(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " main();",
+ "}");
+ // index unit in separate context
+ {
+ ContextHelper helper = new ContextHelper();
+ Source source = helper.addSource("/Test.dart", code);
+ CompilationUnit unit = helper.analyzeSingleUnitLibrary(source);
+ index.indexUnit(helper.context, unit);
+ }
+ // index same unit as "test"
+ indexTestUnit(code);
+ // configure refactoring
+ createRenameRefactoring("main() {");
+ assertEquals("Rename Top-Level Function", refactoring.getRefactoringName());
+ refactoring.setNewName("newName");
+ // validate change
+ assertSuccessfulRename(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "newName() {",
+ " newName();",
+ "}");
+ }
+
public void test_createChange_TopLevelVariableElement_field() throws Exception {
check_createChange_TopLevelVariableElement("test = 42;");
}

Powered by Google App Engine
This is Rietveld 408576698