"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplaceWithAction = void 0;
const action_1 = require("../action");
/**
* ReplaceWithAction to replace code.
* @extends BaseAction
*/
class ReplaceWithAction extends action_1.BaseAction {
/**
* Create an ReplaceAction
* @param {T} node
* @param {string} code
* @param {object} options
* @param {Adapter<T>} options.adapter - adapter to parse the node
*/
constructor(node, code, { adapter }) {
super(node, code, { adapter });
this.type = "replace";
}
/**
* Calculate the begin and end positions.
* @protected
*/
calculatePositions() {
this.start = this.adapter.getStart(this.node);
this.end = this.adapter.getEnd(this.node);
}
/**
* The rewritten source code.
* @returns {string} rewritten code.
*/
get newCode() {
return this.rewrittenSource();
}
}
exports.ReplaceWithAction = ReplaceWithAction;