in lib/generator.js [1726:1771]
eachAPI(ast, level) {
this.visitAnnotation(ast.annotation, level);
let comments = DSL.comment.getFrontComments(this.comments, ast.tokenRange[0]);
this.visitComments(comments, level);
this.emit('public ', level);
this.visitType(ast.returnType);
this.emit(` ${_name(ast.apiName)}`);
this.visitParams(ast.params, level);
if (!this.NoException) {
this.emit(' throws Exception');
}
this.emit(' {\n');
for (var i = 0; i < ast.params.params.length; i++) {
const param = ast.params.params[i];
if (_name(param.paramType) && !DSL.util.isBasicType(_name(param.paramType)) && param.paramName.lexeme !== 'client') {
this.emit(`TeaModel.validateParams(${param.paramName.lexeme}, "${param.paramName.lexeme}");\n`, level + 1);
}
}
let baseLevel = ast.runtimeBody ? level + 2 : level;
// api level
if (ast.runtimeBody) {
this.visitRuntimeBefore(ast.runtimeBody, level + 1);
}
this.visitAPIBody(ast.apiBody, baseLevel + 1);
if (ast.runtimeBody) {
this.emit(`_lastRequest = ${REQUEST};\n`, baseLevel + 1);
}
this.emit(`TeaResponse ${RESPONSE} = Tea.doAction(${REQUEST}`, baseLevel + 1);
if (ast.runtimeBody) {
this.emit(`, ${RUNTIME}`);
} else {
this.emit(`, new java.util.HashMap<String, Object>()`);
}
this.emit(', interceptorChain);\n');
if (ast.returns) {
this.visitReturnBody(ast.returns, baseLevel + 1);
}
if (ast.runtimeBody) {
this.visitRuntimeAfter(ast.runtimeBody, level + 1);
}
this.emit('}\n', level);
}