mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract local variable: notifications restored
This commit is contained in:
+14
@@ -128,6 +128,11 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
return "IntroduceVariable";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRefactoringId() {
|
||||
return "refactoring.extractLocal";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void restoreState(@NotNull PsiVariable psiField) {
|
||||
if (myDeleteSelf) return;
|
||||
@@ -159,6 +164,15 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiExpression getBeforeExpr() {
|
||||
final PsiVariable variable = getVariable();
|
||||
if (variable != null) {
|
||||
return variable.getInitializer();
|
||||
}
|
||||
return super.getBeforeExpr();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performIntroduce() {
|
||||
final PsiVariable psiVariable = getVariable();
|
||||
|
||||
+14
-1
@@ -531,7 +531,16 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
final String refactoringId = getRefactoringId();
|
||||
if (refactoringId != null) {
|
||||
final RefactoringEventData beforeData = new RefactoringEventData();
|
||||
beforeData.addElements(new PsiElement[] {getLocalVariable(), getExpr()});
|
||||
final V localVariable = getLocalVariable();
|
||||
if (localVariable != null) {
|
||||
beforeData.addElement(localVariable);
|
||||
}
|
||||
else {
|
||||
final E beforeExpr = getBeforeExpr();
|
||||
if (beforeExpr != null) {
|
||||
beforeData.addElement(beforeExpr);
|
||||
}
|
||||
}
|
||||
myProject.getMessageBus()
|
||||
.syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(refactoringId, beforeData);
|
||||
}
|
||||
@@ -546,6 +555,10 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
return false;
|
||||
}
|
||||
|
||||
protected E getBeforeExpr() {
|
||||
return getExpr();
|
||||
}
|
||||
|
||||
protected boolean ensureValid() {
|
||||
final String newName = getInputName();
|
||||
if (getLocalVariable() == null && myExpr == null ||
|
||||
|
||||
Reference in New Issue
Block a user