def parsePackage(self,child,lastNode,isPrivate): element = Extract.getPackage(child,self.prefixClass,lastNode) element['has_childs'] = False element['public'] = [] element['private'] = [] if child.find('visible_part_declarative_items_ql') is not None: self.parseRecursive(child.find('visible_part_declarative_items_ql'),element['public'],child,isPrivate) if child.find('private_part_declarative_items_ql') is not None: self.parseRecursive(child.find('private_part_declarative_items_ql'),element['private'],child,True) return element
def parseRecursive(self,node,elements,parent=None,isPrivate=False): lastNode = None i = 0 for child in node: element = None has_body_declarative_items_ql = False if child.tag in ['procedure_body_declaration','function_body_declaration']: element = Extract.getFunction(child,lastNode,self.sourcefile) elif child.tag in ['function_declaration','generic_function_declaration','procedure_declaration','generic_procedure_declaration','single_task_declaration','task_type_declaration','protected_type_declaration','single_protected_declaration']: element = Extract.getFunctionHead(child,lastNode,self.sourcefile,self.extractPriv) elif child.tag in ['ordinary_type_declaration','subtype_declaration','private_type_declaration']: element = self.parseType(child,lastNode,isPrivate,node) elif child.tag in ['component_declaration']: element = Extract.getRecordComponent(child,self.sourcefile) elif child.tag == 'package_body_declaration': element = Extract.getPackage(child,self.prefixClass,lastNode) elif child.tag in ['generic_package_declaration','package_declaration']: element = self.parsePackage(child,lastNode,isPrivate) elif child.tag == 'package_renaming_declaration': element = Extract.getRename(child) elif child.tag in ['attribute_definition_clause','record_representation_clause','enumeration_representation_clause'] and self.hideRepClause is False: element = Extract.getRepClause(child,self.prefixRepClause,self.sourcefile) elif child.tag in ['import_pragma']: self.imports.append(Extract.getImport(child,self.sourcefile)) elif child.tag not in ['implementation_defined_pragma']: logging.info("Not parsed: "+child.tag) if element is not None: if parent is None: c = Extract.getUnitComment(self.root) else: c = Extract.getComment(node,i) element['comment'] = c element['is_private'] = isPrivate element['is_extract'] = c != '' or self.extractAll or parent == None if 'uri' in element: self.elementsByUris[element['uri']] = element elements.append(element) if element['has_childs'] and child.find('body_declarative_items_ql') is not None: isPrivateSubLevel = isPrivate if element['type'] == 'function': isPrivateSubLevel = True self.parseRecursive(child.find('body_declarative_items_ql'),element['childs'],child,isPrivateSubLevel) i+=1 lastNode = child