String (final PsiJavaCodeReferenceElement element) { String superClassName = null; PsiElement parent = element.getParent(); final PsiElement ggParent = parent.getParent(); if (ggParent instanceof PsiClass && ((PsiClass)ggParent).getPermitsList() == parent) { return ((PsiClass)ggParent).getQualifiedName(); } else if (ggParent instanceof PsiMethod method) { if (method.getThrowsList() == parent) { superClassName = "java.lang.Exception"; } } else if (ggParent instanceof PsiClassObjectAccessExpression) { final ExpectedTypeInfo[] expectedTypes = ExpectedTypesProvider.getExpectedTypes((PsiExpression)ggParent, false); if (expectedTypes.length == 1) { final PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(expectedTypes[0].getType()); final PsiClass psiClass = classResolveResult.getElement(); if (psiClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(psiClass.getQualifiedName())) { final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters(); PsiType psiType = typeParameters.length == 1 ? classResolveResult.getSubstitutor().substitute(typeParameters[0]) : null; if (psiType instanceof PsiWildcardType && ((PsiWildcardType)psiType).isExtends()) { psiType = ((PsiWildcardType)psiType).getExtendsBound(); } final PsiClass aClass = PsiUtil.resolveClassInType(psiType); if (aClass != null) return aClass.getQualifiedName(); } } } else if (ggParent instanceof PsiExpressionList && parent instanceof PsiExpression && (myKind == CreateClassKind.ENUM || myKind == CreateClassKind.RECORD)) { final ExpectedTypeInfo[] expectedTypes = ExpectedTypesProvider.getExpectedTypes((PsiExpression)parent, false); if (expectedTypes.length == 1) { final PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(expectedTypes[0].getType()); final PsiClass psiClass = classResolveResult.getElement(); if (psiClass != null && psiClass.isInterface()) { return psiClass.getQualifiedName(); } } return null; } return superClassName; }