private static boolean processClassMembersWithAllNames(@NotNull PsiClass aClass,
                                                         @NotNull PsiScopeProcessor processor,
                                                         @NotNull ResolveState state,
                                                         @Nullable Set<PsiClass> visited,
                                                         PsiElement last,
                                                         @NotNull PsiElement place,
                                                         boolean isRaw,
                                                         @NotNull LanguageLevel languageLevel,
                                                         @NotNull GlobalSearchScope resolveScope) {
    ProgressManager.checkCanceled();
    if (visited == null) {
      visited = new HashSet<>();
    }
    if (!visited.add(aClass)) {
      return true;
    }
    processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, aClass);
    ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);

    if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.FIELD)) {
      if (!processMembers(state, processor, aClass.getFields())) return false;
    }

    PsiElementFactory factory = JavaPsiFacade.getElementFactory(aClass.getProject());

    if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) {
      PsiSubstitutor baseSubstitutor = state.get(PsiSubstitutor.KEY);
      for (PsiMethod method : aClass.getMethods()) {
        PsiSubstitutor finalSubstitutor = checkRaw(isRaw, factory, method, baseSubstitutor);
        ResolveState methodState = finalSubstitutor == baseSubstitutor ? state : state.put(PsiSubstitutor.KEY, finalSubstitutor);
        if (!processor.execute(method, methodState)) return false;
      }
    }

    if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) {
      if (last != null && last.getContext() == aClass) {
        // Parameters
        PsiTypeParameterList list = aClass.getTypeParameterList();
        if (list != null && !list.processDeclarations(processor, ResolveState.initial(), last, place)) return false;
      }

      if (!(last instanceof PsiReferenceList) && !(last instanceof PsiModifierList)) {
        if (!processMembers(state, processor, aClass.getInnerClasses())) return false;
      }
    }

    if (last instanceof PsiReferenceList) return true;

    Set<PsiClass> visited1 = visited;
    return processSuperTypes(aClass, state.get(PsiSubstitutor.KEY), factory, languageLevel, resolveScope,
                             (superClass, finalSubstitutor) -> processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited1, last, place,
                                                                                                               languageLevel, isRaw, resolveScope));
  }
private static boolean processClassMembersWithAllNames(@NotNull PsiClass aClass,
                                                         @NotNull PsiScopeProcessor processor,
                                                         @NotNull ResolveState state,
                                                         @Nullable Set<PsiClass> visited,
                                                         PsiElement last,
                                                         @NotNull PsiElement place,
                                                         boolean isRaw,
                                                         @NotNull LanguageLevel languageLevel,
                                                         @NotNull GlobalSearchScope resolveScope)