diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index dbd54120d2d..885b858b7e7 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -23,7 +23,8 @@ remove.elvis.operator=Remove elvis operator replace.operation.in.binary.expression=Replace operation in a binary expression replace.cast.with.static.assert=Replace a cast with a static assert replace.with.dot.call=Replace with dot call -replace.with.safe.call=Replace with safe call +replace.with.safe.call=Replace with safe (?.) call +replace.with.nna.call=Replace with non-null asserted (!!.) call change.to.backing.field=Change reference to backing field implement.members=Implement members new.kotlin.file.action=Kotlin File diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceCallFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceCallFix.java index 1a6fa7c04a0..2205c724db4 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceCallFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceCallFix.java @@ -31,23 +31,26 @@ import org.jetbrains.jet.plugin.JetBundle; * @author svtk */ public class ReplaceCallFix implements IntentionAction { - private final boolean toSafe; + private final boolean safe; + private final boolean fromDot; - public ReplaceCallFix(boolean toSafe) { - this.toSafe = toSafe; + public ReplaceCallFix(boolean safe, boolean fromDot) { + this.safe = safe; + this.fromDot = fromDot; } - @NotNull @Override public String getText() { - return toSafe ? JetBundle.message("replace.with.safe.call") : JetBundle.message("replace.with.dot.call"); + return fromDot + ? (safe ? JetBundle.message("replace.with.safe.call") : JetBundle.message("replace.with.nna.call")) + : JetBundle.message("replace.with.dot.call"); } @NotNull @Override public String getFamilyName() { - return toSafe ? JetBundle.message("replace.with.safe.call") : JetBundle.message("replace.with.dot.call"); + return getText(); } @Override @@ -60,7 +63,7 @@ public class ReplaceCallFix implements IntentionAction { private JetQualifiedExpression getCallExpression(@NotNull Editor editor, @NotNull JetFile file) { final PsiElement elementAtCaret = file.findElementAt(editor.getCaretModel().getOffset()); - return PsiTreeUtil.getParentOfType(elementAtCaret, toSafe ? JetDotQualifiedExpression.class : JetSafeQualifiedExpression.class); + return PsiTreeUtil.getParentOfType(elementAtCaret, fromDot ? JetDotQualifiedExpression.class : JetSafeQualifiedExpression.class); } @Override @@ -71,7 +74,8 @@ public class ReplaceCallFix implements IntentionAction { JetExpression selector = callExpression.getSelectorExpression(); if (selector != null) { JetQualifiedExpression newElement = (JetQualifiedExpression) JetPsiFactory.createExpression( - project, callExpression.getReceiverExpression().getText() + (toSafe ? "?." : ".") + selector.getText()); + project, + callExpression.getReceiverExpression().getText() + (fromDot ? (safe ? "?." : "!!.") : ".") + selector.getText()); callExpression.replace(newElement); }