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_LAST(self, *kids): self.val = qlast.Position(position='LAST')
def reduce_FIRST(self, *kids): self.val = qlast.Position(position='FIRST')
def reduce_AFTER_NodeName(self, *kids): self.val = qlast.Position(ref=kids[1].val, position='AFTER')
def reduce_BEFORE_NodeName(self, *kids): self.val = qlast.Position(ref=kids[1].val, position='BEFORE')