void (PsiMember[] members, final PsiExpression expression, List<ExpectedTypeInfo[]> types, PsiElementFactory factory) { Arrays.sort(members, (m1, m2) -> compareMembers(m1, m2, expression)); List<ExpectedTypeInfo> l = new ArrayList<>(); PsiManager manager = expression.getManager(); JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); for (PsiMember member : members) { ProgressManager.checkCanceled(); PsiClass aClass = member.getContainingClass(); if (aClass instanceof PsiAnonymousClass || aClass == null) continue; if (facade.getResolveHelper().isAccessible(member, expression, null)) { PsiClassType type; final PsiElement pparent = expression.getParent().getParent(); if (pparent instanceof PsiMethodCallExpression && member instanceof PsiMethod) { PsiSubstitutor substitutor = ExpectedTypeUtil.inferSubstitutor((PsiMethod)member, (PsiMethodCallExpression)pparent, false); if (substitutor == null) { type = factory.createType(aClass); } else { type = factory.createType(aClass, substitutor); } } else { type = factory.createType(aClass); } l.add(ExpectedTypesProvider.createInfo(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type, TailTypes.noneType())); if (l.size() == MAX_GUESSED_MEMBERS_COUNT) break; } } if (!l.isEmpty()) { types.add(l.toArray(ExpectedTypeInfo.EMPTY_ARRAY)); } }