Better code for change variable mutability fix
This commit is contained in:
@@ -86,11 +86,8 @@ public class ChangeVariableMutabilityFix implements IntentionAction {
|
|||||||
@Override
|
@Override
|
||||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||||
JetProperty property = getCorrespondingProperty(editor, (JetFile)file);
|
JetProperty property = getCorrespondingProperty(editor, (JetFile)file);
|
||||||
assert property != null && !property.isVar();
|
assert property != null;
|
||||||
|
property.getValOrVarNode().getPsi().replace(JetPsiFactory.createValOrVarNode(project, isVar ? "val" : "var").getPsi());
|
||||||
JetProperty newElement = JetPsiFactory.createProperty(project, property.getText().replaceFirst(
|
|
||||||
property.isVar() ? "var" : "val", property.isVar() ? "val" : "var"));
|
|
||||||
property.replace(newElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Make variable mutable" "true"
|
||||||
class A() {
|
class A() {
|
||||||
var a: Int = 0
|
var a: Int = 0
|
||||||
set(v: Int) {
|
set(v: Int) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user