void (final String memberName, final PsiFile file, final Set<? super String> possibleClassNames, final boolean method, final boolean staticAccess, final boolean addObjectInheritors) { final Project project = file.getProject(); final Module moduleForFile = ModuleUtilCore.findModuleForPsiElement(file); if (moduleForFile == null) return; final GlobalSearchScope searchScope = ReadAction.compute(file::getResolveScope); GlobalSearchScope descendantsSearchScope = GlobalSearchScope.moduleWithDependenciesScope(moduleForFile); final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project); if (handleObjectMethod(possibleClassNames, facade, searchScope, method, memberName, staticAccess, addObjectInheritors)) { return; } final PsiMember[] members = ReadAction.compute( () -> method ? cache.getMethodsByName(memberName, searchScope) : cache.getFieldsByName(memberName, searchScope)); for (int i = 0; i < members.length; ++i) { final PsiMember member = members[i]; if (hasCorrectModifiers(member, staticAccess)) { final PsiClass containingClass = member.getContainingClass(); if (containingClass != null) { final String qName = getQualifiedName(containingClass); if (qName == null) continue; ClassInheritorsSearch.search(containingClass, descendantsSearchScope, true, true, false).forEach(psiClass -> { ContainerUtil.addIfNotNull(possibleClassNames, getQualifiedName(psiClass)); return true; }); possibleClassNames.add(qName); } } members[i] = null; } }