mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace introduce api: move to lang
This commit is contained in:
+1
-1
@@ -334,7 +334,7 @@ public class InplaceIntroduceConstantPopup extends AbstractJavaInplaceIntroducer
|
||||
myReplaceAllCb.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
restartTemplate();
|
||||
restartInplaceIntroduceTemplate();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -217,7 +217,7 @@ public class InplaceIntroduceFieldPopup extends AbstractJavaInplaceIntroducer {
|
||||
myIntroduceFieldPanel.addOccurrenceListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
restartTemplate();
|
||||
restartInplaceIntroduceTemplate();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroducer {
|
||||
protected void updateControls(JCheckBox[] removeParamsCb) {
|
||||
super.updateControls(removeParamsCb);
|
||||
if (myParameterIndex < 0) return;
|
||||
restartTemplate();
|
||||
restartInplaceIntroduceTemplate();
|
||||
}
|
||||
};
|
||||
myPanel.append2MainPanel(myWholePanel);
|
||||
|
||||
+1
-6
@@ -34,7 +34,7 @@ import com.intellij.psi.scope.processor.VariablesProcessor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractInplaceVariableIntroducer;
|
||||
import com.intellij.refactoring.introduce.inplace.AbstractInplaceVariableIntroducer;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
@@ -223,11 +223,6 @@ public class VariableInplaceIntroducer extends AbstractInplaceVariableIntroducer
|
||||
builder.replaceElement(typeElement, "Variable_Type", AbstractJavaInplaceIntroducer.createExpression(myExpression, typeElement.getText()), true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCommandName() {
|
||||
return IntroduceVariableBase.REFACTORING_NAME;
|
||||
}
|
||||
|
||||
private static void appendTypeCasts(List<RangeMarker> occurrenceMarkers,
|
||||
PsiFile file,
|
||||
Project project,
|
||||
|
||||
+23
-25
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.introduceParameter;
|
||||
package com.intellij.refactoring.introduce.inplace;
|
||||
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
@@ -70,17 +70,15 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNamedElement, E ext
|
||||
protected abstract void performIntroduce();
|
||||
protected void performPostIntroduceTasks() {}
|
||||
|
||||
public abstract E restoreExpression(PsiFile containingFile, V variable, RangeMarker marker, String exprText);
|
||||
|
||||
protected abstract boolean isReplaceAllOccurrences();
|
||||
protected abstract JComponent getComponent();
|
||||
|
||||
|
||||
protected void restoreAnchors() {}
|
||||
|
||||
protected abstract void saveSettings(V variable);
|
||||
protected abstract V getVariable();
|
||||
|
||||
public abstract E restoreExpression(PsiFile containingFile, V variable, RangeMarker marker, String exprText);
|
||||
protected void restoreAnchors() {}
|
||||
|
||||
public boolean startInplaceIntroduceTemplate() {
|
||||
final boolean replaceAllOccurrences = isReplaceAllOccurrences();
|
||||
final Ref<Boolean> result = new Ref<Boolean>();
|
||||
@@ -115,6 +113,25 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNamedElement, E ext
|
||||
return result.get();
|
||||
}
|
||||
|
||||
public void restartInplaceIntroduceTemplate() {
|
||||
Runnable restartTemplateRunnable = new Runnable() {
|
||||
public void run() {
|
||||
final TemplateState templateState = TemplateManagerImpl.getTemplateState(myEditor);
|
||||
if (templateState != null) {
|
||||
myEditor.putUserData(INTRODUCE_RESTART, true);
|
||||
try {
|
||||
templateState.gotoEnd(true);
|
||||
startInplaceIntroduceTemplate();
|
||||
}
|
||||
finally {
|
||||
myEditor.putUserData(INTRODUCE_RESTART, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CommandProcessor.getInstance().executeCommand(myProject, restartTemplateRunnable, getCommandName(), getCommandName());
|
||||
}
|
||||
|
||||
protected String getInputName() {
|
||||
return myConstantName;
|
||||
}
|
||||
@@ -251,23 +268,4 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNamedElement, E ext
|
||||
performPostIntroduceTasks();
|
||||
}
|
||||
}
|
||||
|
||||
protected void restartTemplate() {
|
||||
Runnable restartTemplateRunnable = new Runnable() {
|
||||
public void run() {
|
||||
final TemplateState templateState = TemplateManagerImpl.getTemplateState(myEditor);
|
||||
if (templateState != null) {
|
||||
myEditor.putUserData(INTRODUCE_RESTART, true);
|
||||
try {
|
||||
templateState.gotoEnd(true);
|
||||
startInplaceIntroduceTemplate();
|
||||
}
|
||||
finally {
|
||||
myEditor.putUserData(INTRODUCE_RESTART, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CommandProcessor.getInstance().executeCommand(myProject, restartTemplateRunnable, getCommandName(), getCommandName());
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.introduceParameter;
|
||||
package com.intellij.refactoring.introduce.inplace;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
@@ -52,10 +52,12 @@ import java.util.List;
|
||||
public abstract class AbstractInplaceVariableIntroducer<E extends PsiElement> extends VariableInplaceRenamer {
|
||||
public static final Key<Boolean> INTRODUCE_RESTART = Key.create("INTRODUCE_RESTART");
|
||||
|
||||
protected List<RangeMarker> myOccurrenceMarkers;
|
||||
protected RangeMarker myExprMarker;
|
||||
protected E myExpr;
|
||||
protected RangeMarker myExprMarker;
|
||||
|
||||
protected E[] myOccurrences;
|
||||
protected List<RangeMarker> myOccurrenceMarkers;
|
||||
|
||||
protected Balloon myBalloon;
|
||||
protected String myTitle;
|
||||
|
||||
@@ -72,7 +74,6 @@ public abstract class AbstractInplaceVariableIntroducer<E extends PsiElement> ex
|
||||
}
|
||||
|
||||
protected abstract JComponent getComponent();
|
||||
protected abstract String getCommandName();
|
||||
|
||||
public void setOccurrenceMarkers(List<RangeMarker> occurrenceMarkers) {
|
||||
myOccurrenceMarkers = occurrenceMarkers;
|
||||
Reference in New Issue
Block a user