@Override
    public void visitAnonymousClass(@NotNull PsiAnonymousClass anonymousClass) {
      if (anonymousClass instanceof PsiEnumConstantInitializer) {
        return;
      }
      if (PsiUtil.isAvailable(JavaFeature.INNER_NOT_CAPTURE_THIS, anonymousClass) &&
          !InheritanceUtil.isInheritor(anonymousClass, CommonClassNames.JAVA_IO_SERIALIZABLE)) {
        // Since Java 18, non-serializable anonymous classes don't capture 'this' reference
        return;
      }
      final PsiMember containingMember = PsiTreeUtil.getParentOfType(anonymousClass, PsiMember.class);
      if (containingMember == null || containingMember.hasModifierProperty(PsiModifier.STATIC)) {
        return;
      }
      final PsiJavaCodeReferenceElement reference = anonymousClass.getBaseClassReference();
      if (reference.resolve() == null) {
        // don't warn on broken code
        return;
      }
      final PsiClass containingClass = PsiTreeUtil.getParentOfType(anonymousClass, PsiClass.class);
      if (containingClass == null) {
        return;
      }
      if (containingClass.getContainingClass() != null && !containingClass.hasModifierProperty(PsiModifier.STATIC)) {
        // strictly speaking can be named static inner class but not when part of the current containing class
        return;
      }
      final InnerClassReferenceVisitor visitor = new InnerClassReferenceVisitor(anonymousClass);
      anonymousClass.accept(visitor);
      if (!visitor.canInnerClassBeStatic()) {
        return;
      }
      if (hasReferenceToLocalClass(anonymousClass)) {
        return;
      }
      registerClassError(anonymousClass);
    }
@Override
    public void visitAnonymousClass(@NotNull PsiAnonymousClass anonymousClass)