refactor(semantic): rename vars from flag to flags (#5031)

Part of #4991.
This commit is contained in:
overlookmotel 2024-08-21 00:19:59 +00:00
parent 5f4c9ab38e
commit 83dfb1484e
2 changed files with 5 additions and 5 deletions

View file

@ -345,7 +345,7 @@ impl<'a> SemanticBuilder<'a> {
self.current_scope_flags().is_strict_mode() self.current_scope_flags().is_strict_mode()
} }
pub(crate) fn set_function_node_flag(&mut self, flags: NodeFlags) { pub(crate) fn set_function_node_flags(&mut self, flags: NodeFlags) {
if let Some(current_function) = self.function_stack.last() { if let Some(current_function) = self.function_stack.last() {
*self.nodes.get_node_mut(*current_function).flags_mut() |= flags; *self.nodes.get_node_mut(*current_function).flags_mut() |= flags;
} }
@ -1917,7 +1917,7 @@ impl<'a> SemanticBuilder<'a> {
} }
} }
AstKind::YieldExpression(_) => { AstKind::YieldExpression(_) => {
self.set_function_node_flag(NodeFlags::HasYield); self.set_function_node_flags(NodeFlags::HasYield);
} }
_ => {} _ => {}
} }

View file

@ -401,7 +401,7 @@ mod tests {
(typescript, "let a: number; (a as any) = 1;", ReferenceFlags::write()), (typescript, "let a: number; (a as any) = 1;", ReferenceFlags::write()),
]; ];
for (source_type, source, flag) in sources { for (source_type, source, flags) in sources {
let semantic = get_semantic(&alloc, source, source_type); let semantic = get_semantic(&alloc, source, source_type);
let a_id = let a_id =
semantic.scopes().get_root_binding(&target_symbol_name).unwrap_or_else(|| { semantic.scopes().get_root_binding(&target_symbol_name).unwrap_or_else(|| {
@ -415,7 +415,7 @@ mod tests {
"expected to find 1 reference to '{target_symbol_name}' but {num_refs} were found\n\nsource:\n{source}" "expected to find 1 reference to '{target_symbol_name}' but {num_refs} were found\n\nsource:\n{source}"
); );
let ref_type = a_refs[0]; let ref_type = a_refs[0];
if flag.is_write() { if flags.is_write() {
assert!( assert!(
ref_type.is_write(), ref_type.is_write(),
"expected reference to '{target_symbol_name}' to be write\n\nsource:\n{source}" "expected reference to '{target_symbol_name}' to be write\n\nsource:\n{source}"
@ -426,7 +426,7 @@ mod tests {
"expected reference to '{target_symbol_name}' not to have been written to, but it is\n\nsource:\n{source}" "expected reference to '{target_symbol_name}' not to have been written to, but it is\n\nsource:\n{source}"
); );
} }
if flag.is_read() { if flags.is_read() {
assert!( assert!(
ref_type.is_read(), ref_type.is_read(),
"expected reference to '{target_symbol_name}' to be read\n\nsource:\n{source}" "expected reference to '{target_symbol_name}' to be read\n\nsource:\n{source}"