UNPKG

haystack-codegen

Version:

Project Haystack Core code generation tools

42 lines (41 loc) 1.01 kB
"use strict"; /* * Copyright (c) 2021, J2 Innovations. All Rights Reserved */ Object.defineProperty(exports, "__esModule", { value: true }); exports.NamespaceNode = void 0; const util_1 = require("./util"); /** * Generates a TypeScript namespace. */ class NamespaceNode { name; intNode; doc; newLines = 2; constructor(name, intNode, doc) { this.name = name; this.intNode = intNode; this.doc = doc; this.intNode.newLines = 0; } generateCode(out) { out('/**'); out(` * ${this.name}`); if (this.doc.trim()) { out(' *'); (0, util_1.writeDocComment)(out, this.doc); } out(' */'); out(`export namespace ${this.name} {`); (0, util_1.generateNodes)((code) => out(` ${code}`), [this.intNode]); out('}'); } get values() { return this.intNode.values; } get types() { return this.intNode.types; } } exports.NamespaceNode = NamespaceNode;