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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/actions/RenameDartElementAction_NEW.java

Issue 548593002: Integrate 'Rename' refactoring into Editor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/actions/RenameDartElementAction_NEW.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/actions/RenameDartElementAction_NEW.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/actions/RenameDartElementAction_NEW.java
index 446b482f7a8fc117c9ee934afdc0bdabaa0b40a1..2bb16be7093d6e8c3edb27c31f5f98aefba06c3b 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/actions/RenameDartElementAction_NEW.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/actions/RenameDartElementAction_NEW.java
@@ -15,13 +15,11 @@ package com.google.dart.tools.ui.internal.refactoring.actions;
import com.google.dart.engine.element.Element;
import com.google.dart.server.generated.types.RefactoringKind;
-import com.google.dart.tools.internal.corext.refactoring.RefactoringExecutionStarter;
import com.google.dart.tools.ui.actions.AbstractRefactoringAction_NEW;
-import com.google.dart.tools.ui.internal.actions.SelectionConverter;
-import com.google.dart.tools.ui.internal.refactoring.RefactoringMessages;
-import com.google.dart.tools.ui.internal.refactoring.RefactoringUtils;
+import com.google.dart.tools.ui.internal.refactoring.RefactoringSaveHelper;
+import com.google.dart.tools.ui.internal.refactoring.RenameWizard_NEW;
+import com.google.dart.tools.ui.internal.refactoring.ServerRenameRefactoring;
import com.google.dart.tools.ui.internal.text.editor.DartEditor;
-import com.google.dart.tools.ui.internal.util.ExceptionHandler;
import org.eclipse.jface.action.Action;
@@ -33,81 +31,45 @@ import org.eclipse.jface.action.Action;
public class RenameDartElementAction_NEW extends AbstractRefactoringAction_NEW {
public RenameDartElementAction_NEW(DartEditor editor) {
super(editor, RefactoringKind.RENAME);
- setEnabled(SelectionConverter.canOperateOn(editor));
- }
-
-// @Override
-// public void selectionChanged(DartSelection selection) {
-// // cannot operate on this editor
-// if (!canOperateOn()) {
-// setEnabled(false);
-// return;
-// }
-// // validate element
-// Element element = getElementToRename(selection);
-// setEnabled(element != null);
-// }
-//
-// @Override
-// public void selectionChanged(IStructuredSelection selection) {
-// Element element = getSelectionElement(selection);
-// setEnabled(element != null);
-// }
-//
-// @Override
-// protected void doRun(DartSelection selection, Event event,
-// UIInstrumentationBuilder instrumentation) {
-// AssistContext context = getContextAfterBuild(selection);
-// if (context == null) {
-// return;
-// }
-// // prepare element
-// Element element = getElementToRename(selection);
-// if (element == null) {
-// return;
-// }
-// // Always rename using dialog. Eclipse implementation of the linked mode is very slow
-// // in case of the many occurrences in the single file. It is also done using asynchronous
-// // execution, in these 1-2-3 seconds user can type anything and damage source.
-// renameUsingDialog(element);
-// }
-//
-// @Override
-// protected void doRun(IStructuredSelection selection, Event event,
-// UIInstrumentationBuilder instrumentation) {
-// Element element = getSelectionElement(selection);
-// renameUsingDialog(element);
-// }
-
- @Override
- public boolean isEnabled() {
- return super.isEnabled();
}
@Override
public void run() {
// TODO(scheglov)
System.out.println("run!");
+ ServerRenameRefactoring refactoring = new ServerRenameRefactoring(
+ file,
+ selectionOffset,
+ selectionLength);
+ try {
+ new RefactoringStarter().activate(
+ new RenameWizard_NEW(refactoring),
+ getShell(),
+ "Rename",
+ RefactoringSaveHelper.SAVE_NOTHING);
+ } catch (Throwable e) {
+ showError("Extract Local", e);
+ }
}
@Override
protected void init() {
}
- private void renameUsingDialog(Element element) {
- if (element == null) {
- return;
- }
- if (!RefactoringUtils.waitReadyForRefactoring()) {
- return;
- }
- try {
- RefactoringExecutionStarter.startRenameRefactoring(element, getShell());
- } catch (Throwable e) {
- ExceptionHandler.handle(
- e,
- RefactoringMessages.RenameDartElementAction_name,
- RefactoringMessages.RenameDartElementAction_exception);
- }
- }
+// private void renameUsingDialog(Element element) {
+// if (element == null) {
+// return;
+// }
+// if (!RefactoringUtils.waitReadyForRefactoring()) {
+// return;
+// }
+// try {
+// RefactoringExecutionStarter.startRenameRefactoring(element, getShell());
+// } catch (Throwable e) {
+// ExceptionHandler.handle(
+// e,
+// RefactoringMessages.RenameDartElementAction_name,
+// RefactoringMessages.RenameDartElementAction_exception);
+// }
+// }
}

Powered by Google App Engine
This is Rietveld 408576698