use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class PsiUtilTest method testTypeParameterIterator3.
public void testTypeParameterIterator3() throws Exception {
final PsiClass classA = createClass("class A<T> { class B<X, Y> {}}");
final Iterator<PsiTypeParameter> iterator = PsiUtil.typeParametersIterator(classA.getInnerClasses()[0]);
compareIterator(new String[] { "Y", "X", "T" }, iterator);
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class PsiUtilTest method testTypeParameterIterator2.
public void testTypeParameterIterator2() throws Exception {
final PsiClass classA = createClass("class A<T> { static class B<X> {}}");
final Iterator<PsiTypeParameter> iterator = PsiUtil.typeParametersIterator(classA.getInnerClasses()[0]);
compareIterator(new String[] { "X" }, iterator);
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class InheritanceUtil method existsMutualSubclass.
public static boolean existsMutualSubclass(PsiClass class1, final PsiClass class2, final boolean avoidExpensiveProcessing) {
if (class1 instanceof PsiTypeParameter) {
final PsiClass[] superClasses = class1.getSupers();
for (PsiClass superClass : superClasses) {
if (!existsMutualSubclass(superClass, class2, avoidExpensiveProcessing)) {
return false;
}
}
return true;
}
if (class2 instanceof PsiTypeParameter) {
return existsMutualSubclass(class2, class1, avoidExpensiveProcessing);
}
final String className = class1.getQualifiedName();
if (CommonClassNames.JAVA_LANG_OBJECT.equals(className)) {
return true;
}
final String class2Name = class2.getQualifiedName();
if (CommonClassNames.JAVA_LANG_OBJECT.equals(class2Name)) {
return true;
}
if (class1.isInheritor(class2, true) || class2.isInheritor(class1, true)) {
return true;
}
final SearchScope scope = GlobalSearchScope.allScope(class1.getProject());
final Query<PsiClass> search = ClassInheritorsSearch.search(class1, scope, true);
final boolean[] result = new boolean[1];
search.forEach(new Processor<PsiClass>() {
AtomicInteger count = new AtomicInteger(0);
@Override
public boolean process(PsiClass inheritor) {
if (inheritor.equals(class2) || inheritor.isInheritor(class2, true) || avoidExpensiveProcessing && count.incrementAndGet() > 20) {
result[0] = true;
return false;
}
return true;
}
});
return result[0];
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class PsiUtilTest method testTypeParameterIterator.
public void testTypeParameterIterator() throws Exception {
PsiClass classA = createClass("class A<T> {}");
final Iterator<PsiTypeParameter> iterator = PsiUtil.typeParametersIterator(classA);
compareIterator(new String[] { "T" }, iterator);
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class GroovyTypeParameterInfoHandler method findElementForParameterInfo.
@Nullable
@Override
public GrTypeArgumentList findElementForParameterInfo(@NotNull CreateParameterInfoContext context) {
final GrTypeArgumentList parameterList = ParameterInfoUtils.findParentOfType(context.getFile(), context.getOffset(), GrTypeArgumentList.class);
if (parameterList != null) {
if (!(parameterList.getParent() instanceof GrCodeReferenceElement))
return null;
final GrCodeReferenceElement ref = ((GrCodeReferenceElement) parameterList.getParent());
final PsiElement resolved = ref.resolve();
if (!(resolved instanceof PsiTypeParameterListOwner))
return null;
final PsiTypeParameter[] typeParams = ((PsiTypeParameterListOwner) resolved).getTypeParameters();
if (typeParams.length == 0)
return null;
context.setItemsToShow(typeParams);
return parameterList;
}
return null;
}
Aggregations