in lib/generator.js [2593:2646]
visitInit(ast, types, main, filepath, level, env) {
assert.equal(ast.type, 'init');
types.forEach((item) => {
let comments = DSL.comment.getFrontComments(this.comments, item.tokenRange[0]);
this.visitComments(comments, level + 2);
this.emit('protected ', level + 2);
if (item.value.type || item.value.idType) {
this.visitType(item.value);
this.emit(' ');
} else if (this.imports[_name(item.value)]) {
const realClsName = this.getRealClientName(_name(item.value));
this.emit(`${realClsName || 'Client'} `);
} else {
this.emit(`${this._type(_name(item.value))} `);
}
this.emit(`${_vid(item.vid)};\n`);
});
this.emit('\n');
this.visitAnnotation(ast.annotation, level + 2);
let comments = DSL.comment.getFrontComments(this.comments, ast.tokenRange[0]);
this.visitComments(comments, level + 2);
let className = this.className;
if (!main) {
const fileInfo = path.parse(filepath);
const beginNotes = DSL.note.getNotes(this.notes, 0, this.ast.moduleBody.nodes[0].tokenRange[0]);
const clientNote = beginNotes.find(note => note.note.lexeme === '@clientName');
if (clientNote) {
className = clientNote.arg.value.string;
} else {
className = `${_upperFirst(fileInfo.name.toLowerCase())}Client`;
}
}
this.emit(`public ${className || 'Client'}`, level + 2);
this.visitParams(ast.params);
if (ast.initBody && ast.initBody.stmts[0] && ast.initBody.stmts[0].type === 'super') {
this.emit(`: base(`);
for (let i = 0; i < ast.initBody.stmts[0].args.length; i++) {
if (i > 0) {
this.emit(', ');
}
this.visitExpr(ast.initBody.stmts[0].args[i], level, env);
}
this.emit(`)`);
}
this.emit('\n');
this.emit('{\n', level + 2);
if (ast.initBody) {
this.visitStmts(ast.initBody, level + 3, {
isAsyncMode: false
});
}
this.emit('}\n\n', level + 2);
}