List<PsiClassType> (PsiType type, GlobalSearchScope scope) { List<PsiClassType> ex = null; for (PsiClassType classType : PsiTypesUtil.getClassTypeComponents(type)) { PsiClassType.ClassResolveResult resourceType = PsiUtil.resolveGenericsClassInType(classType); PsiClass resourceClass = resourceType.getElement(); if (resourceClass == null) continue; PsiMethod[] methods = PsiUtil.getResourceCloserMethodsForType(classType); if (methods != null) { for (PsiMethod method : methods) { PsiClass closerClass = method.getContainingClass(); if (closerClass != null) { PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(closerClass, resourceClass, resourceType.getSubstitutor()); if (substitutor != null) { final PsiClassType[] exceptionTypes = method.getThrowsList().getReferencedTypes(); if (exceptionTypes.length == 0) return Collections.emptyList(); if (ex == null) { ex = collectSubstituted(substitutor, exceptionTypes, scope); } else { retainExceptions(ex, collectSubstituted(substitutor, exceptionTypes, scope)); } } } } } } return ex; }