all files / dist/writers/ NamespaceWriter.js

100% Statements 25/25
100% Branches 2/2
100% Functions 7/7
100% Lines 25/25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                           
"use strict";
var definitions_1 = require("./../definitions");
// todo: tests
var NamespaceWriter = (function () {
    function NamespaceWriter(writer, baseDefinitionWriter, documentationedWriter, exportableWriter, ambientableWriter) {
        this.writer = writer;
        this.baseDefinitionWriter = baseDefinitionWriter;
        this.documentationedWriter = documentationedWriter;
        this.exportableWriter = exportableWriter;
        this.ambientableWriter = ambientableWriter;
    }
    NamespaceWriter.prototype.initialize = function (moduledWriter) {
        // this was the only way I could think of to handle the circular dependency caused by the
        // circular nature of the problem... maybe there's a better way
        this.moduledWriter = moduledWriter;
    };
    NamespaceWriter.prototype.write = function (def, flags) {
        var _this = this;
        this.baseDefinitionWriter.writeWrap(def, function () {
            _this.documentationedWriter.write(def);
            _this.exportableWriter.writeExportKeyword(def, flags);
            _this.ambientableWriter.writeDeclareKeyword(def);
            _this.writer.write(_this.getDeclarationTypeAsString(def.declarationType));
            _this.writer.write(" " + def.name).block(function () {
                _this.moduledWriter.write(def, flags);
            });
        });
    };
    NamespaceWriter.prototype.getDeclarationTypeAsString = function (declarationType) {
        if (declarationType === definitions_1.NamespaceDeclarationType.Module)
            return "module";
        return "namespace";
    };
    return NamespaceWriter;
}());
exports.NamespaceWriter = NamespaceWriter;
 
//# sourceMappingURL=NamespaceWriter.js.map