all files / dist/writers/ MethodWriter.js

57.41% Statements 31/54
46.67% Branches 7/15
40% Functions 4/10
54.9% Lines 28/51
2 statements, 3 branches Ignored     
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66    18× 18× 18× 18× 18× 18× 18×                                                                        
"use strict";
var __extends = (this && this.__extends)/* istanbul ignore next */ || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var definitions_1 = require("./../definitions");
var WriteFlags_1 = require("./../WriteFlags");
var factories_1 = require("./../factories");
var ScopeWriter_1 = require("./ScopeWriter");
var BaseDefinitionWriter_1 = require("./BaseDefinitionWriter");
var FunctionBodyWriter_1 = require("./FunctionBodyWriter");
var FunctionReturnTypeWriter_1 = require("./FunctionReturnTypeWriter");
var MethodWriter = (function (_super) {
    __extends(MethodWriter, _super);
    function MethodWriter() {
        _super.apply(this, arguments);
        this.callSignatureWriter = factories_1.MainFactory.createWriteFactory(this.writer).getCallSignatureWriter();
        this.typeParametersWriter = factories_1.MainFactory.createWriteFactory(this.writer).getTypeParametersWriter();
        this.parametersWriter = factories_1.MainFactory.createWriteFactory(this.writer).getParametersWriter();
        this.scopeWriter = new ScopeWriter_1.ScopeWriter(this.writer);
        this.functionBodyWriter = new FunctionBodyWriter_1.FunctionBodyWriter(this.writer);
        this.functionReturnTypeWriter = new FunctionReturnTypeWriter_1.FunctionReturnTypeWriter(this.writer);
    }
    MethodWriter.prototype.writeDefault = function (def, flags) {
        var _this = this;
        var showImplementation = def.overloadSignatures.length === 0 || (flags & WriteFlags_1.WriteFlags.HideFunctionImplementations) === 0;
        def.overloadSignatures.forEach(function (s) {
            _this.writeStartOfFunctionHeader(def);
            _this.callSignatureWriter.write(s, flags);
        });
        if (showImplementation)
            this.writeImplementation(def, flags);
    };
    MethodWriter.prototype.writeImplementation = function (def, flags) {
        this.writeStartOfFunctionHeader(def);
        this.typeParametersWriter.write(def.typeParameters);
        this.parametersWriter.write(def, flags);
        this.functionReturnTypeWriter.write(def, flags);
        this.functionBodyWriter.write(def, flags);
    };
    MethodWriter.prototype.writeStartOfFunctionHeader = function (def) {
        this.scopeWriter.write(def.scope);
        this.writer.spaceIfLastNotSpace();
        this.writeStatic(def);
        this.writeAbstract(def);
        this.writeAsyncKeyword(def);
        this.writer.conditionalWrite(def.isGenerator, "*");
        this.writer.write(def.name);
    };
    MethodWriter.prototype.writeStatic = function (def) {
        if (def instanceof definitions_1.ClassStaticMethodDefinition) {
            this.writer.write("static ");
        }
    };
    MethodWriter.prototype.writeAbstract = function (def) {
        if (def.isAbstract) {
            this.writer.write("abstract ");
        }
    };
    return MethodWriter;
}(BaseDefinitionWriter_1.BaseDefinitionWriter));
exports.MethodWriter = MethodWriter;
 
//# sourceMappingURL=MethodWriter.js.map