PsiElement (PsiClass aSuper, PsiReference ref) { PsiElement typeParams = null; if (ref instanceof PsiJavaCodeReferenceElement) { final JavaResolveResult result = ((PsiJavaCodeReferenceElement)ref).advancedResolve(false); final PsiElement aClass = result.getElement(); if (aClass instanceof PsiClass) { final PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(aSuper, (PsiClass)aClass, result.getSubstitutor()); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(aClass.getProject()); final PsiClassType classType = factory.createType(aSuper, substitutor); typeParams = factory.createReferenceFromText(classType.getCanonicalText(), aClass).getParameterList(); } } return typeParams; }