Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/pgt_query_macros/src/iter_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ pub fn iter_mut_mod(analyser: ProtoAnalyzer) -> proc_macro2::TokenStream {

for node in &nodes {
// Use the enum variant name from the Node enum
if let Some(variant_name) = type_to_variant.get(&node.name) {
if let Some(variant_name) = type_to_variant.get(&node.enum_variant_name) {
let variant_ident = format_ident!("{}", variant_name);
node_variant_names.push(variant_ident);

let property_handlers = property_handlers(node);
node_property_handlers.push(property_handlers);
} else {
panic!(
"No enum variant found for node type: {}",
node.enum_variant_name
);
}
}

Expand Down
7 changes: 6 additions & 1 deletion crates/pgt_query_macros/src/iter_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ pub fn iter_ref_mod(analyser: ProtoAnalyzer) -> proc_macro2::TokenStream {
}

for node in &nodes {
if let Some(variant_name) = type_to_variant.get(&node.name) {
if let Some(variant_name) = type_to_variant.get(&node.enum_variant_name) {
let variant_ident = format_ident!("{}", variant_name);
node_variant_names.push(variant_ident);

let property_handlers = property_handlers(node);
node_property_handlers.push(quote! {
#(#property_handlers)*
});
} else {
panic!(
"No enum variant found for node type: {}",
node.enum_variant_name
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/pgt_query_macros/src/proto_analyser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub(crate) struct Field {
}

pub(crate) struct Node {
pub name: String,
#[allow(dead_code)]
pub name: String,
pub enum_variant_name: String,
pub fields: Vec<Field>,
}
Expand Down