IDEA-144489 "Complete current statement" creates broken code - missing closing paren on method invocation

This commit is contained in:
peter
2015-08-28 15:13:17 +02:00
parent b3fbcd0334
commit 77d4defe4a
4 changed files with 18 additions and 1 deletions
@@ -44,7 +44,7 @@ public class MethodCallFixer implements Fixer {
if (args != null && !hasRParenth(args)) {
int caret = editor.getCaretModel().getOffset();
PsiCallExpression innermostCall = PsiTreeUtil.findElementOfClassAtOffset(psiElement.getContainingFile(), caret, PsiCallExpression.class, false);
PsiCallExpression innermostCall = PsiTreeUtil.findElementOfClassAtOffset(psiElement.getContainingFile(), caret - 1, PsiCallExpression.class, false);
if (innermostCall == null) return;
args = innermostCall.getArgumentList();
@@ -0,0 +1,8 @@
class Main {
public void test() {
double[] d = new double[si<caret>];
}
int size();
int size2();
}
@@ -0,0 +1,8 @@
class Main {
public void test() {
double[] d = new double[size()];<caret>
}
int size();
int size2();
}
@@ -935,6 +935,7 @@ public class ListUtils {
public void testSmartEnterNoNewLine() { doTest(Lookup.COMPLETE_STATEMENT_SELECT_CHAR as String) }
public void testSmartEnterWithNewLine() { doTest(Lookup.COMPLETE_STATEMENT_SELECT_CHAR as String) }
public void testSmartEnterGuessArgumentCount() throws Throwable { doTest(Lookup.COMPLETE_STATEMENT_SELECT_CHAR as String) }
public void testSmartEnterInsideArrayBrackets() { doTest(Lookup.COMPLETE_STATEMENT_SELECT_CHAR as String) }
public void testTabReplacesMethodNameWithLocalVariableName() throws Throwable { doTest('\t'); }
public void testMethodParameterAnnotationClass() throws Throwable { doTest(); }