@Nullable
  private static PsiClass findClassToMove(PsiFile file, int offset) {
    PsiElement element = file.findElementAt(offset);
    while (element != null) {
      if (element instanceof PsiAnonymousClass anonymousClass) {
        return anonymousClass;
      }
      if (element instanceof PsiClass psiClass && PsiUtil.isLocalClass(psiClass)) {
        return psiClass;
      }
      if (element instanceof PsiNewExpression newExpression && newExpression.getAnonymousClass() != null) {
        return newExpression.getAnonymousClass();
      }
      element = element.getParent();
    }
    return null;
  }
@Nullable
  private static PsiClass findClassToMove(PsiFile file, int offset)