in lib/generator.js [489:564]
visitType(ast, isSubType = false) {
if (ast.type === 'map') {
this.emit(`java.util.Map<`);
this.visitType(ast.keyType, true);
this.emit(`, `);
this.visitType(ast.valueType, true);
this.emit(`>`);
} else if (ast.type === 'array') {
this.emit(`java.util.List<`);
this.visitType(ast.subType || ast.itemType, true);
this.emit(`>`);
} else if (ast.type === 'model') {
if (ast.moduleName) {
this.emit(`${this.imports[ast.moduleName].package}.models.`);
} else {
const modelMap = `${_name(ast)}`;
if (this.conflictModels.get(modelMap)) {
this.emit(`${this.package}.models.`);
}
}
this.emit(`${_type(this.getSubFieldClassName(ast.name, true))}`);
} else if (ast.type === 'subModel') {
let className = '';
for (let i = 0; i < ast.path.length; i++) {
const item = ast.path[i];
if (i > 0) {
className += '.';
}
className += item.lexeme;
}
let resultName = this.getSubModelClassName(className.split('.'), 0, '');
this.emit(resultName);
} else if (ast.type === 'moduleModel') {
const [moduleId, ...rest] = ast.path;
let pathName = rest.map((item) => {
return item.lexeme;
}).join('.');
let subModelName = '';
if (rest.length > 1) {
subModelName = `.${_subModelName(pathName, this.conflictModelNameMap, this.allModleNameMap, this.enableMinimizeModelName)}`;
}
var modelName = rest[0].lexeme;
var moduleName = moduleId.lexeme;
var packageName = `${this.imports[moduleName].package}.models.`;
this.emit(packageName + modelName + subModelName);
} else if (ast.idType === 'typedef') {
this.emit(this.typeRelover(ast));
} else if (ast.type === 'moduleTypedef') {
for (let i = 1; i < ast.path.length; i++) {
this.emit(this.typeRelover(ast.path[i], ast.path[0]));
}
} else if (ast.type === 'basic') {
this.emit(_type(ast.name));
} else if (this.predefined && this.predefined[`module:${_name(ast)}`]) {
var className = this.imports[ast.lexeme].className || 'Client';
this.emit(`${this.imports[_name(ast)]}.${className}`);
} else if (ast.idType === 'module') {
let className = this.imports[ast.lexeme].className || 'Client';
this.emit(`${this.imports[ast.lexeme].package}.${className}`);
} else if (ast.idType === 'model') {
const modelMap = `${_name(ast)}`;
if (this.conflictModels.get(modelMap)) {
this.emit(`${this.package}.models.`);
}
this.emit(modelMap);
} else if (ast.type === 'module_instance') {
let className = this.imports[_name(ast)].className || 'Client';
this.emit(`${this.imports[_name(ast)].package}.${className}`);
} else {
if (isSubType) {
this.emit(collectionType(_type(ast.lexeme || ast.name)));
} else {
this.emit(_type(ast.lexeme || ast.name));
}
}
}