List<PsiMember> (@NotNull GlobalSearchScope scope) { List<PsiMember> candidates = new ArrayList<>(); AtomicInteger count = new AtomicInteger(); Processor<PsiMember> processor = member -> { if (!(member instanceof PsiMethod && !ApproximateResolver.canHaveArgCount((PsiMethod)member, argCount))) { candidates.add(member); } return count.incrementAndGet() < 42; }; PsiShortNamesCache cache = PsiShortNamesCache.getInstance(scope.getProject()); if (isCall) { if (!cache.processMethodsWithName(referenceName, processor, scope, null)) { return null; } } else { if (!cache.processFieldsWithName(referenceName, processor, scope, null)) { return null; } } if (!cache.processClassesWithName(referenceName, processor, scope, null)) { return null; } return candidates; }