use draxl_ast::{
CommentNode, DocNode, Expr, Field, Item, MatchArm, NodeId, Param, Pattern, Rank, SlotName,
Stmt, Type, Variant,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SlotOwner {
File,
Node(NodeId),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SlotRef {
pub owner: SlotOwner,
pub slot: SlotName,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RankedDest {
pub slot: SlotRef,
pub rank: Rank,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PatchDest {
Ranked(RankedDest),
Slot(SlotRef),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PatchNode {
Item(Item),
Field(Field),
Variant(Variant),
Param(Param),
Stmt(Stmt),
MatchArm(MatchArm),
Expr(Expr),
Type(Type),
Pattern(Pattern),
Doc(DocNode),
Comment(CommentNode),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PatchPath {
pub node_id: NodeId,
pub segments: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PatchValue {
Ident(String),
Str(String),
Int(i64),
Bool(bool),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PatchOp {
Insert {
dest: RankedDest,
node: PatchNode,
},
Put {
slot: SlotRef,
node: PatchNode,
},
Replace {
target_id: NodeId,
replacement: PatchNode,
},
Delete {
target_id: NodeId,
},
Move {
target_id: NodeId,
dest: PatchDest,
},
Set {
path: PatchPath,
value: PatchValue,
},
Clear {
path: PatchPath,
},
Attach {
node_id: NodeId,
target_id: NodeId,
},
Detach {
node_id: NodeId,
},
}