def rename_class(self, target: Class): """Find the next available class identifier, save the original name in the class metadata and update the class qualified name and all classes that depend on the target class.""" qname = target.qname namespace, name = split_qname(target.qname) target.qname = self.next_qname(namespace, name) target.meta_name = name self.container.reset(target, qname) for item in self.container.iterate(): self.rename_class_dependencies(item, qname, target.qname)
def promote_inner_class(self, parent: Class, inner: Class): """ Convert inner class to root class. Steps: 1. Remove inner class from parent 2. Prepend parent name to inner class name. 3. Search and replace all matching attribute types. 4. Add inner class to the global class index. """ name = f"{parent.name}_{inner.name}" parent.inner.remove(inner) for attr in parent.attrs: for attr_type in attr.types: if attr_type.name == inner.name: attr_type.forward = False attr_type.qname = QName(inner.qname.namespace, name) inner.qname = QName(inner.qname.namespace, name) self.container.add(inner)