private List<ReferenceType> getClassReferences(@NotNull PsiClass psiClass, SourcePosition position) {
    record ClassInfo(boolean isLocalOrAnonymous, int requiredDepth, String className) {
      @RequiresReadLock
      static ClassInfo create(@NotNull PsiClass psiClass) {
        boolean isLocalOrAnonymous = false;
        int requiredDepth = 0;
        String className = JVMNameUtil.getNonAnonymousClassName(psiClass);
        if (className == null) {
          isLocalOrAnonymous = true;
          Pair<PsiClass, Integer> enclosing = getTopOrStaticEnclosingClass(psiClass);
          PsiClass topLevelClass = enclosing.first;
          if (topLevelClass != null) {
            final String parentClassName = JVMNameUtil.getNonAnonymousClassName(topLevelClass);
            if (parentClassName != null) {
              requiredDepth = enclosing.second;
              className = parentClassName;
            }
          }
          else {
            final StringBuilder sb = new StringBuilder();
            PsiTreeUtil.treeWalkUp(psiClass, null, (element, element2) -> {
              sb.append('\n').append(element);
              return true;
            });
            LOG.info("Local or anonymous class " + psiClass + " has no non-local parent, parents:" + sb);
          }
        }
        return new ClassInfo(isLocalOrAnonymous, requiredDepth, className);
      }
    }
    ClassInfo classInfo = ReadAction.compute(() -> ClassInfo.create(psiClass));

    if (classInfo.className == null) {
      return Collections.emptyList();
    }

    List<ReferenceType> matchingClasses = myDebugProcess.getVirtualMachineProxy().classesByName(classInfo.className);
    if (!classInfo.isLocalOrAnonymous) {
      return matchingClasses;
    }

    return StreamEx.of(matchingClasses)
      .map(outer -> findNested(outer, 0, psiClass, classInfo.requiredDepth, position))
      .nonNull()
      .toList();
  }
private List<ReferenceType> getClassReferences(@NotNull PsiClass psiClass, SourcePosition position)