From 2c10bed32b01e039e0b3f3d866f3d1d24e483a00 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 1 Sep 2016 14:36:20 +0300 Subject: [PATCH] EA-86898 - assert: CaretImpl.lambda$doSetSelection$ open another editor if fix is invoked from method call --- .../daemon/impl/quickfix/MethodReturnTypeFix.java | 6 ++++-- resources-en/src/messages/QuickFixBundle.properties | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java index a370186e7d48..871f077e312f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnTypeFix.java @@ -135,7 +135,7 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle } if (statementToSelect != null) { - Editor editorForMethod = getEditorForMethod(myMethod, project, editor, statementToSelect.getContainingFile()); + Editor editorForMethod = getEditorForMethod(myMethod, project, editor, file); if (editorForMethod != null) { selectReturnValueInEditor(statementToSelect, editorForMethod); } @@ -308,7 +308,9 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle } static void selectReturnValueInEditor(final PsiReturnStatement returnStatement, final Editor editor) { - TextRange range = returnStatement.getReturnValue().getTextRange(); + final PsiExpression returnValue = returnStatement.getReturnValue(); + LOG.assertTrue(returnValue != null, returnStatement); + TextRange range = returnValue.getTextRange(); int offset = range.getStartOffset(); editor.getCaretModel().moveToOffset(offset); diff --git a/resources-en/src/messages/QuickFixBundle.properties b/resources-en/src/messages/QuickFixBundle.properties index 40230c94545f..9ec2d5c163d4 100644 --- a/resources-en/src/messages/QuickFixBundle.properties +++ b/resources-en/src/messages/QuickFixBundle.properties @@ -119,7 +119,7 @@ make.vararg.parameter.last.family=Make vararg parameter last make.vararg.parameter.last.text=Move ''{0}'' to the end of the list fix.parameter.type.family=Fix Parameter Type fix.parameter.type.text=Make ''{0}'' take parameter of type ''{1}'' here -fix.return.type.family=Fix Return Type +fix.return.type.family=Fix return type fix.return.type.text=Make ''{0}'' return ''{1}'' fix.throws.list.family=Fix Throws List fix.throws.list.add.exception=Add ''{0}'' to ''{1}'' throws list