all files / dist/writers/ FunctionBodyWriter.js

100% Statements 27/27
100% Branches 15/15
100% Functions 7/7
100% Lines 27/27
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 40 41  17×   20×   19× 19× 19× 19× 19× 19×     13×                  
"use strict";
var definitions_1 = require("./../definitions");
var WriteFlags_1 = require("./../WriteFlags");
var FunctionBodyWriter = (function () {
    function FunctionBodyWriter(writer) {
        this.writer = writer;
    }
    FunctionBodyWriter.prototype.willWriteFunctionBody = function (def, flags) {
        if (def instanceof definitions_1.InterfaceMethodDefinition)
            return false;
        else {
            var isOnWriteFunctionBodyDefined = typeof def.onWriteFunctionBody === "function";
            var shouldHideFunctionBodies = (flags & WriteFlags_1.WriteFlags.HideFunctionBodies) !== 0;
            var isAmbient = def.isAmbient || false;
            var isAbstract = def.isAbstract || false;
            var suggestedToHideFunctionBody = shouldHideFunctionBodies || isAmbient || isAbstract;
            return isOnWriteFunctionBodyDefined || !suggestedToHideFunctionBody;
        }
    };
    FunctionBodyWriter.prototype.write = function (def, flags) {
        if (this.willWriteFunctionBody(def, flags))
            this.writeFunctionBody(def);
        else
            this.writeSemiColon();
    };
    FunctionBodyWriter.prototype.writeSemiColon = function () {
        this.writer.write(";");
    };
    FunctionBodyWriter.prototype.writeFunctionBody = function (def) {
        var _this = this;
        this.writer.block(function () {
            if (typeof def.onWriteFunctionBody === "function")
                def.onWriteFunctionBody(_this.writer);
        });
    };
    return FunctionBodyWriter;
}());
exports.FunctionBodyWriter = FunctionBodyWriter;
 
//# sourceMappingURL=FunctionBodyWriter.js.map