From 217ece149ba78de6ddbedd91249a790233ad8126 Mon Sep 17 00:00:00 2001 From: "peter.gromov" Date: Mon, 8 Nov 2010 16:56:45 +0300 Subject: [PATCH] IDEA-58858 Regression: Incorrect behavior on method name autocomplete if the next statement has a cast --- .../codeInsight/completion/JavaCompletionUtil.java | 8 ++++++++ ...colonAfterExistingParenthesesEspeciallyIfItsACast.java | 5 +++++ ...fterExistingParenthesesEspeciallyIfItsACast_after.java | 5 +++++ .../codeInsight/completion/NormalCompletionTest.groovy | 2 ++ 4 files changed, 20 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast.java create mode 100644 java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast_after.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index fd8e72df578e..f0588fb2a53c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -922,6 +922,14 @@ public class JavaCompletionUtil { // Invoke parameters popup AutoPopupController.getInstance(file.getProject()).autoPopupParameterInfo(editor, overloadsMatter ? null : (PsiElement)item.getObject()); } + + if (tailType == TailType.SEMICOLON) { + PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments(); + if (psiElement().beforeLeaf(psiElement().withText(".")).accepts(file.findElementAt(context.getTailOffset() - 1))) { + return; + } + } + if (tailType == TailType.SMART_COMPLETION || needLeftParenth && needRightParenth) { tailType.processTail(editor, context.getTailOffset()); } diff --git a/java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast.java b/java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast.java new file mode 100644 index 000000000000..8f7b35e3ff22 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast.java @@ -0,0 +1,5 @@ +public class Beda { + { + System.out.printl ((String)"a").subSequence(); + } +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast_after.java b/java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast_after.java new file mode 100644 index 000000000000..25802dce5c1b --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/NoSemicolonAfterExistingParenthesesEspeciallyIfItsACast_after.java @@ -0,0 +1,5 @@ +public class Beda { + { + System.out.println ((String)"a").subSequence(); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index 2e3607a7a4b0..b8ebfd0ea1db 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -596,6 +596,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { doTest(); } + public void testNoSemicolonAfterExistingParenthesesEspeciallyIfItsACast() throws Throwable { doTest(); } + public void testCaseTailType() throws Throwable { doTest(); } def doPrimitiveTypeTest() {