action/group.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupAction = void 0;
const helpers_1 = require("../helpers");
const base_1 = require("./base");
const DEFAULT_START = 2 ** 30;
/**
 * GroupAction to group actions.
 */
class GroupAction extends base_1.BaseAction {
    /**
     * Create a GroupAction
     * @param {object} options
     * @param {Adapter<T>} options.adapter - adapter to parse the node
     */
    constructor({ adapter }) {
        super(undefined, "", { adapter });
        this.actions = [];
        this.type = "group";
        this.start = DEFAULT_START;
        this.end = 0;
    }
    /**
     * Calculate the begin and end positions.
     * @protected
     */
    calculatePositions() {
        (0, helpers_1.iterateActions)(this.actions, (action) => {
            this.start = Math.min(this.start, action.start);
            this.end = Math.max(this.end, action.end);
        });
        if (this.start === DEFAULT_START) {
            this.start = 0;
        }
    }
    get newCode() {
        return undefined;
    }
}
exports.GroupAction = GroupAction;