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

Unified Diff: editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImplTest.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/RenameRefactoringImplTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImplTest.java b/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImplTest.java
index 9519e2bad35796915d123ee4fdf17cada2a77c66..cfb6629ce913b6cd23f0938f03aa19991a160db2 100644
--- a/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImplTest.java
+++ b/editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImplTest.java
@@ -14,18 +14,63 @@
package com.google.dart.engine.services.internal.refactoring;
+import com.google.dart.engine.AnalysisEngine;
+import com.google.dart.engine.ast.CompilationUnit;
import com.google.dart.engine.ast.SimpleIdentifier;
+import com.google.dart.engine.context.AnalysisContext;
+import com.google.dart.engine.context.ChangeSet;
import com.google.dart.engine.element.Element;
+import com.google.dart.engine.element.LibraryElement;
import com.google.dart.engine.services.change.Change;
import com.google.dart.engine.services.refactoring.RefactoringFactory;
import com.google.dart.engine.services.refactoring.RenameRefactoring;
import com.google.dart.engine.services.status.RefactoringStatusSeverity;
+import com.google.dart.engine.source.DartUriResolver;
+import com.google.dart.engine.source.FileBasedSource;
+import com.google.dart.engine.source.Source;
+import com.google.dart.engine.source.SourceFactory;
+import com.google.dart.engine.utilities.io.FileUtilities2;
/**
* Abstract test for testing {@link RenameRefactoring}s.
*/
public abstract class RenameRefactoringImplTest extends RefactoringImplTest {
+ /**
+ * Helper for creating and analyzing separate {@link AnalysisContext}s.
+ */
+ protected final class ContextHelper {
+ public final AnalysisContext context;
+ public final SourceFactory sourceFactory;
+
+ public ContextHelper() {
+ context = newAnalysisContext();
+ sourceFactory = context.getSourceFactory();
+ }
+
+ public Source addSource(String path, String code) {
+ Source source = new FileBasedSource(
+ sourceFactory.getContentCache(),
+ FileUtilities2.createFile(path));
+ // add source
+ {
+ sourceFactory.setContents(source, "");
+ ChangeSet changeSet = new ChangeSet();
+ changeSet.added(source);
+ context.applyChanges(changeSet);
+ }
+ // update source
+ context.setContents(source, code);
+ return source;
+ }
+
+ public CompilationUnit analyzeSingleUnitLibrary(Source source) throws Exception {
+ LibraryElement libraryElement = context.computeLibraryElement(source);
+ return context.resolveCompilationUnit(source, libraryElement);
+ }
+ }
+
protected RenameRefactoring refactoring;
+
protected Change refactoringChange;
/**
@@ -67,4 +112,14 @@ public abstract class RenameRefactoringImplTest extends RefactoringImplTest {
Element element = findIdentifierElement(search);
createRenameRefactoring(element);
}
+
+ /**
+ * @return new {@link AnalysisContext} with SDK.
+ */
+ protected final AnalysisContext newAnalysisContext() {
+ AnalysisContext context = AnalysisEngine.getInstance().createAnalysisContext();
+ SourceFactory sourceFactory = new SourceFactory(new DartUriResolver(defaultSdk));
+ context.setSourceFactory(sourceFactory);
+ return context;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698