Type (@NotNull PsiClassType type) { PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics(); PsiClass aClass = resolveResult.getElement(); if (aClass instanceof PsiAnonymousClass) { return visitClassType(((PsiAnonymousClass)aClass).getBaseClassType()); } else if (aClass == null) { return new UnresolvedType(type); } else { Map<String, Type> substitutionMap = new HashMap<>(); PsiSubstitutor substitutor = resolveResult.getSubstitutor(); for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aClass)) { PsiType substitute = substitutor.substitute(typeParameter); substitutionMap.put(typeParameter.getName(), substitute != null ? substitute.accept(this) : null); } String qualifiedName = ObjectUtils.notNull(aClass.getQualifiedName(), Objects.requireNonNull(aClass.getName())); return new ClassType(type, qualifiedName, substitutionMap); } }