UNPKG

ts-budgie

Version:

Converts TypeScript code to Budgie.

53 lines 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var budgie_1 = require("budgie"); var lengthCommandTypeAdjustmentChecker_1 = require("./typeAdjustments/lengthCommandTypeAdjustmentChecker"); /** * Budgie commands with known return types, keyed to those return types. */ var knownBudgieLineTypes = new Map([ [budgie_1.CommandNames.StringCaseLower, "string"], [budgie_1.CommandNames.StringCaseUpper, "string"], [budgie_1.CommandNames.StringFormat, "string"], [budgie_1.CommandNames.StringIndexOf, "string"], [budgie_1.CommandNames.StringLength, "int"], [budgie_1.CommandNames.StringSubstringIndex, "string"], [budgie_1.CommandNames.StringSubstringLength, "string"], [budgie_1.CommandNames.StringTrim, "string"], ]); /** * Tries to find more specific types for variable declarations. */ var TypeAdjuster = /** @class */ (function () { function TypeAdjuster() { this.checkers = [new lengthCommandTypeAdjustmentChecker_1.LengthCommandTypeAdjustmentChecker()]; } /** * Tries to find a more specific type for a variable declaration. * * @param info Info on the variable declaration. * @returns More specific type for the variable declaration, if available. */ TypeAdjuster.prototype.attempt = function (info) { for (var _i = 0, _a = this.checkers; _i < _a.length; _i++) { var checker = _a[_i]; var adjustedType = checker.attempt(info); if (adjustedType !== undefined) { return adjustedType; } } return undefined; }; /** * Tries to find a more specific type based on a known Budgie command. * * @param line Budgie command line. * @returns Known type of that command line, if available. */ TypeAdjuster.prototype.getKnownTypeOfBudgieLine = function (line) { return knownBudgieLineTypes.get(line.command); }; return TypeAdjuster; }()); exports.TypeAdjuster = TypeAdjuster; //# sourceMappingURL=types.js.map