def resolve(self) -> SchemaDefinition:
if not isinstance(self.schema.slots, dict):<EOL><INDENT>raise ValueError(f"<STR_LIT>")<EOL><DEDENT>if not isinstance(self.schema.classes, dict):<EOL><INDENT>raise ValueError(f"<STR_LIT>")<EOL><DEDENT>for sname in self.schema.imports:<EOL><INDENT>if sname not in self.loaded:<EOL><INDENT>self.loaded.add(sname)<EOL>merge_schemas(self.schema, load_raw_schema(sname + '<STR_LIT>', base_dir=self.base_dir))<EOL><DEDENT><DEDENT>for slot in self.schema.slots.values():<EOL><INDENT>if slot.domain in self.schema.classes and slot.name not in self.schema.classes[slot.domain].slots:<EOL><INDENT>self.schema.classes[slot.domain].slots.append(slot.name)<EOL><DEDENT><DEDENT>for cls in self.schema.classes.values():<EOL><INDENT>if not isinstance(cls, ClassDefinition):<EOL><INDENT>raise ValueError(<EOL>f'<STR_LIT>')<EOL><DEDENT>if isinstance(cls.slots, str):<EOL><INDENT>print(f"<STR_LIT>", file=sys.stderr)<EOL>cls.slots = [cls.slots]<EOL><DEDENT>for slotname in cls.slots:<EOL><INDENT>if slotname in self.schema.slots:<EOL><INDENT>if self.schema.slots[slotname].domain is None:<EOL><INDENT>self.schema.slots[slotname].domain = cls.name<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for cls in self.schema.classes.values():<EOL><INDENT>if cls.apply_to in self.schema.classes:<EOL><INDENT>self.schema.classes[cls.apply_to].mixins.append(cls.name)<EOL><DEDENT><DEDENT>for cls in self.schema.classes.values():<EOL><INDENT>for slot_name, slot_usage in cls.slot_usage.items():<EOL><INDENT>parent_slot = self.slot_definition_for(slot_name, cls)<EOL>if not parent_slot and slot_name in self.schema.slots:<EOL><INDENT>parent_slot = self.schema.slots[slot_name]<EOL><DEDENT>child_name = SlotDefinitionName(cls.name + '<STR_LIT:U+0020>' + slot_name) if parent_slot else slot_name<EOL>new_slot = SlotDefinition(name=child_name, alias=slot_name, domain=cls.name)<EOL>merge_slots(new_slot, slot_usage)<EOL>if parent_slot is not None:<EOL><INDENT>new_slot.is_a = parent_slot.name<EOL>merge_slots(new_slot, parent_slot)<EOL><DEDENT>merge_slots(new_slot, slot_usage)<EOL>self.schema.slots[child_name] = new_slot<EOL>append = True<EOL>for i, s in enumerate(cls.slots):<EOL><INDENT>if s == slot_name:<EOL><INDENT>cls.slots[i] = SlotDefinitionName(child_name)<EOL>append = False<EOL>break<EOL><DEDENT><DEDENT>if append:<EOL><INDENT>cls.slots.append(SlotDefinitionName(child_name))<EOL><DEDENT><DEDENT><DEDENT>merged_slots: List[SlotDefinition] = []<EOL>for slot in self.schema.slots.values():<EOL><INDENT>self.merge_slot(slot, merged_slots)<EOL><DEDENT>for slot in self.schema.slots.values():<EOL><INDENT>if not slot.range:<EOL><INDENT>slot.range = '<STR_LIT:string>'<EOL><DEDENT><DEDENT>return self.schema<EOL>
Return a fully resolved schema