Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private processAST(ast: any) {
switch(ast.type) {
case AST_NODE_TYPES.ClassDeclaration:
this.processClassDeclaration(ast as ClassDeclaration);
break;
case AST_NODE_TYPES.TSEnumDeclaration:
this.processTSEnumDeclaration(ast as TSEnumDeclaration);
break;
case AST_NODE_TYPES.ExportNamedDeclaration:
this.processExportNamedDeclaration(ast as ExportNamedDeclaration);
break;
case AST_NODE_TYPES.TSModuleBlock:
this.processTSModuleBlock(ast as TSModuleBlock);
break;
case AST_NODE_TYPES.TSModuleDeclaration:
this.processTSModuleDeclaration(ast as TSModuleDeclaration);
break;
default:
break;
private processClassDeclaration(ast: ClassDeclaration) {
let info: TsClassInfo = { type: AST_NODE_TYPES.ClassDeclaration, name: ast.id.name, properties: {}, funcs: {} };
for(let cbb of ast.body.body) {
if(cbb.type == AST_NODE_TYPES.ClassProperty) {
let cp = cbb as ClassProperty;
let cpInfo: TsPropInfo = { type: AST_NODE_TYPES.ClassProperty, name: (cp.key as Identifier).name, isStatic: cp.static, varType: cp.typeAnnotation };
info.properties[cpInfo.name] = cpInfo;
} else if(cbb.type == AST_NODE_TYPES.MethodDefinition) {
let md = cbb as MethodDefinition;
let mdInfo: TsFuncInfo = { type: AST_NODE_TYPES.MethodDefinition, name: (md.key as Identifier).name, isStatic: md.static, returnType: md.value.returnType };
info.funcs[mdInfo.name] = mdInfo;
}
}
this.classMap[ast.id.name] = info;
if(this.moduleName) {
this.classMap[this.moduleName + '.' + ast.id.name] = info;
this.moduleMap[this.moduleName].classes[ast.id.name] = info;
}