UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for static analysis and code manipulation.

100 lines (99 loc) 4.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var base_1 = require("../base"); var callBaseSet_1 = require("../callBaseSet"); var module_1 = require("../module"); var Statement_1 = require("./Statement"); var callBaseGetStructure_1 = require("../callBaseGetStructure"); exports.VariableStatementBase = base_1.ChildOrderableNode(module_1.NamespaceChildableNode(base_1.JSDocableNode(base_1.AmbientableNode(base_1.ExportableNode(base_1.ModifierableNode(Statement_1.Statement)))))); var VariableStatement = /** @class */ (function (_super) { tslib_1.__extends(VariableStatement, _super); function VariableStatement() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get variable declaration list. */ VariableStatement.prototype.getDeclarationList = function () { return this._getNodeFromCompilerNode(this.compilerNode.declarationList); }; /** * Get the variable declarations. */ VariableStatement.prototype.getDeclarations = function () { return this.getDeclarationList().getDeclarations(); }; /** * Gets the variable declaration kind. */ VariableStatement.prototype.getDeclarationKind = function () { return this.getDeclarationList().getDeclarationKind(); }; /** * Gets the variable declaration kind keyword. */ VariableStatement.prototype.getDeclarationKindKeyword = function () { return this.getDeclarationList().getDeclarationKindKeyword(); }; /** * Sets the variable declaration kind. * @param type - Type to set. */ VariableStatement.prototype.setDeclarationKind = function (type) { return this.getDeclarationList().setDeclarationKind(type); }; /** * Add a variable declaration to the statement. * @param structure - Structure representing the variable declaration to add. */ VariableStatement.prototype.addDeclaration = function (structure) { return this.getDeclarationList().addDeclaration(structure); }; /** * Adds variable declarations to the statement. * @param structures - Structures representing the variable declarations to add. */ VariableStatement.prototype.addDeclarations = function (structures) { return this.getDeclarationList().addDeclarations(structures); }; /** * Inserts a variable declaration at the specified index within the statement. * @param index - Child index to insert at. * @param structure - Structure representing the variable declaration to insert. */ VariableStatement.prototype.insertDeclaration = function (index, structure) { return this.getDeclarationList().insertDeclaration(index, structure); }; /** * Inserts variable declarations at the specified index within the statement. * @param index - Child index to insert at. * @param structures - Structures representing the variable declarations to insert. */ VariableStatement.prototype.insertDeclarations = function (index, structures) { return this.getDeclarationList().insertDeclarations(index, structures); }; /** * Sets the node from a structure. * @param structure - Structure to set the node with. */ VariableStatement.prototype.set = function (structure) { callBaseSet_1.callBaseSet(exports.VariableStatementBase.prototype, this, structure); this.getDeclarationList().set({ declarationKind: structure.declarationKind, declarations: structure.declarations }); return this; }; /** * Gets the structure equivalent to this node. */ VariableStatement.prototype.getStructure = function () { return callBaseGetStructure_1.callBaseGetStructure(exports.VariableStatementBase.prototype, this, { declarationKind: this.getDeclarationKind(), declarations: this.getDeclarations().map(function (declaration) { return declaration.getStructure(); }) }); }; return VariableStatement; }(exports.VariableStatementBase)); exports.VariableStatement = VariableStatement;