From 76956c0ebe42026782e05ddc80d84268bd4cb295 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 23 Jan 2014 10:39:22 +0100 Subject: [PATCH] IDEA-119740 Ctrl+Shift+Space does not complete exception type after "final" --- .../completion/JavaSmartCompletionContributor.java | 8 ++++---- .../completion/smartType/InsideCatchFinal-out.java | 9 +++++++++ .../completion/smartType/InsideCatchFinal.java | 9 +++++++++ .../codeInsight/completion/SmartTypeCompletionTest.java | 3 ++- 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal-out.java create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java index 6a2991674321..1e0fa6c7b792 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java @@ -302,10 +302,10 @@ public class JavaSmartCompletionContributor extends CompletionContributor { }); final Key tryKey = Key.create("try"); - extend(CompletionType.SMART, psiElement().afterLeaf( - psiElement().withText("(")) - .withSuperParent(3, psiElement(PsiCatchSection.class).withParent( - psiElement(PsiTryStatement.class).save(tryKey))), new CompletionProvider() { + extend(CompletionType.SMART, psiElement().insideStarting( + psiElement(PsiTypeElement.class).withParent( + psiElement(PsiCatchSection.class).withParent( + psiElement(PsiTryStatement.class).save(tryKey)))), new CompletionProvider() { @Override protected void addCompletions(@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result) { final PsiCodeBlock tryBlock = context.get(tryKey).getTryBlock(); diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal-out.java new file mode 100644 index 000000000000..4bbdf25b0b97 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal-out.java @@ -0,0 +1,9 @@ +class A{ + +{ + try{ + throw new Exception(); + } + catch(final Exception ) +} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal.java b/java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal.java new file mode 100644 index 000000000000..86328e3da4ba --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InsideCatchFinal.java @@ -0,0 +1,9 @@ +class A{ + +{ + try{ + throw new Exception(); + } + catch(final ) +} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java index a0555fe5f5b5..a45f7a1a540b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java @@ -317,7 +317,8 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { checkResultByFile(path + "/after2.java"); } - public void testInsideCatch() throws Exception { doTest(); } + public void testInsideCatch() { doTest(); } + public void testInsideCatchFinal() { doTest(); } public void testGenerics6() throws Exception { String path = "/generics";