async function parse_thrift_root(thrift_file_objs) {
let results = thrift_root(),
name_map = new Map(),
includes = [];
for (let i=0; i<thrift_file_objs.length; i++) {
let obj = thrift_file_objs[i];
const fcode = await obj.text;
try {
obj.thrift = eleme_parser(fcode);
obj.children = [];
name_map.set(obj.name, obj);
console.log("Mapping obj to " + obj.name);
if (obj.thrift.include == null) {
results.no_includes.children.push(obj);
} else {
includes.push(obj);
}
} catch (error) {
obj.thrift = "error";
results.errors.children.push(obj);
}
}
includes.forEach((obj, index) => {
const kid = obj.thrift.include;
const kids = Object.keys(kid);
console.log(kid);
console.log(kids);
kids.forEach((parent_key, pindex) => {
console.log("Searching for parent " + kid[parent_key].path);
let pobj = name_map.get(kid[parent_key].path);
pobj && pobj.children.push(obj);
});
});
return results;
}