"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
|