Refactoring: Inline KotlinChangePropertyActions.declareValueOrVariable() method

This commit is contained in:
Alexey Sedunov
2015-02-24 16:21:09 +03:00
parent 6a25cd663e
commit 02bf8368c1
2 changed files with 4 additions and 41 deletions
@@ -1,40 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable;
import com.intellij.lang.ASTNode;
import org.jetbrains.kotlin.psi.JetProperty;
import org.jetbrains.kotlin.psi.JetPsiFactory;
import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory;
public class KotlinChangePropertyActions {
private KotlinChangePropertyActions() {
}
public static void declareValueOrVariable(boolean isVariable, JetProperty property) {
ASTNode node;
JetPsiFactory psiFactory = JetPsiFactory(property);
if (isVariable) {
node = psiFactory.createVarNode();
}
else {
node = psiFactory.createValNode();
}
property.getValOrVarNode().getPsi().replace(node.getPsi());
}
}
@@ -91,7 +91,10 @@ public class KotlinInplaceVariableIntroducer extends InplaceVariableIntroducer<J
@Override
protected void run(Result result) throws Throwable {
PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
KotlinChangePropertyActions.declareValueOrVariable(myVarCheckbox.isSelected(), myProperty);
JetPsiFactory psiFactory = new JetPsiFactory(myProject);
ASTNode node = myVarCheckbox.isSelected() ? psiFactory.createVarNode() : psiFactory.createValNode();
myProperty.getValOrVarNode().getPsi().replace(node.getPsi());
}
}.execute();
}