UNPKG

ts-budgie

Version:

Converts TypeScript code to Budgie.

44 lines 2.29 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { 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 extendStatics(d, b); }; 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 budgie_1 = require("budgie"); var budgieLine_1 = require("../../../output/budgieLine"); var transformation_1 = require("../../../output/transformation"); var strings_1 = require("../../../parsing/strings"); var propertyAccessChecker_1 = require("./propertyAccessChecker"); var DictionaryIndexAccessChecker = /** @class */ (function (_super) { __extends(DictionaryIndexAccessChecker, _super); function DictionaryIndexAccessChecker() { return _super !== null && _super.apply(this, arguments) || this; } DictionaryIndexAccessChecker.prototype.visit = function (node) { if (!this.isDictionary(node.expression)) { return undefined; } var key = this.router.recurseIntoValue(node.expression); var value = this.router.recurseIntoValue(node.name); if (typeof value === "string") { value = strings_1.wrapWithQuotes(value); } return [transformation_1.Transformation.fromNode(node, this.sourceFile, [new budgieLine_1.BudgieLine("dictionary index", key, value)])]; }; DictionaryIndexAccessChecker.prototype.isDictionary = function (expression) { var friendlyName = this.aliaser.getFriendlyTypeName(expression); return friendlyName instanceof budgieLine_1.BudgieLine ? friendlyName.command === budgie_1.CommandNames.DictionaryType : false; }; return DictionaryIndexAccessChecker; }(propertyAccessChecker_1.PropertyAccessChecker)); exports.DictionaryIndexAccessChecker = DictionaryIndexAccessChecker; //# sourceMappingURL=dictionaryIndexAccessChecker.js.map