in lib/generator.js [1544:1600]
visitConstructModel(ast, level, env) {
assert.equal(ast.type, 'construct_model');
if (ast.aliasId.isModule) {
let aliasId = ast.aliasId.lexeme;
const { namespace } = this.moduleClass.get(aliasId);
this.emit('new ');
let tempName = '';
let type = 'Models';
const moduleModelName = ast.propertyPath.map((item) => {
return item.lexeme;
}).join('.');
var usedEx;
if (this.usedExternException) {
usedEx = this.usedExternException.get(aliasId);
}
if (usedEx && usedEx.has(moduleModelName)) {
type = 'Exceptions';
}
for (let i = 0; i < ast.propertyPath.length; i++) {
const item = ast.propertyPath[i];
if (i > 0) {
this.emit('.');
}
// Request.RequestSubmodel,先判断Request是否冲突
if (i === 0) {
tempName += _upperFirst(item.lexeme);
const realModelName = this.getRealModelName(`${namespace}.${type}`, tempName, type);
this.emit(realModelName);
} else {
tempName += _upperFirst(item.lexeme);
this.emit(tempName);
}
}
} else if (ast.aliasId.isModel) {
let mainModelName = ast.aliasId;
let type = 'Models';
this.emit('new ');
const modelName = [mainModelName, ...ast.propertyPath].map((item) => {
return item.lexeme;
}).join('.');
if (_isBuiltinModel(modelName)) {
const namespace = this.getType(modelName);
const subModelName = this.getRealModelName(namespace, this._type(modelName));
this.emit(subModelName);
} else {
if (this.predefined[modelName] && this.predefined[modelName].isException) {
type = 'Exceptions';
}
const subModelName = this.getRealModelName(`${this.namespace}.${type}`, modelName, type);
this.emit(subModelName);
}
} else {
this.emit(`new ${_name(ast.aliasId)}`);
}
this.visitConstructObject(ast.object, level, env);
}