private static PsiClass @Nullable [] getClassesWithMember(final PsiReference reference, final PsiMember member) {
    return ApplicationManager.getApplication().runReadAction(new Computable<>() {
      @Override
      public PsiClass[] compute() {
        PsiClass containingClass = member.getContainingClass();
        final PsiExpression expression = ((PsiReferenceExpression)reference).getQualifierExpression();
        PsiClass psiClass;
        if (reference instanceof PsiMethodReferenceExpression) {
          psiClass = PsiMethodReferenceUtil.getQualifierResolveResult((PsiMethodReferenceExpression)reference).getContainingClass();
        }
        else if (expression != null) {
          psiClass = PsiUtil.resolveClassInType(expression.getType());
        }
        else {
          if (member instanceof PsiClass) {
            psiClass = (PsiClass)member;
            final PsiElement resolve = ((PsiReferenceExpression)reference).advancedResolve(true).getElement();
            if (resolve instanceof PsiClass) {
              containingClass = (PsiClass)resolve;
            }
          }
          else {
            psiClass = PsiTreeUtil.getParentOfType((PsiReferenceExpression)reference, PsiClass.class);
          }
        }

        if (containingClass == null && psiClass == null) return PsiClass.EMPTY_ARRAY;
        if (containingClass != null) {
          PsiClass[] inheritors = getInheritors(containingClass, psiClass, new HashSet<>());
          return inheritors.length == 0 ? null : inheritors;
        }
        return null;
      }

      private static PsiClass[] getInheritors(PsiClass containingClass, PsiClass psiClass, Set<? super PsiClass> visited) {
        if (psiClass instanceof PsiTypeParameter) {
          List<PsiClass> result = new ArrayList<>();
          for (PsiClassType classType : psiClass.getExtendsListTypes()) {
            PsiClass aClass = classType.resolve();
            if (aClass != null && visited.add(aClass)) {
              ContainerUtil.addAll(result, getInheritors(containingClass, aClass, visited));
            }
          }
          return result.toArray(PsiClass.EMPTY_ARRAY);
        }

        PsiElementFindProcessor<PsiClass> processor1 = new PsiElementFindProcessor<>(containingClass);
        while (psiClass != null) {
          if (!processor1.process(psiClass) ||
              !ClassInheritorsSearch.search(containingClass).forEach(new PsiElementFindProcessor<>(psiClass)) ||
              !ClassInheritorsSearch.search(psiClass).forEach(processor1)) {
            return new PsiClass[]{psiClass};
          }
          psiClass = psiClass.getContainingClass();
        }
        return PsiClass.EMPTY_ARRAY;
      }
    });
  }
private static PsiClass @Nullable [] getClassesWithMember(final PsiReference reference, final PsiMember member)