mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-68178 Completions does not complete class names in java annotations
This commit is contained in:
+6
-2
@@ -41,6 +41,7 @@ import com.intellij.psi.filters.element.ModifierFilter;
|
||||
import com.intellij.psi.filters.getters.ExpectedTypesGetter;
|
||||
import com.intellij.psi.filters.types.AssignableFromFilter;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.scope.ElementClassFilter;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -50,7 +51,10 @@ import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.patterns.PsiJavaPatterns.*;
|
||||
|
||||
@@ -94,7 +98,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
or(psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiCatchSection.class)),
|
||||
psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiParameter.class).withSuperParent(3, PsiCatchSection.class)));
|
||||
static final ElementPattern<PsiElement> INSIDE_METHOD_THROWS_CLAUSE =
|
||||
psiElement().afterLeaf(PsiKeyword.THROWS, ",").inside(PsiMethod.class).andNot(psiElement().inside(PsiCodeBlock.class)).andNot(psiElement().inside(PsiParameterList.class));
|
||||
psiElement().afterLeaf(PsiKeyword.THROWS, ",").inside(psiElement(JavaElementType.THROWS_LIST));
|
||||
static final ElementPattern<PsiElement> IN_RESOURCE_TYPE =
|
||||
psiElement().withParent(psiElement(PsiJavaCodeReferenceElement.class).
|
||||
withParent(psiElement(PsiTypeElement.class).
|
||||
|
||||
@@ -45,21 +45,22 @@ public class ClassLiteralGetter {
|
||||
PsiType classParameter = PsiUtil.substituteTypeParameter(parameters.getExpectedType(), CommonClassNames.JAVA_LANG_CLASS, 0, false);
|
||||
|
||||
boolean addInheritors = false;
|
||||
PsiElement position = parameters.getPosition();
|
||||
if (classParameter instanceof PsiWildcardType) {
|
||||
final PsiWildcardType wildcardType = (PsiWildcardType)classParameter;
|
||||
classParameter = wildcardType.getBound();
|
||||
addInheritors = wildcardType.isExtends() && classParameter instanceof PsiClassType;
|
||||
} else if (!matcher.getPrefix().isEmpty()) {
|
||||
addInheritors = true;
|
||||
classParameter = PsiType.getJavaLangObject(position.getManager(), position.getResolveScope());
|
||||
}
|
||||
if (classParameter == null) {
|
||||
return;
|
||||
if (classParameter != null) {
|
||||
PsiFile file = position.getContainingFile();
|
||||
addClassLiteralLookupElement(classParameter, result, file);
|
||||
if (addInheritors) {
|
||||
addInheritorClassLiterals(file, shortNameCondition, classParameter, result, matcher);
|
||||
}
|
||||
}
|
||||
|
||||
PsiFile file = parameters.getPosition().getContainingFile();
|
||||
addClassLiteralLookupElement(classParameter, result, file);
|
||||
if (addInheritors) {
|
||||
addInheritorClassLiterals(file, shortNameCondition, classParameter, result, matcher);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void addInheritorClassLiterals(PsiFile context,
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = { Aaaaaa<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = { Object.class, Aaaaaa<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = { Object.class, Aaaaaaaaaaaaaaaaaaaaa<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = { Aaaaaaaaaaaaaaaaaaaaa<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = { Aaaaaaaaaaaaaaaaaaaaa.class<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = { Aaaaaa<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.Object;
|
||||
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = {Object.class, Aaaaaaaaaaaaaaaaaaaaa.class<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.Object;
|
||||
|
||||
@interface TestFor {
|
||||
Class[] testForClass();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@TestFor(testForClass = {Object.class, Aaaaaa<caret> } )
|
||||
public void foo22() {}
|
||||
}
|
||||
|
||||
class Aaaaaaaaaaaaaaaaaaaaa {}
|
||||
+3
@@ -176,6 +176,9 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
assertTrue("Exception not found", Arrays.binarySearch(myItems, "xxx") > 0);
|
||||
}
|
||||
|
||||
public void testClassLiteralInArrayAnnoInitializer() throws Throwable { doTest(); }
|
||||
public void testClassLiteralInArrayAnnoInitializer2() throws Throwable { doTest(); }
|
||||
|
||||
public void testReferenceParameters() throws Exception {
|
||||
configureByFile("ReferenceParameters.java");
|
||||
assertNotNull(myItems);
|
||||
|
||||
+2
@@ -801,6 +801,8 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testCastWith2TypeParameters() throws Throwable { doTest(); }
|
||||
public void testClassLiteralInArrayAnnoInitializer() throws Throwable { doTest(); }
|
||||
public void testClassLiteralInArrayAnnoInitializer2() throws Throwable { doTest(); }
|
||||
|
||||
public void testAnnotation() throws Exception {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user