private static boolean swap(ImmutableActionChangeRange @NotNull [] ranges, int i) {
    ImmutableActionChangeRange first = ranges[i];
    ImmutableActionChangeRange second = ranges[i + 1];

    ImmutableActionChangeRange firstMoved = first.moveAfter(second, true);
    if (firstMoved == null)
      return false;

    ImmutableActionChangeRange secondMoved = second.moveAfter(firstMoved.asInverted(), false);
    if (secondMoved == null)
      return false;

    ranges[i + 1] = firstMoved;
    ranges[i] = secondMoved;
    return true;
  }
private static boolean swap(ImmutableActionChangeRange @NotNull [] ranges, int i)