From d07261265b726af1d56604ebf0c5f94917ca986f Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 21 Mar 2013 20:21:57 +0100 Subject: [PATCH] IDEA-103117 (completion after annotated wildcard parameter) --- .../completion/JavaCompletionData.java | 6 +++--- .../JavaMemberNameCompletionContributor.java | 11 +++++++---- .../completion/keywords/extends13.java | 18 ++++++++++++++++++ .../completion/keywords/extends13_after.java | 18 ++++++++++++++++++ .../completion/KeywordCompletionTest.java | 3 ++- 5 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/keywords/extends13.java create mode 100644 java/java-tests/testData/codeInsight/completion/keywords/extends13_after.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java index b264d0e2bd00..7992e0a4c07d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -483,8 +483,8 @@ public class JavaCompletionData extends JavaAwareCompletionData { } } - if ((isInsideParameterList(position) || isAtResourceVariableStart(position)) && - !psiElement().afterLeaf(PsiKeyword.FINAL).accepts(position) && + if ((isInsideParameterList(position) || isAtResourceVariableStart(position)) && + !psiElement().afterLeaf(PsiKeyword.FINAL).accepts(position) && !AFTER_DOT.accepts(position)) { result.addElement(TailTypeDecorator.withTail(createKeyword(position, PsiKeyword.FINAL), TailType.HUMBLE_SPACE_BEFORE_WORD)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java index 1a21b65af873..1026f48f432f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,8 +52,11 @@ import static com.intellij.patterns.StandardPatterns.or; * @author peter */ public class JavaMemberNameCompletionContributor extends CompletionContributor { - public static final ElementPattern INSIDE_TYPE_PARAMS_PATTERN = - psiElement().afterLeaf(psiElement().withText("?").afterLeaf("<", ",")); + public static final ElementPattern INSIDE_TYPE_PARAMS_PATTERN = psiElement(). + afterLeaf(psiElement().withText("?").andOr( + psiElement().afterLeaf("<", ","), + psiElement().afterSiblingSkipping(psiElement().whitespaceCommentEmptyOrError(), psiElement(PsiAnnotation.class)))); + static final int MAX_SCOPE_SIZE_TO_SEARCH_UNRESOLVED = 50000; @Override @@ -410,7 +413,7 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor { continue outer; } } - + LookupElement element = PrioritizedLookupElement.withPriority(LookupElementBuilder.create(name).withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE), -i); if (callback != null) { element = LookupElementDecorator.withInsertHandler(element, new InsertHandler>() { diff --git a/java/java-tests/testData/codeInsight/completion/keywords/extends13.java b/java/java-tests/testData/codeInsight/completion/keywords/extends13.java new file mode 100644 index 000000000000..fb290a5d235e --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/keywords/extends13.java @@ -0,0 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class A { + Collection<@TA ? ex> +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/keywords/extends13_after.java b/java/java-tests/testData/codeInsight/completion/keywords/extends13_after.java new file mode 100644 index 000000000000..f85ef386450b --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/keywords/extends13_after.java @@ -0,0 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class A { + Collection<@TA ? extends > +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java index 55b27122e5f8..e4a4ca55be6a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +62,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase { public void testExtends10() throws Exception { doTest(false); } public void testExtends11() throws Exception { doTest(false); } public void testExtends12() throws Exception { doTest(false); } + public void testExtends13() throws Exception { doTest(false); } public void testSynchronized1() throws Exception { doTest(false); } public void testSynchronized2() throws Exception {