mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
inplace: merge in one undo
This commit is contained in:
+4
-3
@@ -284,7 +284,7 @@ public class InplaceIntroduceConstantPopup {
|
||||
renamer.performInplaceRename(false, nameSuggestions);
|
||||
}
|
||||
}
|
||||
}, IntroduceConstantHandler.REFACTORING_NAME, null);
|
||||
}, IntroduceConstantHandler.REFACTORING_NAME, IntroduceConstantHandler.REFACTORING_NAME);
|
||||
}
|
||||
|
||||
private PsiField createFieldToStartTemplateOn(final String[] names, final PsiType psiType) {
|
||||
@@ -340,7 +340,8 @@ public class InplaceIntroduceConstantPopup {
|
||||
super(myProject, new TypeExpression(myProject, myTypeSelectorManager.getTypesForAll()),
|
||||
myEditor, field, false,
|
||||
myTypeSelectorManager.getTypesForAll().length > 1,
|
||||
myExpr != null && myExpr.isPhysical() ? myEditor.getDocument().createRangeMarker(myExpr.getTextRange()) : null, InplaceIntroduceConstantPopup.this.getOccurrenceMarkers());
|
||||
myExpr != null && myExpr.isPhysical() ? myEditor.getDocument().createRangeMarker(myExpr.getTextRange()) : null, InplaceIntroduceConstantPopup.this.getOccurrenceMarkers(),
|
||||
IntroduceConstantHandler.REFACTORING_NAME);
|
||||
|
||||
myDefaultParameterTypePointer =
|
||||
SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(myTypeSelectorManager.getDefaultType());
|
||||
@@ -437,7 +438,7 @@ public class InplaceIntroduceConstantPopup {
|
||||
protected JComponent getComponent() {
|
||||
if (!myInitListeners) {
|
||||
myInitListeners = true;
|
||||
final VisibilityListener visibilityListener = new VisibilityListener(myProject, myEditor) {
|
||||
final VisibilityListener visibilityListener = new VisibilityListener(myProject, IntroduceConstantHandler.REFACTORING_NAME, myEditor) {
|
||||
@Override
|
||||
protected String getVisibility() {
|
||||
return getSelectedVisibility();
|
||||
|
||||
+5
-4
@@ -176,7 +176,7 @@ public class InplaceIntroduceFieldPopup {
|
||||
renamer.performInplaceRename(false, nameSuggestions);
|
||||
}
|
||||
}
|
||||
}, IntroduceFieldHandler.REFACTORING_NAME, null);
|
||||
}, IntroduceFieldHandler.REFACTORING_NAME, IntroduceFieldHandler.REFACTORING_NAME);
|
||||
}
|
||||
|
||||
private PsiField createFieldToStartTemplateOn(final String[] names,
|
||||
@@ -230,7 +230,8 @@ public class InplaceIntroduceFieldPopup {
|
||||
super(myProject, new TypeExpression(myProject, myTypeSelectorManager.getTypesForAll()),
|
||||
myEditor, psiVariable, false,
|
||||
myTypeSelectorManager.getTypesForAll().length > 1,
|
||||
myInitializerExpression != null && myInitializerExpression.isPhysical() ? myEditor.getDocument().createRangeMarker(myInitializerExpression.getTextRange()) : null, InplaceIntroduceFieldPopup.this.getOccurrenceMarkers());
|
||||
myInitializerExpression != null && myInitializerExpression.isPhysical() ? myEditor.getDocument().createRangeMarker(myInitializerExpression.getTextRange()) : null, InplaceIntroduceFieldPopup.this.getOccurrenceMarkers(),
|
||||
IntroduceFieldHandler.REFACTORING_NAME);
|
||||
myDefaultParameterTypePointer =
|
||||
SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(myTypeSelectorManager.getDefaultType());
|
||||
myFieldRangeStart = myEditor.getDocument().createRangeMarker(psiVariable.getTextRange());
|
||||
@@ -276,13 +277,13 @@ public class InplaceIntroduceFieldPopup {
|
||||
protected JComponent getComponent() {
|
||||
if (!myInitListeners) {
|
||||
myInitListeners = true;
|
||||
myIntroduceFieldPanel.addVisibilityListener(new VisibilityListener(myProject, myEditor){
|
||||
myIntroduceFieldPanel.addVisibilityListener(new VisibilityListener(myProject, IntroduceFieldHandler.REFACTORING_NAME, myEditor){
|
||||
@Override
|
||||
protected String getVisibility() {
|
||||
return myIntroduceFieldPanel.getFieldVisibility();
|
||||
}
|
||||
});
|
||||
final FinalListener finalListener = new FinalListener(myProject);
|
||||
final FinalListener finalListener = new FinalListener(myProject, IntroduceFieldHandler.REFACTORING_NAME);
|
||||
myIntroduceFieldPanel.addFinalListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
|
||||
+6
-4
@@ -57,8 +57,8 @@ public abstract class AbstractInplaceIntroducer extends VariableInplaceIntroduce
|
||||
boolean cantChangeFinalModifier,
|
||||
boolean hasTypeSuggestion,
|
||||
RangeMarker exprMarker,
|
||||
List<RangeMarker> occurrenceMarkers) {
|
||||
super(project, expression, editor, elementToRename, cantChangeFinalModifier, hasTypeSuggestion, exprMarker, occurrenceMarkers);
|
||||
List<RangeMarker> occurrenceMarkers, String commandName) {
|
||||
super(project, expression, editor, elementToRename, cantChangeFinalModifier, hasTypeSuggestion, exprMarker, occurrenceMarkers, commandName);
|
||||
}
|
||||
|
||||
protected abstract boolean isReplaceAllOccurrences();
|
||||
@@ -143,16 +143,18 @@ public abstract class AbstractInplaceIntroducer extends VariableInplaceIntroduce
|
||||
|
||||
protected abstract class VisibilityListener implements ChangeListener {
|
||||
private Project myProject;
|
||||
private final String myCommandName;
|
||||
private Editor myEditor;
|
||||
|
||||
protected VisibilityListener(Project project, Editor editor) {
|
||||
protected VisibilityListener(Project project, String commandName, Editor editor) {
|
||||
myProject = project;
|
||||
myCommandName = commandName;
|
||||
myEditor = editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
new WriteCommandAction(myProject) {
|
||||
new WriteCommandAction(myProject, myCommandName, myCommandName) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
final Document document = myEditor.getDocument();
|
||||
|
||||
+5
-2
@@ -20,7 +20,9 @@ import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
@@ -202,7 +204,7 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
renamer.performInplaceRename(false, nameSuggestions);
|
||||
}
|
||||
}
|
||||
}, IntroduceParameterHandler.REFACTORING_NAME, null);
|
||||
}, IntroduceParameterHandler.REFACTORING_NAME, IntroduceParameterHandler.REFACTORING_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,7 +236,8 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
public ParameterInplaceIntroducer(PsiParameter parameter) {
|
||||
super(myProject, new TypeExpression(myProject, myTypeSelectorManager.getTypesForAll()),
|
||||
myEditor, parameter, myMustBeFinal,
|
||||
myTypeSelectorManager.getTypesForAll().length > 1, myExprMarker, InplaceIntroduceParameterPopup.this.getOccurrenceMarkers());
|
||||
myTypeSelectorManager.getTypesForAll().length > 1, myExprMarker, InplaceIntroduceParameterPopup.this.getOccurrenceMarkers(),
|
||||
IntroduceParameterHandler.REFACTORING_NAME);
|
||||
myDefaultParameterTypePointer = SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(parameter.getType());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -478,7 +478,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
|
||||
final boolean cantChangeFinalModifier = hasWriteAccess || (inFinalContext && choice == OccurrencesChooser.ReplaceChoice.ALL);
|
||||
final VariableInplaceRenamer renamer =
|
||||
new VariableInplaceIntroducer(project, expression, editor, elementToRename, cantChangeFinalModifier,
|
||||
typeSelectorManager.getTypesForAll().length > 1, exprMarker, occurrenceMarkers);
|
||||
typeSelectorManager.getTypesForAll().length > 1, exprMarker, occurrenceMarkers, IntroduceVariableBase.REFACTORING_NAME);
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
|
||||
renamer.performInplaceRename(false, new LinkedHashSet<String>(Arrays.asList(suggestedName.names)));
|
||||
}
|
||||
|
||||
+7
-6
@@ -38,7 +38,6 @@ import com.intellij.openapi.ui.popup.BalloonBuilder;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -52,7 +51,6 @@ import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import com.intellij.ui.TitlePanel;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ui.PositionTracker;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -87,7 +85,8 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
final boolean cantChangeFinalModifier,
|
||||
final boolean hasTypeSuggestion,
|
||||
final RangeMarker exprMarker,
|
||||
final List<RangeMarker> occurrenceMarkers) {
|
||||
final List<RangeMarker> occurrenceMarkers,
|
||||
final String commandName) {
|
||||
super(elementToRename, editor);
|
||||
myProject = project;
|
||||
myEditor = editor;
|
||||
@@ -110,7 +109,7 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
myCanBeFinal = new NonFocusableCheckBox("Declare final");
|
||||
myCanBeFinal.setSelected(createFinals());
|
||||
myCanBeFinal.setMnemonic('f');
|
||||
myCanBeFinal.addActionListener(new FinalListener(project));
|
||||
myCanBeFinal.addActionListener(new FinalListener(project, commandName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,9 +380,11 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
|
||||
public class FinalListener implements ActionListener {
|
||||
private final Project myProject;
|
||||
private final String myCommandName;
|
||||
|
||||
public FinalListener(Project project) {
|
||||
public FinalListener(Project project, String commandName) {
|
||||
myProject = project;
|
||||
myCommandName = commandName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -396,7 +397,7 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
}
|
||||
|
||||
public void perform(final boolean generateFinal, final String modifier) {
|
||||
new WriteCommandAction(myProject){
|
||||
new WriteCommandAction(myProject, myCommandName, myCommandName){
|
||||
@Override
|
||||
protected void run(com.intellij.openapi.application.Result result) throws Throwable {
|
||||
final Document document = myEditor.getDocument();
|
||||
|
||||
Reference in New Issue
Block a user