@ApiStatus.Internal
  @VisibleForTesting
  public static boolean shouldEnterModalityState(@NotNull Task task) {
    return task.isModal() ||
           EDT.isCurrentThreadEdt() &&
           !isSynchronousHeadless(task) &&
           isSynchronous(task.asBackgroundable());
  }
@ApiStatus.Internal
  @VisibleForTesting
  public static boolean shouldEnterModalityState(@NotNull Task task)