def _apply_rebase_ast(self, context, node, op): from . import inheriting parent_ctx = context.get(sd.CommandContextToken) parent_op = parent_ctx.op rebase = next( iter(parent_op.get_subcommands(type=inheriting.RebaseNamedObject))) dropped = rebase.removed_bases added = rebase.added_bases if dropped: node.commands.append( qlast.AlterDropInherit(bases=[ qlast.ObjectRef(module=b.classname.module, name=b.classname.name) for b in dropped ])) for bases, pos in added: if isinstance(pos, tuple): pos_node = qlast.Position(position=pos[0], ref=qlast.ObjectRef( module=pos[1].classname.module, name=pos[1].classname.name)) else: pos_node = qlast.Position(position=pos) node.commands.append( qlast.AlterAddInherit(bases=[ qlast.ObjectRef(module=b.classname.module, name=b.classname.name) for b in bases ], position=pos_node))
def reduce_DROP_EXTENDING_SimpleTypeNameList(self, *kids): self.val = qlast.AlterDropInherit(bases=kids[2].val)