suggest extends&super in wildcards (IDEA-97765, IDEA-57321)

This commit is contained in:
peter
2012-12-18 18:25:31 +01:00
parent ea73902b92
commit 3e0d7a41c9
6 changed files with 17 additions and 46 deletions
@@ -53,17 +53,4 @@ public class Java15CompletionData extends JavaCompletionData {
}
}
@Override
protected void initVariantsInClassScope() {
super.initVariantsInClassScope();
{
//Completion of "extends" & "super" inside wildcards
final CompletionVariant variant = new CompletionVariant(JavaMemberNameCompletionContributor.INSIDE_TYPE_PARAMS_PATTERN);
variant.includeScopeClass(PsiVariable.class, true);
variant.includeScopeClass(PsiExpressionStatement.class, true);
variant.addCompletion(PsiKeyword.SUPER, TailType.HUMBLE_SPACE_BEFORE_WORD);
variant.addCompletion(PsiKeyword.EXTENDS, TailType.HUMBLE_SPACE_BEFORE_WORD);
registerVariant(variant);
}
}
}
@@ -135,7 +135,8 @@ public class JavaCompletionData extends JavaAwareCompletionData {
not(psiElement().afterLeaf(PsiKeyword.CASE)),
not(psiElement().afterLeaf(psiElement().withText(".").afterLeaf(PsiKeyword.THIS, PsiKeyword.SUPER))),
not(psiElement().inside(PsiAnnotation.class)),
not(START_SWITCH));
not(START_SWITCH),
not(JavaMemberNameCompletionContributor.INSIDE_TYPE_PARAMS_PATTERN));
private static final String[] PRIMITIVE_TYPES = new String[]{
PsiKeyword.SHORT, PsiKeyword.BOOLEAN,
@@ -522,6 +523,11 @@ public class JavaCompletionData extends JavaAwareCompletionData {
new SameSignatureCallParametersProvider().addCompletions(parameters, new ProcessingContext(), result);
}
}
if (JavaMemberNameCompletionContributor.INSIDE_TYPE_PARAMS_PATTERN.accepts(position)) {
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.EXTENDS), TailType.HUMBLE_SPACE_BEFORE_WORD));
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.SUPER), TailType.HUMBLE_SPACE_BEFORE_WORD));
}
}
private static boolean isExpressionPosition(PsiElement position) {
@@ -1,19 +1,3 @@
/*
* 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.
*/
public class Main {
public static void main() {
@@ -0,0 +1,9 @@
public class Main {
public int compare(Object value1, Object value2) {
if (value1 instanceof Comparable && value2 instanceof Comparable) {
return ((Comparable<? <caret>>) value1).compareTo(value2);
}
throw new IllegalArgumentException();
}
}
@@ -1,19 +1,3 @@
/*
* 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.
*/
public class Main {
public static void main() {
@@ -85,6 +85,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
checkResultByFile(BASE_PATH + "/" + getTestName(true) + "_after.java");
}
public void testExtendsInCastTypeParameters() throws Exception { doTest(false); }
public void testExtendsInCastTypeParameters2() throws Exception { doTest(2, "extends", "super"); }
public void testExtendsWithRightContextInClassTypeParameters() throws Exception { doTest(false); }
public void testTrueInVariableDeclaration() throws Exception { doTest(true); }
public void testNullInIf() throws Exception { doTest(true); }