ts-budgie
Version:
Converts TypeScript code to Budgie.
79 lines • 2.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* How a range of source should become Budgie output.
*/
var Transformation = /** @class */ (function () {
/**
* Initializes a new instance of the Transformation class.
*
* @param range Area in the source file to transform.
* @param output Output transformation.
* @param sourceFile Source file of the transformation.
*/
function Transformation(range, output) {
this.range = range;
this.output = output;
}
/**
* Initializes a new Transformation for a comment range.
*
* @param range Area in the source file to transform.
* @param output Output transformation.
* @param sourceFile Source file of the transformation.
* @returns A new Transformation for the comment range.
*/
Transformation.fromCommentRange = function (range, output) {
return new Transformation({
end: range.end,
start: range.pos,
}, output);
};
/**
* Initializes a new Transform for a standard node.
*
* @param node Node from the source file.
* @param sourceFile Source file for the node.
* @param output Output transformation.
* @returns A new Transformation for the node.
*/
Transformation.fromNode = function (node, sourceFile, output) {
return new Transformation({
end: node.getEnd(),
start: node.getStart(sourceFile),
}, output);
};
/**
* Initializes a new Transform for the ending character of a standard node.
*
* @param node Node from the source file.
* @param sourceFile Source file for the node.
* @param output Output transformation.
* @returns A new Transformation for the node.
*/
Transformation.fromNodeEnd = function (node, output) {
var end = node.getEnd();
return new Transformation({
end: end,
start: end - 1,
}, output);
};
/**
* Initializes a new Transform for the starting character of a standard node.
*
* @param node Node from the source file.
* @param sourceFile Source file for the node.
* @param output Output transformation.
* @returns A new Transformation for the node.
*/
Transformation.fromNodeStart = function (node, sourceFile, output) {
var start = node.getStart(sourceFile);
return new Transformation({
end: start + 1,
start: start,
}, output);
};
return Transformation;
}());
exports.Transformation = Transformation;
//# sourceMappingURL=transformation.js.map