| Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/rename/RenameResourceParticipant.java
|
| diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/rename/RenameResourceParticipant.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/rename/RenameResourceParticipant.java
|
| index ef907e25bda5ea07090a56ec74d8216da6ab81f2..92a6cf93608d9582a991136cfff0eafbd97b9a3b 100644
|
| --- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/rename/RenameResourceParticipant.java
|
| +++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/rename/RenameResourceParticipant.java
|
| @@ -13,33 +13,18 @@
|
| */
|
| package com.google.dart.tools.internal.corext.refactoring.rename;
|
|
|
| -import com.google.dart.engine.element.CompilationUnitElement;
|
| -import com.google.dart.engine.search.SearchEngine;
|
| -import com.google.dart.engine.search.SearchMatch;
|
| -import com.google.dart.engine.source.Source;
|
| -import com.google.dart.engine.utilities.source.SourceRange;
|
| -import com.google.dart.tools.core.DartCore;
|
| -import com.google.dart.tools.internal.corext.refactoring.RefactoringCoreMessages;
|
| -import com.google.dart.tools.internal.corext.refactoring.changes.TextChangeCompatibility;
|
| -import com.google.dart.tools.internal.corext.refactoring.util.DartElementUtil;
|
| -import com.google.dart.tools.internal.corext.refactoring.util.TextChangeManager;
|
| +import com.google.dart.tools.core.DartCoreDebug;
|
| import com.google.dart.tools.ui.internal.refactoring.RefactoringMessages;
|
|
|
| -import org.eclipse.core.resources.IFile;
|
| import org.eclipse.core.runtime.CoreException;
|
| import org.eclipse.core.runtime.IProgressMonitor;
|
| import org.eclipse.core.runtime.OperationCanceledException;
|
| import org.eclipse.ltk.core.refactoring.Change;
|
| -import org.eclipse.ltk.core.refactoring.CompositeChange;
|
| import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
| -import org.eclipse.ltk.core.refactoring.TextChange;
|
| import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
|
| -import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
|
| +import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
|
| +import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
|
| import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
|
| -import org.eclipse.text.edits.ReplaceEdit;
|
| -import org.eclipse.text.edits.TextEdit;
|
| -
|
| -import java.util.List;
|
|
|
| /**
|
| * {@link RenameParticipant} for updating resource references in Dart libraries.
|
| @@ -47,46 +32,31 @@ import java.util.List;
|
| * @coverage dart.editor.ui.refactoring.core
|
| */
|
| public class RenameResourceParticipant extends RenameParticipant {
|
| - private final TextChangeManager changeManager = new TextChangeManager();
|
| - private IFile file;
|
| + private final RenameParticipant impl;
|
| +
|
| + public RenameResourceParticipant() {
|
| + if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
|
| + impl = new RenameResourceParticipant_NEW();
|
| + } else {
|
| + impl = new RenameResourceParticipant_OLD();
|
| + }
|
| + }
|
|
|
| @Override
|
| public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
|
| throws OperationCanceledException {
|
| - return new RefactoringStatus();
|
| + return impl.checkConditions(pm, context);
|
| }
|
|
|
| @Override
|
| public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
|
| - return null;
|
| + return impl.createChange(pm);
|
| }
|
|
|
| @Override
|
| - public Change createPreChange(IProgressMonitor pm) {
|
| - RenameArguments arguments = getArguments();
|
| - // update references
|
| - if (arguments.getUpdateReferences()) {
|
| - // prepare unit element
|
| - CompilationUnitElement unitElement = DartElementUtil.getCompilationUnitElement(file);
|
| - if (unitElement == null) {
|
| - return null;
|
| - }
|
| - // prepare references
|
| - SearchEngine searchEngine = DartCore.getProjectManager().newSearchEngine();
|
| - List<SearchMatch> references = searchEngine.searchReferences(unitElement, null, null);
|
| - // update references
|
| - String newName = arguments.getNewName();
|
| - for (SearchMatch match : references) {
|
| - addReferenceUpdate(match, newName);
|
| - }
|
| - }
|
| - // return as single CompositeChange
|
| - TextChange[] changes = changeManager.getAllChanges();
|
| - if (changes.length != 0) {
|
| - return new CompositeChange(getName(), changes);
|
| - } else {
|
| - return null;
|
| - }
|
| + public Change createPreChange(IProgressMonitor pm) throws CoreException,
|
| + OperationCanceledException {
|
| + return impl.createPreChange(pm);
|
| }
|
|
|
| @Override
|
| @@ -95,27 +65,13 @@ public class RenameResourceParticipant extends RenameParticipant {
|
| }
|
|
|
| @Override
|
| - protected boolean initialize(Object element) {
|
| - if (element instanceof IFile) {
|
| - file = (IFile) element;
|
| - return true;
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - private void addReferenceUpdate(SearchMatch match, String newName) {
|
| - Source source = match.getElement().getSource();
|
| - // prepare "old name" range
|
| - SourceRange matchRange = match.getSourceRange();
|
| - int end = matchRange.getEnd() - "'".length();
|
| - int begin = end - file.getName().length();
|
| - // add TextEdit to rename "old name" with "new name"
|
| - TextEdit edit = new ReplaceEdit(begin, end - begin, newName);
|
| - addTextEdit(source, RefactoringCoreMessages.RenameProcessor_update_reference, edit);
|
| + public boolean initialize(RefactoringProcessor processor, Object element,
|
| + RefactoringArguments arguments) {
|
| + return impl.initialize(processor, element, arguments);
|
| }
|
|
|
| - private void addTextEdit(Source source, String groupName, TextEdit textEdit) {
|
| - TextChange change = changeManager.get(source);
|
| - TextChangeCompatibility.addTextEdit(change, groupName, textEdit);
|
| + @Override
|
| + protected boolean initialize(Object element) {
|
| + return false;
|
| }
|
| }
|
|
|