diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java index 9b7cdba6ee4..298eb0f81e1 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java @@ -80,21 +80,9 @@ public class ChangeVariableMutabilityFix implements IntentionAction { public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { JetProperty property = getCorrespondingProperty(editor, (JetFile)file); assert property != null && !property.isVar(); - JetProperty newElement = (JetProperty) property.copy(); - if (newElement.isVar()) { - PsiElement varElement = newElement.getNode().findChildByType(JetTokens.VAR_KEYWORD).getPsi(); - JetProperty valProperty = JetPsiFactory.createProperty(project, "x", "Any", false); - PsiElement valElement = valProperty.getNode().findChildByType(JetTokens.VAL_KEYWORD).getPsi(); - CodeEditUtil.replaceChild(newElement.getNode(), varElement.getNode(), valElement.getNode()); - } - else { - PsiElement valElement = newElement.getNode().findChildByType(JetTokens.VAL_KEYWORD).getPsi(); - - JetProperty varProperty = JetPsiFactory.createProperty(project, "x", "Any", true); - PsiElement varElement = varProperty.getNode().findChildByType(JetTokens.VAR_KEYWORD).getPsi(); - CodeEditUtil.replaceChild(newElement.getNode(), valElement.getNode(), varElement.getNode()); - } + JetProperty newElement = JetPsiFactory.createProperty(project, property.getText().replaceFirst( + property.isVar() ? "var" : "val", property.isVar() ? "val" : "var")); property.replace(newElement); } diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceOperationInBinaryExpressionFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceOperationInBinaryExpressionFix.java index 5dad7492772..77a128322a1 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceOperationInBinaryExpressionFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceOperationInBinaryExpressionFix.java @@ -10,16 +10,17 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement; import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetPsiFactory; +import org.jetbrains.jet.lang.psi.JetTypeReference; import org.jetbrains.jet.plugin.JetBundle; /** * @author svtk */ public abstract class ReplaceOperationInBinaryExpressionFix extends JetIntentionAction { - private final String expressionWithNecessaryOperation; - public ReplaceOperationInBinaryExpressionFix(@NotNull T element, String expressionWithNecessaryOperation) { + private final String operation; + public ReplaceOperationInBinaryExpressionFix(@NotNull T element, String operation) { super(element); - this.expressionWithNecessaryOperation = expressionWithNecessaryOperation; + this.operation = operation; } @NotNull @@ -31,12 +32,12 @@ public abstract class ReplaceOperationInBinaryExpressionFix createAction(DiagnosticWithPsiElement diagnostic) { assert diagnostic.getPsiElement() instanceof JetBinaryExpressionWithTypeRHS; - return new ReplaceOperationInBinaryExpressionFix((JetBinaryExpressionWithTypeRHS) diagnostic.getPsiElement(), "2 : Int") { + return new ReplaceOperationInBinaryExpressionFix((JetBinaryExpressionWithTypeRHS) diagnostic.getPsiElement(), " : ") { @NotNull @Override public String getText() { diff --git a/idea/testData/quickfix/variables/changeMutability/afterValWithSetter.kt b/idea/testData/quickfix/variables/changeMutability/afterValWithSetter.kt index 86d2423c318..ca89842347b 100644 --- a/idea/testData/quickfix/variables/changeMutability/afterValWithSetter.kt +++ b/idea/testData/quickfix/variables/changeMutability/afterValWithSetter.kt @@ -1,5 +1,6 @@ // "Make variable mutable" "true" class A() { var a: Int = 0 - set(v: Int) {} + set(v: Int) { + } }