UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

56 lines (55 loc) 2.36 kB
"use strict"; var __extends = (this && this.__extends)/* istanbul ignore next */ || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var errors = require("./../../errors"); var Statement_1 = require("./Statement"); exports.TryStatementBase = Statement_1.Statement; var TryStatement = /** @class */ (function (_super) { __extends(TryStatement, _super); function TryStatement() { return _super !== null && _super.apply(this, arguments) || this; } /** * Gets this try statement's try block. */ TryStatement.prototype.getTryBlock = function () { return this.getNodeFromCompilerNode(this.compilerNode.tryBlock); }; /** * Gets this try statement's catch clause or undefined if none exists. */ TryStatement.prototype.getCatchClause = function () { return this.getNodeFromCompilerNodeIfExists(this.compilerNode.catchClause); }; /** * Gets this try statement's catch clause or throws if none exists. */ TryStatement.prototype.getCatchClauseOrThrow = function () { return errors.throwIfNullOrUndefined(this.getCatchClause(), "Expected to find a catch clause."); }; /** * Gets this try statement's finally block or undefined if none exists. */ TryStatement.prototype.getFinallyBlock = function () { if (this.compilerNode.finallyBlock == null || this.compilerNode.finallyBlock.getFullWidth() === 0) return undefined; return this.getNodeFromCompilerNode(this.compilerNode.finallyBlock); }; /** * Gets this try statement's finally block or throws if none exists. */ TryStatement.prototype.getFinallyBlockOrThrow = function () { return errors.throwIfNullOrUndefined(this.getFinallyBlock(), "Expected to find a finally block."); }; return TryStatement; }(exports.TryStatementBase)); exports.TryStatement = TryStatement;