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
3 changes: 3 additions & 0 deletions tasks/ast_tools/src/derives/estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ fn parse_estree_attr(location: AttrLocation, part: AttrPart) -> Result<()> {
AttrLocation::StructField(struct_def, field_index) => match part {
AttrPart::Tag("skip") => struct_def.fields[field_index].estree.skip = true,
AttrPart::Tag("flatten") => struct_def.fields[field_index].estree.flatten = true,
AttrPart::Tag("no_flatten") => struct_def.fields[field_index].estree.no_flatten = true,
AttrPart::Tag("json_safe") => struct_def.fields[field_index].estree.json_safe = true,
AttrPart::String("rename", value) => {
struct_def.fields[field_index].estree.rename = Some(value);
Expand Down Expand Up @@ -488,6 +489,8 @@ pub fn should_skip_field(field: &FieldDef, schema: &Schema) -> bool {
pub fn should_flatten_field(field: &FieldDef, schema: &Schema) -> bool {
if field.estree.flatten {
true
} else if field.estree.no_flatten {
false
} else {
let field_type = field.type_def(schema);
matches!(field_type, TypeDef::Struct(field_struct_def) if field_struct_def.estree.flatten)
Expand Down
1 change: 1 addition & 0 deletions tasks/ast_tools/src/schema/extensions/estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct ESTreeStructField {
pub append_field_index: Option<usize>,
pub skip: bool,
pub flatten: bool,
pub no_flatten: bool,
// `true` for fields containing a `&str` or `Atom` which does not need escaping in JSON
pub json_safe: bool,
pub is_ts: bool,
Expand Down
Loading