Skip to content

Commit

Permalink
Allow type_expander to ignore dict type alias names
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Feb 6, 2024
1 parent 2ea5ef2 commit 6416283
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/ttype/type_expander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct TypeExpansionOptions<'a> {
pub expand_generic: bool,
pub expand_templates: bool,
pub expand_hakana_types: bool,
pub expand_all_type_aliases: bool,
}

impl Default for TypeExpansionOptions<'_> {
Expand All @@ -58,6 +59,7 @@ impl Default for TypeExpansionOptions<'_> {
expand_generic: false,
expand_templates: true,
expand_hakana_types: true,
expand_all_type_aliases: false,
}
}
}
Expand Down Expand Up @@ -127,6 +129,7 @@ fn expand_atomic(
if let TAtomic::TDict {
ref mut known_items,
ref mut params,
ref mut shape_name,
..
} = return_type_part
{
Expand All @@ -146,6 +149,10 @@ fn expand_atomic(
);
}
}

if options.expand_all_type_aliases {
*shape_name = None;
}
} else if let TAtomic::TVec {
ref mut known_items,
ref mut type_param,
Expand Down Expand Up @@ -307,7 +314,7 @@ fn expand_atomic(
if let Some(expanding_file_path) = options.file_path {
expanding_file_path == type_file_path
} else {
false
options.expand_all_type_aliases
}
} else {
true
Expand Down Expand Up @@ -409,7 +416,10 @@ fn expand_atomic(

data_flow_graph.add_node(shape_node);
}
*shape_name = Some((*type_name, None));

if !options.expand_all_type_aliases {
*shape_name = Some((*type_name, None));
}
};
}
v
Expand Down

0 comments on commit 6416283

Please sign in to comment.