private boolean shouldMerge(Object groupId, @NotNull CommandMerger nextCommandToMerge) {
    if (nextCommandToMerge.isTransparent() && nextCommandToMerge.myStateAfter == null && myStateAfter != null) return false;
    if (isTransparent() && myStateBefore == null && nextCommandToMerge.myStateBefore != null) return false;
    if (isTransparent() || nextCommandToMerge.isTransparent()) {
      return !hasActions() || !nextCommandToMerge.hasActions() || myAllAffectedDocuments.equals(nextCommandToMerge.myAllAffectedDocuments);
    }

    if ((myForcedGlobal || nextCommandToMerge.myForcedGlobal) && !isMergeGlobalCommandsAllowed()) return false;
    return canMergeGroup(groupId, SoftReference.dereference(myLastGroupId));
  }
private boolean shouldMerge(Object groupId, @NotNull CommandMerger nextCommandToMerge)