diff --git a/crates/oxc_cfg/src/builder/mod.rs b/crates/oxc_cfg/src/builder/mod.rs index b15789c2e1ffb..2edc48da38223 100644 --- a/crates/oxc_cfg/src/builder/mod.rs +++ b/crates/oxc_cfg/src/builder/mod.rs @@ -2,7 +2,7 @@ mod context; use context::Ctx; pub use context::{CtxCursor, CtxFlags}; -use oxc_syntax::node::AstNodeId; +use oxc_syntax::node::NodeId; use petgraph::Direction; use super::{ @@ -107,11 +107,11 @@ impl<'a> ControlFlowGraphBuilder<'a> { self.graph.add_edge(a, b, weight); } - pub fn push_statement(&mut self, stmt: AstNodeId) { + pub fn push_statement(&mut self, stmt: NodeId) { self.push_instruction(InstructionKind::Statement, Some(stmt)); } - pub fn push_return(&mut self, kind: ReturnInstructionKind, node: AstNodeId) { + pub fn push_return(&mut self, kind: ReturnInstructionKind, node: NodeId) { self.push_instruction(InstructionKind::Return(kind), Some(node)); } @@ -166,20 +166,20 @@ impl<'a> ControlFlowGraphBuilder<'a> { ); } - pub fn append_condition_to(&mut self, block: BasicBlockId, node: Option) { + pub fn append_condition_to(&mut self, block: BasicBlockId, node: Option) { self.push_instruction_to(block, InstructionKind::Condition, node); } - pub fn append_iteration(&mut self, node: Option, kind: IterationInstructionKind) { + pub fn append_iteration(&mut self, node: Option, kind: IterationInstructionKind) { self.push_instruction(InstructionKind::Iteration(kind), node); } - pub fn append_throw(&mut self, node: AstNodeId) { + pub fn append_throw(&mut self, node: NodeId) { self.push_instruction(InstructionKind::Throw, Some(node)); self.append_unreachable(); } - pub fn append_break(&mut self, node: AstNodeId, label: Option<&'a str>) { + pub fn append_break(&mut self, node: NodeId, label: Option<&'a str>) { let kind = match label { Some(_) => LabeledInstruction::Labeled, None => LabeledInstruction::Unlabeled, @@ -193,7 +193,7 @@ impl<'a> ControlFlowGraphBuilder<'a> { self.ctx(label).r#break(bb); } - pub fn append_continue(&mut self, node: AstNodeId, label: Option<&'a str>) { + pub fn append_continue(&mut self, node: NodeId, label: Option<&'a str>) { let kind = match label { Some(_) => LabeledInstruction::Labeled, None => LabeledInstruction::Unlabeled, @@ -221,7 +221,7 @@ impl<'a> ControlFlowGraphBuilder<'a> { /// # Panics #[inline] - pub(self) fn push_instruction(&mut self, kind: InstructionKind, node_id: Option) { + pub(self) fn push_instruction(&mut self, kind: InstructionKind, node_id: Option) { self.push_instruction_to(self.current_node_ix, kind, node_id); } @@ -230,12 +230,12 @@ impl<'a> ControlFlowGraphBuilder<'a> { &mut self, block: BasicBlockId, kind: InstructionKind, - node_id: Option, + node_id: Option, ) { self.basic_block_mut(block).instructions.push(Instruction { kind, node_id }); } - pub fn enter_statement(&mut self, stmt: AstNodeId) { + pub fn enter_statement(&mut self, stmt: NodeId) { self.push_statement(stmt); } } diff --git a/crates/oxc_cfg/src/lib.rs b/crates/oxc_cfg/src/lib.rs index af393df6c6e92..2e126aa444e55 100644 --- a/crates/oxc_cfg/src/lib.rs +++ b/crates/oxc_cfg/src/lib.rs @@ -3,7 +3,7 @@ mod dot; pub mod visit; use itertools::Itertools; -use oxc_syntax::node::AstNodeId; +use oxc_syntax::node::NodeId; use petgraph::{ stable_graph::NodeIndex, visit::{Control, DfsEvent, EdgeRef}, @@ -44,11 +44,11 @@ impl BasicBlock { #[derive(Debug, Clone)] pub struct Instruction { pub kind: InstructionKind, - pub node_id: Option, + pub node_id: Option, } impl Instruction { - pub fn new(kind: InstructionKind, node_id: Option) -> Self { + pub fn new(kind: InstructionKind, node_id: Option) -> Self { Self { kind, node_id } } } diff --git a/crates/oxc_cfg/tests/builder.rs b/crates/oxc_cfg/tests/builder.rs index 5308e4034d035..98f0da4e7419c 100644 --- a/crates/oxc_cfg/tests/builder.rs +++ b/crates/oxc_cfg/tests/builder.rs @@ -1,5 +1,5 @@ use oxc_cfg::{ControlFlowGraphBuilder, CtxCursor}; -use oxc_syntax::node::AstNodeId; +use oxc_syntax::node::NodeId; /// same as but just the skeleton /// ```js /// A: { @@ -29,7 +29,7 @@ fn labeled_statement_with_multiple_loops_continue_and_break() { cfg.ctx(None).default().allow_break().allow_continue(); cfg.ctx(None).mark_break(c2).mark_continue(c2).resolve_with_upper_label(); - cfg.append_break(AstNodeId::DUMMY, A); + cfg.append_break(NodeId::DUMMY, A); // labeled block end cfg.ctx(A).mark_break(labeled).resolve(); diff --git a/crates/oxc_linter/src/ast_util.rs b/crates/oxc_linter/src/ast_util.rs index 2faf06477c9f9..ad8b2f063aa6d 100644 --- a/crates/oxc_linter/src/ast_util.rs +++ b/crates/oxc_linter/src/ast_util.rs @@ -1,5 +1,5 @@ use oxc_ast::{ast::BindingIdentifier, AstKind}; -use oxc_semantic::{AstNode, AstNodeId, IsGlobalReference, SymbolId}; +use oxc_semantic::{AstNode, IsGlobalReference, NodeId, SymbolId}; use oxc_span::{GetSpan, Span}; use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator}; @@ -246,7 +246,7 @@ pub fn nth_outermost_paren_parent<'a, 'b>( /// [`Expression::get_inner_expression`]. pub fn iter_outer_expressions<'a, 'ctx>( ctx: &'ctx LintContext<'a>, - node_id: AstNodeId, + node_id: NodeId, ) -> impl Iterator> + 'ctx { ctx.nodes().iter_parents(node_id).skip(1).filter(|parent| { !matches!( diff --git a/crates/oxc_linter/src/rules/eslint/func_names.rs b/crates/oxc_linter/src/rules/eslint/func_names.rs index 4b3607a59c8b3..07593de4356d3 100644 --- a/crates/oxc_linter/src/rules/eslint/func_names.rs +++ b/crates/oxc_linter/src/rules/eslint/func_names.rs @@ -9,7 +9,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::{Atom, GetSpan, Span}; use oxc_syntax::identifier::is_identifier_name; use phf::phf_set; @@ -479,7 +479,7 @@ impl Rule for FuncNames { } } -fn guess_function_name<'a>(ctx: &LintContext<'a>, parent_id: AstNodeId) -> Option> { +fn guess_function_name<'a>(ctx: &LintContext<'a>, parent_id: NodeId) -> Option> { for parent_kind in ctx.nodes().iter_parents(parent_id).map(AstNode::kind) { match parent_kind { AstKind::ParenthesizedExpression(_) diff --git a/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs b/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs index 7666518ed65e8..468778b1ac7f3 100644 --- a/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs +++ b/crates/oxc_linter/src/rules/eslint/no_constructor_return.rs @@ -4,7 +4,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -65,7 +65,7 @@ fn is_constructor(node: &AstNode<'_>) -> bool { ) } -fn is_definitely_in_constructor(ctx: &LintContext, node_id: AstNodeId) -> bool { +fn is_definitely_in_constructor(ctx: &LintContext, node_id: NodeId) -> bool { ctx.nodes() .ancestors(node_id) .map(|id| ctx.nodes().get_node(id)) diff --git a/crates/oxc_linter/src/rules/eslint/no_import_assign.rs b/crates/oxc_linter/src/rules/eslint/no_import_assign.rs index c9a4d2bb9601b..b3964fb277711 100644 --- a/crates/oxc_linter/src/rules/eslint/no_import_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_import_assign.rs @@ -1,7 +1,7 @@ use oxc_ast::{ast::Expression, AstKind}; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::{AstNodeId, SymbolId}; +use oxc_semantic::{NodeId, SymbolId}; use oxc_span::{GetSpan, Span}; use oxc_syntax::operator::UnaryOperator; use phf::phf_set; @@ -106,7 +106,7 @@ impl Rule for NoImportAssign { /// - `Reflect.deleteProperty` /// - `Reflect.set` /// - `Reflect.setPrototypeOf` -fn is_argument_of_well_known_mutation_function(node_id: AstNodeId, ctx: &LintContext<'_>) -> bool { +fn is_argument_of_well_known_mutation_function(node_id: NodeId, ctx: &LintContext<'_>) -> bool { let current_node = ctx.nodes().get_node(node_id); let call_expression_node = ctx.nodes().parent_node(node_id).and_then(|node| ctx.nodes().parent_kind(node.id())); diff --git a/crates/oxc_linter/src/rules/eslint/no_multi_str.rs b/crates/oxc_linter/src/rules/eslint/no_multi_str.rs index 62121a497edf7..d022ab67d7411 100644 --- a/crates/oxc_linter/src/rules/eslint/no_multi_str.rs +++ b/crates/oxc_linter/src/rules/eslint/no_multi_str.rs @@ -1,7 +1,7 @@ use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -52,7 +52,7 @@ impl Rule for NoMultiStr { } } -fn is_within_jsx_attribute_item(id: AstNodeId, ctx: &LintContext) -> bool { +fn is_within_jsx_attribute_item(id: NodeId, ctx: &LintContext) -> bool { if matches!(ctx.nodes().parent_kind(id), Some(AstKind::JSXAttributeItem(_))) { return true; } diff --git a/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs b/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs index 019328a864204..19d392d8936fb 100644 --- a/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs +++ b/crates/oxc_linter/src/rules/eslint/no_this_before_super.rs @@ -10,7 +10,7 @@ use oxc_cfg::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -62,7 +62,7 @@ impl Rule for NoThisBeforeSuper { // first pass -> find super calls and local violations let mut wanted_nodes = Vec::new(); let mut basic_blocks_with_super_called = HashSet::::new(); - let mut basic_blocks_with_local_violations = HashMap::>::new(); + let mut basic_blocks_with_local_violations = HashMap::>::new(); for node in semantic.nodes().iter() { match node.kind() { AstKind::Function(_) | AstKind::ArrowFunctionExpression(_) => { @@ -153,7 +153,7 @@ impl NoThisBeforeSuper { cfg: &ControlFlowGraph, id: BasicBlockId, basic_blocks_with_super_called: &HashSet, - basic_blocks_with_local_violations: &HashMap>, + basic_blocks_with_local_violations: &HashMap>, follow_join: bool, ) -> Vec { neighbors_filtered_by_edge_weight( @@ -212,7 +212,7 @@ impl NoThisBeforeSuper { cfg: &ControlFlowGraph, output: Vec, basic_blocks_with_super_called: &HashSet, - basic_blocks_with_local_violations: &HashMap>, + basic_blocks_with_local_violations: &HashMap>, ) -> bool { // Deciding whether we definitely call this before super in all // codepaths is as simple as seeing if any individual codepath diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs b/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs index 8137c16f1a935..c41a3219a9fd0 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_private_class_members.rs @@ -2,7 +2,7 @@ use itertools::Itertools; use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::{AstNode, AstNodeId, AstNodes}; +use oxc_semantic::{AstNode, AstNodes, NodeId}; use oxc_span::Span; use oxc_syntax::class::ElementKind; @@ -114,7 +114,7 @@ impl Rule for NoUnusedPrivateClassMembers { } } -fn is_read(current_node_id: AstNodeId, nodes: &AstNodes) -> bool { +fn is_read(current_node_id: NodeId, nodes: &AstNodes) -> bool { for (curr, parent) in nodes .iter_parents(nodes.parent_id(current_node_id).unwrap_or(current_node_id)) .tuple_windows::<(&AstNode<'_>, &AstNode<'_>)>() diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs index 3a9cc1cb34f1b..0461804773082 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs @@ -2,7 +2,7 @@ //! consider variables ignored by name pattern, but by where they are declared. #[allow(clippy::wildcard_imports)] use oxc_ast::{ast::*, AstKind}; -use oxc_semantic::{AstNode, AstNodeId, Semantic}; +use oxc_semantic::{AstNode, NodeId, Semantic}; use oxc_span::GetSpan; use super::{options::ArgsOption, NoUnusedVars, Symbol}; @@ -154,7 +154,7 @@ impl NoUnusedVars { pub(super) fn is_allowed_type_parameter( &self, symbol: &Symbol<'_, '_>, - declaration_id: AstNodeId, + declaration_id: NodeId, ) -> bool { matches!(symbol.nodes().parent_kind(declaration_id), Some(AstKind::TSMappedType(_))) } @@ -234,7 +234,7 @@ impl NoUnusedVars { .any(|p| p.has_modifier() || p.pattern.has_any_used_binding(ctx)) } - /// `params_id` is the [`AstNodeId`] to a [`AstKind::FormalParameters`] node. + /// `params_id` is the [`NodeId`] to a [`AstKind::FormalParameters`] node. /// /// The following allowed conditions are handled: /// 1. setter parameters - removing them causes a syntax error. @@ -242,7 +242,7 @@ impl NoUnusedVars { fn is_allowed_param_because_of_method<'a>( semantic: &Semantic<'a>, param: &FormalParameter<'a>, - params_id: AstNodeId, + params_id: NodeId, ) -> bool { let mut parents_iter = semantic.nodes().iter_parents(params_id).skip(1).map(AstNode::kind); diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/fixers/fix_vars.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/fixers/fix_vars.rs index dbe187f3c79b0..95f37d2a62c59 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/fixers/fix_vars.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/fixers/fix_vars.rs @@ -2,7 +2,7 @@ use oxc_ast::{ ast::{Expression, VariableDeclarator}, AstKind, }; -use oxc_semantic::{AstNode, AstNodeId}; +use oxc_semantic::{AstNode, NodeId}; use oxc_span::CompactStr; use regex::Regex; @@ -28,7 +28,7 @@ impl NoUnusedVars { fixer: RuleFixer<'_, 'a>, symbol: &Symbol<'_, 'a>, decl: &VariableDeclarator<'a>, - decl_id: AstNodeId, + decl_id: NodeId, ) -> RuleFix<'a> { if decl.init.as_ref().is_some_and(|init| is_skipped_init(symbol, init)) { return fixer.noop(); diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs index 12594f8692fa8..ce4eac741f2d2 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs @@ -8,7 +8,7 @@ use oxc_ast::{ AstKind, }; use oxc_semantic::{ - AstNode, AstNodeId, AstNodes, Reference, ScopeId, ScopeTree, Semantic, SymbolFlags, SymbolId, + AstNode, AstNodes, NodeId, Reference, ScopeId, ScopeTree, Semantic, SymbolFlags, SymbolId, SymbolTable, }; use oxc_span::{GetSpan, Span}; @@ -77,7 +77,7 @@ impl<'s, 'a> Symbol<'s, 'a> { } #[inline] - fn declaration_id(&self) -> AstNodeId { + fn declaration_id(&self) -> NodeId { self.symbols().get_declaration(self.id) } @@ -107,14 +107,14 @@ impl<'s, 'a> Symbol<'s, 'a> { pub fn iter_relevant_parents( &self, - node_id: AstNodeId, + node_id: NodeId, ) -> impl Iterator> + Clone + '_ { self.nodes().iter_parents(node_id).skip(1).filter(|n| Self::is_relevant_kind(n.kind())) } pub fn iter_relevant_parent_and_grandparent_kinds( &self, - node_id: AstNodeId, + node_id: NodeId, ) -> impl Iterator, /* grandparent */ AstKind<'a>)> + Clone + '_ { let parents_iter = self diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs index 61b08ef0d0b30..c1f81dadd1bd5 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs @@ -3,7 +3,7 @@ #[allow(clippy::wildcard_imports)] use oxc_ast::{ast::*, AstKind}; -use oxc_semantic::{AstNode, AstNodeId, Reference, ScopeId, SymbolFlags, SymbolId}; +use oxc_semantic::{AstNode, NodeId, Reference, ScopeId, SymbolFlags, SymbolId}; use oxc_span::{GetSpan, Span}; use super::{ignored::FoundStatus, NoUnusedVars, Symbol}; @@ -427,7 +427,7 @@ impl<'s, 'a> Symbol<'s, 'a> { } /// Check if a [`AstNode`] is within a return statement or implicit return. - fn is_in_return_statement(&self, node_id: AstNodeId) -> bool { + fn is_in_return_statement(&self, node_id: NodeId) -> bool { for parent in self.iter_relevant_parents(node_id).map(AstNode::kind) { match parent { AstKind::ReturnStatement(_) => return true, @@ -660,7 +660,7 @@ impl<'s, 'a> Symbol<'s, 'a> { /// Find the [`SymbolId`] for the nearest function declaration or expression /// that is a parent of `node_id`. - fn get_nearest_function(&self, node_id: AstNodeId) -> Option { + fn get_nearest_function(&self, node_id: NodeId) -> Option { // set to `true` when we find an arrow function and we want to get its // name from the variable its assigned to. let mut needs_variable_identifier = false; diff --git a/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs b/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs index 17172945f93f0..afcb56e16c071 100644 --- a/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs +++ b/crates/oxc_linter/src/rules/eslint/no_useless_escape.rs @@ -2,7 +2,7 @@ use memchr::memmem; use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -103,7 +103,7 @@ impl Rule for NoUselessEscape { } } -fn is_within_jsx_attribute_item(id: AstNodeId, ctx: &LintContext) -> bool { +fn is_within_jsx_attribute_item(id: NodeId, ctx: &LintContext) -> bool { if matches!(ctx.nodes().parent_kind(id), Some(AstKind::JSXAttributeItem(_))) { return true; } @@ -111,7 +111,7 @@ fn is_within_jsx_attribute_item(id: AstNodeId, ctx: &LintContext) -> bool { } #[allow(clippy::cast_possible_truncation)] -fn check(ctx: &LintContext<'_>, node_id: AstNodeId, start: u32, offsets: &[usize]) { +fn check(ctx: &LintContext<'_>, node_id: NodeId, start: u32, offsets: &[usize]) { let source_text = ctx.source_text(); for offset in offsets { let offset = start as usize + offset; diff --git a/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs b/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs index 683e0e4c64502..b5799351557fe 100644 --- a/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs +++ b/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs @@ -1,7 +1,7 @@ use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::{AstNode, AstNodeId}; +use oxc_semantic::{AstNode, NodeId}; use oxc_span::Span; use rustc_hash::FxHashSet; @@ -98,7 +98,7 @@ fn run<'a>(possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>) fn check_parents<'a>( node: &AstNode<'a>, - visited: &mut FxHashSet, + visited: &mut FxHashSet, in_conditional: InConditional, ctx: &LintContext<'a>, ) -> InConditional { diff --git a/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs b/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs index be17080b60a98..dad249f04d2a8 100644 --- a/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs +++ b/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs @@ -4,7 +4,7 @@ use cow_utils::CowUtils; use oxc_ast::{ast::MemberExpression, AstKind}; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::{AstNode, AstNodeId, ReferenceId}; +use oxc_semantic::{AstNode, NodeId, ReferenceId}; use oxc_span::{GetSpan, Span}; use crate::{ @@ -151,7 +151,7 @@ fn handle_jest_set_time_out<'a>( reference_id_list: impl Iterator, jest_reference_id_list: &Vec<(ReferenceId, Span)>, seen_jest_set_timeout: &mut bool, - id_to_jest_node_map: &HashMap>, + id_to_jest_node_map: &HashMap>, ) { let nodes = ctx.nodes(); let scopes = ctx.scopes(); @@ -199,7 +199,7 @@ fn handle_jest_set_time_out<'a>( fn is_jest_fn_call<'a>( parent_node: &AstNode<'a>, - id_to_jest_node_map: &HashMap>, + id_to_jest_node_map: &HashMap>, ctx: &LintContext<'a>, ) -> bool { let mut id = parent_node.id(); diff --git a/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs b/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs index cfe3f612f1c58..a8ef95c57f87c 100644 --- a/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs +++ b/crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{ @@ -104,7 +104,7 @@ impl Rule for NoDuplicateHooks { let Some(root_node) = ctx.nodes().root_node() else { return; }; - let mut hook_contexts: HashMap>> = HashMap::new(); + let mut hook_contexts: HashMap>> = HashMap::new(); hook_contexts.insert(root_node.id(), Vec::new()); let mut possibles_jest_nodes = collect_possible_jest_call_node(ctx); @@ -119,8 +119,8 @@ impl Rule for NoDuplicateHooks { impl NoDuplicateHooks { fn run<'a>( possible_jest_node: &PossibleJestNode<'a, '_>, - root_node_id: AstNodeId, - hook_contexts: &mut HashMap>>, + root_node_id: NodeId, + hook_contexts: &mut HashMap>>, ctx: &LintContext<'a>, ) { let node = possible_jest_node.node; diff --git a/crates/oxc_linter/src/rules/jest/no_identical_title.rs b/crates/oxc_linter/src/rules/jest/no_identical_title.rs index 06bcc9d94bcb5..8a7a812502fb1 100644 --- a/crates/oxc_linter/src/rules/jest/no_identical_title.rs +++ b/crates/oxc_linter/src/rules/jest/no_identical_title.rs @@ -6,7 +6,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{ @@ -100,7 +100,7 @@ impl Rule for NoIdenticalTitle { let parent = span_to_parent_mapping.get(span)?; Some((*span, *kind, *parent)) }) - .collect::>(); + .collect::>(); // After being sorted by parent_id, the span with the same parent will be placed nearby. kind_and_spans.sort_by(|a, b| a.2.cmp(&b.2)); @@ -129,7 +129,7 @@ fn filter_and_process_jest_result<'a>( call_expr: &'a CallExpression<'a>, possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>, -) -> Option<(Span, &'a str, JestFnKind, AstNodeId)> { +) -> Option<(Span, &'a str, JestFnKind, NodeId)> { let result = parse_general_jest_fn_call(call_expr, possible_jest_node, ctx)?; let kind = result.kind; // we only need check `describe` or `test` block @@ -154,7 +154,7 @@ fn filter_and_process_jest_result<'a>( } } -fn get_closest_block(node: &AstNode, ctx: &LintContext) -> Option { +fn get_closest_block(node: &AstNode, ctx: &LintContext) -> Option { match node.kind() { AstKind::BlockStatement(_) | AstKind::FunctionBody(_) | AstKind::Program(_) => { Some(node.id()) diff --git a/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs b/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs index 99634ba8068cd..f189f1d99bfd1 100644 --- a/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs +++ b/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{ @@ -91,7 +91,7 @@ impl NoStandaloneExpect { fn run<'a>( &self, possible_jest_node: &PossibleJestNode<'a, '_>, - id_nodes_mapping: &HashMap>, + id_nodes_mapping: &HashMap>, ctx: &LintContext<'a>, ) { let node = possible_jest_node.node; @@ -129,7 +129,7 @@ impl NoStandaloneExpect { fn is_correct_place_to_call_expect<'a>( node: &AstNode<'a>, additional_test_block_functions: &[String], - id_nodes_mapping: &HashMap>, + id_nodes_mapping: &HashMap>, ctx: &LintContext<'a>, ) -> Option<()> { let mut parent = ctx.nodes().parent_node(node.id())?; @@ -197,7 +197,7 @@ fn is_correct_place_to_call_expect<'a>( fn is_var_declarator_or_test_block<'a>( node: &AstNode<'a>, additional_test_block_functions: &[String], - id_nodes_mapping: &HashMap>, + id_nodes_mapping: &HashMap>, ctx: &LintContext<'a>, ) -> bool { match node.kind() { diff --git a/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs b/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs index 0e38524104fbe..4107bbf38634b 100644 --- a/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs +++ b/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs @@ -7,7 +7,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::{AstNodeId, SymbolId}; +use oxc_semantic::{NodeId, SymbolId}; use oxc_span::{GetSpan, Span}; use crate::{ @@ -198,7 +198,7 @@ fn check_loop_usage<'a>( declaration_node: &AstNode<'a>, declarator: &AstNode<'a>, referenced_symbol_id: SymbolId, - spread_node_id: AstNodeId, + spread_node_id: NodeId, spread_span: Span, ctx: &LintContext<'a>, ) { diff --git a/crates/oxc_linter/src/rules/oxc/no_async_await.rs b/crates/oxc_linter/src/rules/oxc/no_async_await.rs index f2fcb5f156d47..4a21f49076349 100644 --- a/crates/oxc_linter/src/rules/oxc/no_async_await.rs +++ b/crates/oxc_linter/src/rules/oxc/no_async_await.rs @@ -1,7 +1,7 @@ use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -49,7 +49,7 @@ impl Rule for NoAsyncAwait { } } -fn report(node_id: AstNodeId, func_span: Span, ctx: &LintContext<'_>) { +fn report(node_id: NodeId, func_span: Span, ctx: &LintContext<'_>) { /// "async".len() const ASYNC_LEN: u32 = 5; diff --git a/crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs b/crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs index 71fade98ad5df..34103935fcb0e 100644 --- a/crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs +++ b/crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs @@ -8,7 +8,7 @@ use oxc_ast::{ }; use oxc_diagnostics::{Error, LabeledSpan, OxcDiagnostic}; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::{GetSpan as _, Span}; use serde_json::Value; @@ -470,7 +470,7 @@ fn is_allowed_string_like<'a>( ctx: &LintContext<'a>, s: &'a str, container: &JSXExpressionContainer<'a>, - node_id: AstNodeId, + node_id: NodeId, is_prop: bool, ) -> bool { is_whitespace(s) @@ -530,7 +530,7 @@ fn report_unnecessary_curly<'a>( fn has_adjacent_jsx_expression_containers<'a>( ctx: &LintContext<'a>, container: &JSXExpressionContainer<'a>, - node_id: AstNodeId, + node_id: NodeId, // element: &JSXElement<'a>, ) -> bool { let Some(parent) = ctx.semantic().nodes().parent_kind(node_id) else { return false }; diff --git a/crates/oxc_linter/src/rules/react/jsx_no_useless_fragment.rs b/crates/oxc_linter/src/rules/react/jsx_no_useless_fragment.rs index 29a5fceb2686c..eac0686e6b205 100644 --- a/crates/oxc_linter/src/rules/react/jsx_no_useless_fragment.rs +++ b/crates/oxc_linter/src/rules/react/jsx_no_useless_fragment.rs @@ -7,7 +7,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -200,7 +200,7 @@ fn has_less_than_two_children(children: &oxc_allocator::Vec<'_, JSXChild<'_>>) - } fn is_fragment_with_only_text_and_is_not_child<'a>( - id: AstNodeId, + id: NodeId, node: &oxc_allocator::Vec<'a, JSXChild<'a>>, ctx: &LintContext, ) -> bool { diff --git a/crates/oxc_linter/src/rules/react/rules_of_hooks.rs b/crates/oxc_linter/src/rules/react/rules_of_hooks.rs index aa57d721cf580..8d5d173e5ae1d 100644 --- a/crates/oxc_linter/src/rules/react/rules_of_hooks.rs +++ b/crates/oxc_linter/src/rules/react/rules_of_hooks.rs @@ -9,7 +9,7 @@ use oxc_cfg::{ ControlFlowGraph, EdgeType, ErrorEdgeKind, InstructionKind, }; use oxc_macros::declare_oxc_lint; -use oxc_semantic::{AstNodeId, AstNodes}; +use oxc_semantic::{AstNodes, NodeId}; use oxc_syntax::operator::AssignmentOperator; use crate::{ @@ -331,7 +331,7 @@ fn parent_func<'a>(nodes: &'a AstNodes<'a>, node: &AstNode) -> Option<&'a AstNod /// And that function isn't a `React.memo` or `React.forwardRef`. /// Returns `true` if this node is a function argument and that isn't a React special function. /// Otherwise it would return `false`. -fn is_non_react_func_arg(nodes: &AstNodes, node_id: AstNodeId) -> bool { +fn is_non_react_func_arg(nodes: &AstNodes, node_id: NodeId) -> bool { let argument = match nodes.parent_node(node_id) { Some(parent) if matches!(parent.kind(), AstKind::Argument(_)) => parent, _ => return false, @@ -344,7 +344,7 @@ fn is_non_react_func_arg(nodes: &AstNodes, node_id: AstNodeId) -> bool { !(is_react_function_call(call, "forwardRef") || is_react_function_call(call, "memo")) } -fn is_somewhere_inside_component_or_hook(nodes: &AstNodes, node_id: AstNodeId) -> bool { +fn is_somewhere_inside_component_or_hook(nodes: &AstNodes, node_id: NodeId) -> bool { nodes .ancestors(node_id) .map(|id| nodes.get_node(id)) @@ -370,7 +370,7 @@ fn is_somewhere_inside_component_or_hook(nodes: &AstNodes, node_id: AstNodeId) - fn get_declaration_identifier<'a>( nodes: &'a AstNodes<'a>, - node_id: AstNodeId, + node_id: NodeId, ) -> Option> { nodes.ancestors(node_id).map(|id| nodes.kind(id)).find_map(|kind| { match kind { @@ -397,7 +397,7 @@ fn get_declaration_identifier<'a>( }) } -fn is_export_default<'a>(nodes: &'a AstNodes<'a>, node_id: AstNodeId) -> bool { +fn is_export_default<'a>(nodes: &'a AstNodes<'a>, node_id: NodeId) -> bool { nodes .ancestors(node_id) .map(|id| nodes.get_node(id)) @@ -407,7 +407,7 @@ fn is_export_default<'a>(nodes: &'a AstNodes<'a>, node_id: AstNodeId) -> bool { /// # Panics /// `node_id` should always point to a valid `Function`. -fn is_memo_or_forward_ref_callback(nodes: &AstNodes, node_id: AstNodeId) -> bool { +fn is_memo_or_forward_ref_callback(nodes: &AstNodes, node_id: NodeId) -> bool { nodes.ancestors(node_id).map(|id| nodes.get_node(id)).any(|node| { if let AstKind::CallExpression(call) = node.kind() { call.callee_name().is_some_and(|name| matches!(name, "forwardRef" | "memo")) diff --git a/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs b/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs index 427e880bfaa97..f382f80912535 100644 --- a/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs +++ b/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs @@ -15,7 +15,7 @@ use oxc_ast::{ }, AstKind, }; -use oxc_semantic::{AstNode, AstNodeId}; +use oxc_semantic::{AstNode, NodeId}; use oxc_span::{GetSpan, Span}; use oxc_syntax::operator::{LogicalOperator, UnaryOperator}; @@ -302,12 +302,7 @@ impl<'a> ListenerMap for AstNode<'a> { } } -fn report_on_imported_call( - span: Span, - name: &str, - node_id: AstNodeId, - options: &NodeListenerOptions, -) { +fn report_on_imported_call(span: Span, name: &str, node_id: NodeId, options: &NodeListenerOptions) { if has_comment_about_side_effect_check(span, options.ctx) { return; } diff --git a/crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs b/crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs index 3db2bfb6a257a..ccb4628ffb30b 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs @@ -4,7 +4,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::{GetSpan, Span}; use crate::{ast_util::is_method_call, context::LintContext, rule::Rule, AstNode}; @@ -125,7 +125,7 @@ fn is_promise_method_with_single_argument(call_expr: &CallExpression) -> bool { is_method_call(call_expr, Some(&["Promise"]), Some(&["all", "any", "race"]), Some(1), Some(1)) } -fn is_fixable(call_node_id: AstNodeId, ctx: &LintContext<'_>) -> bool { +fn is_fixable(call_node_id: NodeId, ctx: &LintContext<'_>) -> bool { for parent in ctx.semantic().nodes().iter_parents(call_node_id).skip(1) { match parent.kind() { AstKind::CallExpression(_) diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs b/crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs index e6d455c0557a2..0b0c7f0636eb6 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs @@ -4,7 +4,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{context::LintContext, rule::Rule, utils::get_first_parameter_name, AstNode}; @@ -188,7 +188,7 @@ fn is_matching_native_coercion_function_call( } fn check_array_callback_methods( - node_id: AstNodeId, + node_id: NodeId, arg: &FormalParameters, function_body: &FunctionBody, is_arrow: bool, diff --git a/crates/oxc_linter/src/rules/unicorn/text_encoding_identifier_case.rs b/crates/oxc_linter/src/rules/unicorn/text_encoding_identifier_case.rs index 01f94b2372c16..1b1135cf2268b 100644 --- a/crates/oxc_linter/src/rules/unicorn/text_encoding_identifier_case.rs +++ b/crates/oxc_linter/src/rules/unicorn/text_encoding_identifier_case.rs @@ -5,7 +5,7 @@ use oxc_ast::{ }; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::AstNodeId; +use oxc_semantic::NodeId; use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -102,7 +102,7 @@ fn get_replacement(node: &str) -> Option<&'static str> { None } -fn is_jsx_meta_elem_with_charset_attr(id: AstNodeId, ctx: &LintContext) -> bool { +fn is_jsx_meta_elem_with_charset_attr(id: NodeId, ctx: &LintContext) -> bool { let Some(parent) = ctx.nodes().parent_node(id) else { return false; }; diff --git a/crates/oxc_linter/src/rules/vitest/prefer_each.rs b/crates/oxc_linter/src/rules/vitest/prefer_each.rs index 290fbce9b46fa..70499876c74c2 100644 --- a/crates/oxc_linter/src/rules/vitest/prefer_each.rs +++ b/crates/oxc_linter/src/rules/vitest/prefer_each.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::{AstNode, AstNodeId}; +use oxc_semantic::{AstNode, NodeId}; use oxc_span::{GetSpan, Span}; use crate::{ @@ -19,7 +19,7 @@ fn use_prefer_each(span: Span, fn_name: &str) -> OxcDiagnostic { } #[inline] -fn is_in_test(ctx: &LintContext<'_>, id: AstNodeId) -> bool { +fn is_in_test(ctx: &LintContext<'_>, id: NodeId) -> bool { ctx.nodes().iter_parents(id).any(|node| { let AstKind::CallExpression(ancestor_call_expr) = node.kind() else { return false }; let Some(ancestor_member_expr) = ancestor_call_expr.callee.as_member_expression() else { @@ -70,7 +70,7 @@ declare_oxc_lint!( impl Rule for PreferEach { fn run_once(&self, ctx: &LintContext<'_>) { - let mut skip = HashSet::::new(); + let mut skip = HashSet::::new(); ctx.nodes().iter().for_each(|node| { Self::run(node, ctx, &mut skip); }); @@ -78,7 +78,7 @@ impl Rule for PreferEach { } impl PreferEach { - fn run<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>, skip: &mut HashSet) { + fn run<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>, skip: &mut HashSet) { let kind = node.kind(); let AstKind::CallExpression(call_expr) = kind else { return }; diff --git a/crates/oxc_linter/src/utils/tree_shaking.rs b/crates/oxc_linter/src/utils/tree_shaking.rs index 034a740393929..86ddbc190e6a1 100644 --- a/crates/oxc_linter/src/utils/tree_shaking.rs +++ b/crates/oxc_linter/src/utils/tree_shaking.rs @@ -5,7 +5,7 @@ use oxc_ast::{ ast::{Expression, IdentifierReference, StaticMemberExpression}, AstKind, CommentKind, }; -use oxc_semantic::{AstNode, AstNodeId, SymbolId}; +use oxc_semantic::{AstNode, NodeId, SymbolId}; use oxc_span::{CompactStr, GetSpan, Span}; use oxc_syntax::operator::{BinaryOperator, LogicalOperator, UnaryOperator}; use rustc_hash::FxHashSet; @@ -135,7 +135,7 @@ impl Value { } pub fn get_write_expr<'a, 'b>( - node_id: AstNodeId, + node_id: NodeId, ctx: &'b LintContext<'a>, ) -> Option<&'b Expression<'a>> { let parent = ctx.nodes().parent_node(node_id)?; diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 861fffeb39bef..bb67c4844ced5 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -27,7 +27,7 @@ use crate::{ jsdoc::JSDocBuilder, label::UnusedLabels, module_record::ModuleRecordBuilder, - node::{AstNodeId, AstNodes, NodeFlags}, + node::{AstNodes, NodeFlags, NodeId}, reference::{Reference, ReferenceFlags, ReferenceId}, scope::{Bindings, ScopeFlags, ScopeId, ScopeTree}, symbol::{SymbolFlags, SymbolId, SymbolTable}, @@ -72,12 +72,12 @@ pub struct SemanticBuilder<'a> { errors: RefCell>, // states - pub(crate) current_node_id: AstNodeId, + pub(crate) current_node_id: NodeId, pub(crate) current_node_flags: NodeFlags, pub(crate) current_symbol_flags: SymbolFlags, pub(crate) current_scope_id: ScopeId, /// Stores current `AstKind::Function` and `AstKind::ArrowFunctionExpression` during AST visit - pub(crate) function_stack: Vec, + pub(crate) function_stack: Vec, // To make a namespace/module value like // we need the to know the modules we are inside // and when we reach a value declaration we set it @@ -108,7 +108,7 @@ pub struct SemanticBuilder<'a> { pub(crate) class_table_builder: ClassTableBuilder, - ast_node_records: Vec, + ast_node_records: Vec, } /// Data returned by [`SemanticBuilder::build`]. @@ -128,7 +128,7 @@ impl<'a> SemanticBuilder<'a> { source_type: SourceType::default(), trivias: trivias.clone(), errors: RefCell::new(vec![]), - current_node_id: AstNodeId::new(0), + current_node_id: NodeId::new(0), current_node_flags: NodeFlags::empty(), current_symbol_flags: SymbolFlags::empty(), current_reference_flags: ReferenceFlags::empty(), @@ -218,7 +218,7 @@ impl<'a> SemanticBuilder<'a> { pub fn build(mut self, program: &Program<'a>) -> SemanticBuilderReturn<'a> { self.source_type = program.source_type; if self.source_type.is_typescript_definition() { - let scope_id = self.scope.add_scope(None, AstNodeId::DUMMY, ScopeFlags::Top); + let scope_id = self.scope.add_scope(None, NodeId::DUMMY, ScopeFlags::Top); program.scope_id.set(Some(scope_id)); } else { // Count the number of nodes, scopes, symbols, and references. @@ -314,13 +314,13 @@ impl<'a> SemanticBuilder<'a> { #[inline] fn record_ast_nodes(&mut self) { if self.cfg.is_some() { - self.ast_node_records.push(AstNodeId::DUMMY); + self.ast_node_records.push(NodeId::DUMMY); } } #[inline] #[allow(clippy::unnecessary_wraps)] - fn retrieve_recorded_ast_node(&mut self) -> Option { + fn retrieve_recorded_ast_node(&mut self) -> Option { if self.cfg.is_some() { Some(self.ast_node_records.pop().expect("there is no ast node record to stop.")) } else { @@ -335,7 +335,7 @@ impl<'a> SemanticBuilder<'a> { // if self.cfg.is_some() { if let Some(record) = self.ast_node_records.last_mut() { - if *record == AstNodeId::DUMMY { + if *record == NodeId::DUMMY { *record = self.current_node_id; } } diff --git a/crates/oxc_semantic/src/class/builder.rs b/crates/oxc_semantic/src/class/builder.rs index d3ca1a2ee93e3..c0419d2940a40 100644 --- a/crates/oxc_semantic/src/class/builder.rs +++ b/crates/oxc_semantic/src/class/builder.rs @@ -8,7 +8,7 @@ use oxc_ast::{ use oxc_span::GetSpan; use oxc_syntax::class::{ClassId, ElementKind}; -use crate::{AstNodeId, AstNodes}; +use crate::{AstNodes, NodeId}; use super::{ table::{Element, PrivateIdentifierReference}, @@ -33,7 +33,7 @@ impl ClassTableBuilder { pub fn declare_class_body( &mut self, class: &ClassBody, - current_node_id: AstNodeId, + current_node_id: NodeId, nodes: &AstNodes, ) { let parent_id = nodes.parent_id(current_node_id).unwrap_or_else(|| unreachable!()); @@ -98,7 +98,7 @@ impl ClassTableBuilder { pub fn add_private_identifier_reference( &mut self, ident: &PrivateIdentifier, - current_node_id: AstNodeId, + current_node_id: NodeId, nodes: &AstNodes, ) { let parent_kind = nodes.parent_kind(current_node_id); diff --git a/crates/oxc_semantic/src/class/table.rs b/crates/oxc_semantic/src/class/table.rs index 9b8282f0dbdda..a4a68adaaf21e 100644 --- a/crates/oxc_semantic/src/class/table.rs +++ b/crates/oxc_semantic/src/class/table.rs @@ -4,7 +4,7 @@ use oxc_index::IndexVec; use oxc_span::{CompactStr, Span}; use oxc_syntax::class::{ClassId, ElementId, ElementKind}; -use crate::node::AstNodeId; +use crate::node::NodeId; #[derive(Debug)] pub struct Element { @@ -29,14 +29,14 @@ impl Element { #[derive(Debug)] pub struct PrivateIdentifierReference { - pub id: AstNodeId, + pub id: NodeId, pub name: CompactStr, pub span: Span, pub element_ids: Vec, } impl PrivateIdentifierReference { - pub fn new(id: AstNodeId, name: CompactStr, span: Span, element_ids: Vec) -> Self { + pub fn new(id: NodeId, name: CompactStr, span: Span, element_ids: Vec) -> Self { Self { id, name, span, element_ids } } } @@ -47,7 +47,7 @@ impl PrivateIdentifierReference { #[derive(Debug, Default)] pub struct ClassTable { pub parent_ids: FxHashMap, - pub declarations: IndexVec, + pub declarations: IndexVec, pub elements: IndexVec>, // PrivateIdentifier reference pub private_identifiers: IndexVec>, @@ -62,7 +62,7 @@ impl ClassTable { self.declarations.raw.len() } - pub fn iter_enumerated(&self) -> impl Iterator + '_ { + pub fn iter_enumerated(&self) -> impl Iterator + '_ { self.declarations.iter_enumerated() } @@ -73,7 +73,7 @@ impl ClassTable { self.private_identifiers[class_id].iter() } - pub fn get_node_id(&self, class_id: ClassId) -> AstNodeId { + pub fn get_node_id(&self, class_id: ClassId) -> NodeId { self.declarations[class_id] } @@ -102,7 +102,7 @@ impl ClassTable { self.elements[class_id].iter().any(|p| p.is_private && p.name == name) } - pub fn declare_class(&mut self, parent_id: Option, ast_node_id: AstNodeId) -> ClassId { + pub fn declare_class(&mut self, parent_id: Option, ast_node_id: NodeId) -> ClassId { let class_id = self.declarations.push(ast_node_id); if let Some(parent_id) = parent_id { self.parent_ids.insert(class_id, parent_id); diff --git a/crates/oxc_semantic/src/dot.rs b/crates/oxc_semantic/src/dot.rs index 432c4dd82cd19..ed768038536d3 100644 --- a/crates/oxc_semantic/src/dot.rs +++ b/crates/oxc_semantic/src/dot.rs @@ -10,7 +10,7 @@ use oxc_cfg::{ BasicBlock, ControlFlowGraph, EdgeType, Instruction, InstructionKind, IterationInstructionKind, LabeledInstruction, ReturnInstructionKind, }; -use oxc_syntax::node::AstNodeId; +use oxc_syntax::node::NodeId; use crate::{AstNode, AstNodes}; @@ -26,11 +26,11 @@ pub trait DebugDot { pub struct DebugDotContext<'a, 'b>(&'b AstNodes<'a>); impl<'a, 'b> DebugDotContext<'a, 'b> { - fn debug_ast_kind(self, id: AstNodeId) -> String { + fn debug_ast_kind(self, id: NodeId) -> String { self.0.kind(id).debug_name().into_owned() } - fn try_eval_literal(self, id: AstNodeId) -> Option { + fn try_eval_literal(self, id: NodeId) -> Option { match self.0.kind(id) { AstKind::NumericLiteral(lit) => Some(lit.value.to_string()), AstKind::BooleanLiteral(lit) => Some(lit.value.to_string()), diff --git a/crates/oxc_semantic/src/label.rs b/crates/oxc_semantic/src/label.rs index fe346c94a2651..bf47b764cc9da 100644 --- a/crates/oxc_semantic/src/label.rs +++ b/crates/oxc_semantic/src/label.rs @@ -1,4 +1,4 @@ -use crate::AstNodeId; +use crate::NodeId; #[derive(Debug)] pub struct LabeledScope<'a> { @@ -11,7 +11,7 @@ pub struct LabeledScope<'a> { pub struct UnusedLabels<'a> { pub scopes: Vec>, pub curr_scope: usize, - pub labels: Vec, + pub labels: Vec, } impl<'a> UnusedLabels<'a> { @@ -27,7 +27,7 @@ impl<'a> UnusedLabels<'a> { } } - pub fn mark_unused(&mut self, current_node_id: AstNodeId) { + pub fn mark_unused(&mut self, current_node_id: NodeId) { let scope = &self.scopes[self.curr_scope]; if !scope.used { self.labels.push(current_node_id); diff --git a/crates/oxc_semantic/src/lib.rs b/crates/oxc_semantic/src/lib.rs index 2c1f8926241a7..c1a1f28415a02 100644 --- a/crates/oxc_semantic/src/lib.rs +++ b/crates/oxc_semantic/src/lib.rs @@ -37,7 +37,7 @@ mod unresolved_stack; pub use crate::{ builder::{SemanticBuilder, SemanticBuilderReturn}, jsdoc::{JSDoc, JSDocFinder, JSDocTag}, - node::{AstNode, AstNodeId, AstNodes}, + node::{AstNode, AstNodes, NodeId}, reference::{Reference, ReferenceFlags, ReferenceId}, scope::ScopeTree, symbol::{IsGlobalReference, SymbolTable}, @@ -83,7 +83,7 @@ pub struct Semantic<'a> { /// Parsed JSDoc comments. jsdoc: JSDocFinder<'a>, - unused_labels: Vec, + unused_labels: Vec, /// Control flow graph. Only present if [`Semantic`] is built with cfg /// creation enabled using [`SemanticBuilder::with_cfg`]. @@ -150,7 +150,7 @@ impl<'a> Semantic<'a> { &self.symbols } - pub fn unused_labels(&self) -> &Vec { + pub fn unused_labels(&self) -> &Vec { &self.unused_labels } @@ -162,7 +162,7 @@ impl<'a> Semantic<'a> { self.cfg.as_ref() } - pub fn is_unresolved_reference(&self, node_id: AstNodeId) -> bool { + pub fn is_unresolved_reference(&self, node_id: NodeId) -> bool { let reference_node = self.nodes.get_node(node_id); let AstKind::IdentifierReference(id) = reference_node.kind() else { return false; diff --git a/crates/oxc_semantic/src/node.rs b/crates/oxc_semantic/src/node.rs index 35324724e3547..3a478bacad6b5 100644 --- a/crates/oxc_semantic/src/node.rs +++ b/crates/oxc_semantic/src/node.rs @@ -2,14 +2,14 @@ use oxc_ast::AstKind; use oxc_cfg::BasicBlockId; use oxc_index::IndexVec; use oxc_span::GetSpan; -pub use oxc_syntax::node::{AstNodeId, NodeFlags}; +pub use oxc_syntax::node::{NodeFlags, NodeId}; use crate::scope::ScopeId; /// Semantic node contains all the semantic information about an ast node. #[derive(Debug, Clone, Copy)] pub struct AstNode<'a> { - id: AstNodeId, + id: NodeId, /// A pointer to the ast node, which resides in the `bumpalo` memory arena. kind: AstKind<'a>, @@ -29,13 +29,13 @@ impl<'a> AstNode<'a> { scope_id: ScopeId, cfg_id: BasicBlockId, flags: NodeFlags, - id: AstNodeId, + id: NodeId, ) -> Self { Self { id, kind, scope_id, cfg_id, flags } } #[inline] - pub fn id(&self) -> AstNodeId { + pub fn id(&self) -> NodeId { self.id } @@ -78,9 +78,9 @@ pub struct AstNodes<'a> { /// The root node should always point to a `Program`, which is the real /// root of the tree. It isn't possible to statically check for this, so /// users should beware. - root: Option, - nodes: IndexVec>, - parent_ids: IndexVec>, + root: Option, + nodes: IndexVec>, + parent_ids: IndexVec>, } impl<'a> AstNodes<'a> { @@ -103,45 +103,42 @@ impl<'a> AstNodes<'a> { /// The first node produced by this iterator is the first parent of the node /// pointed to by `node_id`. The last node will usually be a `Program`. #[inline] - pub fn iter_parents( - &self, - node_id: AstNodeId, - ) -> impl Iterator> + Clone + '_ { + pub fn iter_parents(&self, node_id: NodeId) -> impl Iterator> + Clone + '_ { AstNodeParentIter { current_node_id: Some(node_id), nodes: self } } #[inline] - pub fn kind(&self, ast_node_id: AstNodeId) -> AstKind<'a> { + pub fn kind(&self, ast_node_id: NodeId) -> AstKind<'a> { self.nodes[ast_node_id].kind } #[inline] - pub fn parent_id(&self, ast_node_id: AstNodeId) -> Option { + pub fn parent_id(&self, ast_node_id: NodeId) -> Option { self.parent_ids[ast_node_id] } - pub fn parent_kind(&self, ast_node_id: AstNodeId) -> Option> { + pub fn parent_kind(&self, ast_node_id: NodeId) -> Option> { self.parent_id(ast_node_id).map(|node_id| self.kind(node_id)) } - pub fn parent_node(&self, ast_node_id: AstNodeId) -> Option<&AstNode<'a>> { + pub fn parent_node(&self, ast_node_id: NodeId) -> Option<&AstNode<'a>> { self.parent_id(ast_node_id).map(|node_id| self.get_node(node_id)) } #[inline] - pub fn get_node(&self, ast_node_id: AstNodeId) -> &AstNode<'a> { + pub fn get_node(&self, ast_node_id: NodeId) -> &AstNode<'a> { &self.nodes[ast_node_id] } #[inline] - pub fn get_node_mut(&mut self, ast_node_id: AstNodeId) -> &mut AstNode<'a> { + pub fn get_node_mut(&mut self, ast_node_id: NodeId) -> &mut AstNode<'a> { &mut self.nodes[ast_node_id] } - /// Get the root `AstNodeId`, It is always pointing to a `Program`. + /// Get the root `NodeId`, It is always pointing to a `Program`. /// Returns `None` if root node isn't set. #[inline] - pub fn root(&self) -> Option { + pub fn root(&self) -> Option { self.root } @@ -163,36 +160,36 @@ impl<'a> AstNodes<'a> { /// /// The first node produced by this iterator is the first parent of the node /// pointed to by `node_id`. The last node will usually be a `Program`. - pub fn ancestors(&self, ast_node_id: AstNodeId) -> impl Iterator + '_ { + pub fn ancestors(&self, ast_node_id: NodeId) -> impl Iterator + '_ { let parent_ids = &self.parent_ids; std::iter::successors(Some(ast_node_id), |node_id| parent_ids[*node_id]) } - /// Create and add an `AstNode` to the `AstNodes` tree and returns its `AstNodeId`. + /// Create and add an `AstNode` to the `AstNodes` tree and returns its `NodeId`. /// Node must not be `Program`. Use `add_program_node` instead. #[inline] pub fn add_node( &mut self, kind: AstKind<'a>, scope_id: ScopeId, - parent_node_id: AstNodeId, + parent_node_id: NodeId, cfg_id: BasicBlockId, flags: NodeFlags, - ) -> AstNodeId { + ) -> NodeId { let ast_node_id = self.parent_ids.push(Some(parent_node_id)); let node = AstNode::new(kind, scope_id, cfg_id, flags, ast_node_id); self.nodes.push(node); ast_node_id } - /// Create and add an `AstNode` to the `AstNodes` tree and returns its `AstNodeId`. + /// Create and add an `AstNode` to the `AstNodes` tree and returns its `NodeId`. pub fn add_program_node( &mut self, kind: AstKind<'a>, scope_id: ScopeId, cfg_id: BasicBlockId, flags: NodeFlags, - ) -> AstNodeId { + ) -> NodeId { let ast_node_id = self.parent_ids.push(None); self.root = Some(ast_node_id); let node = AstNode::new(kind, scope_id, cfg_id, flags, ast_node_id); @@ -208,7 +205,7 @@ impl<'a> AstNodes<'a> { #[derive(Debug, Clone)] pub struct AstNodeParentIter<'s, 'a> { - current_node_id: Option, + current_node_id: Option, nodes: &'s AstNodes<'a>, } diff --git a/crates/oxc_semantic/src/post_transform_checker.rs b/crates/oxc_semantic/src/post_transform_checker.rs index f4f4ec9beea78..9c51f23f34bd0 100644 --- a/crates/oxc_semantic/src/post_transform_checker.rs +++ b/crates/oxc_semantic/src/post_transform_checker.rs @@ -377,7 +377,7 @@ impl<'s> PostTransformChecker<'s> { } } - // NB: Skip checking node IDs match - transformer does not set `AstNodeId`s + // NB: Skip checking node IDs match - transformer does not set `NodeId`s } } @@ -412,7 +412,7 @@ impl<'s> PostTransformChecker<'s> { self.errors.push_mismatch("Symbol scope ID mismatch", symbol_ids, scope_ids); } - // NB: Skip checking declarations match - transformer does not set `AstNodeId`s + // NB: Skip checking declarations match - transformer does not set `NodeId`s // Check resolved references match let reference_ids = self.get_pair(symbol_ids, |scoping, symbol_id| { diff --git a/crates/oxc_semantic/src/reference.rs b/crates/oxc_semantic/src/reference.rs index 1ca9c1b7923eb..0b1b418b9c85a 100644 --- a/crates/oxc_semantic/src/reference.rs +++ b/crates/oxc_semantic/src/reference.rs @@ -8,7 +8,7 @@ use tsify::Tsify; pub use oxc_syntax::reference::{ReferenceFlags, ReferenceId}; -use crate::{symbol::SymbolId, AstNodeId}; +use crate::{symbol::SymbolId, NodeId}; /// Describes where and how a Symbol is used in the AST. /// @@ -37,7 +37,7 @@ use crate::{symbol::SymbolId, AstNodeId}; #[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))] pub struct Reference { /// The AST node making the reference. - node_id: AstNodeId, + node_id: NodeId, /// The symbol being referenced. /// /// This will be [`None`] if no symbol could be found within @@ -52,17 +52,13 @@ pub struct Reference { impl Reference { /// Create a new unresolved reference. #[inline] - pub fn new(node_id: AstNodeId, flags: ReferenceFlags) -> Self { + pub fn new(node_id: NodeId, flags: ReferenceFlags) -> Self { Self { node_id, symbol_id: None, flags } } /// Create a new resolved reference on a symbol. #[inline] - pub fn new_with_symbol_id( - node_id: AstNodeId, - symbol_id: SymbolId, - flags: ReferenceFlags, - ) -> Self { + pub fn new_with_symbol_id(node_id: NodeId, symbol_id: SymbolId, flags: ReferenceFlags) -> Self { Self { node_id, symbol_id: Some(symbol_id), flags } } @@ -74,7 +70,7 @@ impl Reference { /// [`IdentifierReference`]: oxc_ast::ast::IdentifierReference /// [`JSXIdentifier`]: oxc_ast::ast::JSXIdentifier #[inline] - pub fn node_id(&self) -> AstNodeId { + pub fn node_id(&self) -> NodeId { self.node_id } diff --git a/crates/oxc_semantic/src/scope.rs b/crates/oxc_semantic/src/scope.rs index b8e052ad09a25..51c33343a8f10 100644 --- a/crates/oxc_semantic/src/scope.rs +++ b/crates/oxc_semantic/src/scope.rs @@ -8,7 +8,7 @@ use oxc_span::CompactStr; use oxc_syntax::reference::ReferenceId; pub use oxc_syntax::scope::{ScopeFlags, ScopeId}; -use crate::{symbol::SymbolId, AstNodeId}; +use crate::{symbol::SymbolId, NodeId}; type FxIndexMap = IndexMap>; @@ -37,7 +37,7 @@ pub struct ScopeTree { pub(crate) build_child_ids: bool, /// Maps a scope to its node id. - node_ids: IndexVec, + node_ids: IndexVec, flags: IndexVec, @@ -223,7 +223,7 @@ impl ScopeTree { /// /// [`AstNode`]: crate::AstNode #[inline] - pub fn get_node_id(&self, scope_id: ScopeId) -> AstNodeId { + pub fn get_node_id(&self, scope_id: ScopeId) -> NodeId { self.node_ids[scope_id] } @@ -272,7 +272,7 @@ impl ScopeTree { pub fn add_scope( &mut self, parent_id: Option, - node_id: AstNodeId, + node_id: NodeId, flags: ScopeFlags, ) -> ScopeId { let scope_id = self.parent_ids.push(parent_id); diff --git a/crates/oxc_semantic/src/symbol.rs b/crates/oxc_semantic/src/symbol.rs index fbdd5c1b89f7d..2170dc7fc1183 100644 --- a/crates/oxc_semantic/src/symbol.rs +++ b/crates/oxc_semantic/src/symbol.rs @@ -14,7 +14,7 @@ pub use oxc_syntax::{ }; use crate::{ - node::AstNodeId, + node::NodeId, reference::{Reference, ReferenceId}, }; @@ -39,7 +39,7 @@ pub struct SymbolTable { pub flags: IndexVec, pub scope_ids: IndexVec, /// Pointer to the AST Node where this symbol is declared - pub declarations: IndexVec, + pub declarations: IndexVec, pub resolved_references: IndexVec>, redeclarations: IndexVec>, @@ -124,7 +124,7 @@ impl SymbolTable { } #[inline] - pub fn get_declaration(&self, symbol_id: SymbolId) -> AstNodeId { + pub fn get_declaration(&self, symbol_id: SymbolId) -> NodeId { self.declarations[symbol_id] } @@ -134,7 +134,7 @@ impl SymbolTable { name: CompactStr, flags: SymbolFlags, scope_id: ScopeId, - node_id: AstNodeId, + node_id: NodeId, ) -> SymbolId { self.spans.push(span); self.names.push(name); diff --git a/crates/oxc_syntax/src/node.rs b/crates/oxc_syntax/src/node.rs index 9efc14db981ae..f92b45cd8dc39 100644 --- a/crates/oxc_syntax/src/node.rs +++ b/crates/oxc_syntax/src/node.rs @@ -5,12 +5,12 @@ use oxc_index::Idx; use serde::{Serialize, Serializer}; #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub struct AstNodeId(NonMaxU32); +pub struct NodeId(NonMaxU32); -impl AstNodeId { - pub const DUMMY: Self = AstNodeId::new(0); +impl NodeId { + pub const DUMMY: Self = NodeId::new(0); - /// Create `AstNodeId` from `u32`. + /// Create `NodeId` from `u32`. /// /// # Panics /// Panics if `idx` is `u32::MAX`. @@ -22,7 +22,7 @@ impl AstNodeId { unsafe { Self::new_unchecked(idx) } } - /// Create `AstNodeId` from `u32` unchecked. + /// Create `NodeId` from `u32` unchecked. /// /// # SAFETY /// `idx` must not be `u32::MAX`. @@ -33,7 +33,7 @@ impl AstNodeId { } } -impl Idx for AstNodeId { +impl Idx for NodeId { #[allow(clippy::cast_possible_truncation)] fn from_usize(idx: usize) -> Self { assert!(idx < u32::MAX as usize); @@ -47,7 +47,7 @@ impl Idx for AstNodeId { } #[cfg(feature = "serialize")] -impl Serialize for AstNodeId { +impl Serialize for NodeId { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -59,7 +59,7 @@ impl Serialize for AstNodeId { #[cfg(feature = "serialize")] #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" -export type AstNodeId = number; +export type NodeId = number; export type NodeFlags = { JSDoc: 1, Class: 2, diff --git a/crates/oxc_transformer/src/typescript/enum.rs b/crates/oxc_transformer/src/typescript/enum.rs index c194fe1388d53..a3374a81c8498 100644 --- a/crates/oxc_transformer/src/typescript/enum.rs +++ b/crates/oxc_transformer/src/typescript/enum.rs @@ -4,7 +4,7 @@ use oxc_allocator::Vec; use oxc_ast::{ast::*, visit::walk_mut, VisitMut, NONE}; use oxc_span::{Atom, Span, SPAN}; use oxc_syntax::{ - node::AstNodeId, + node::NodeId, number::{NumberBase, ToJsInt32, ToJsString}, operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator}, reference::ReferenceFlags, @@ -85,7 +85,7 @@ impl<'a> TypeScriptEnum<'a> { enum_name.to_compact_str(), SymbolFlags::FunctionScopedVariable, func_scope_id, - AstNodeId::DUMMY, + NodeId::DUMMY, ); ctx.scopes_mut().add_binding(func_scope_id, enum_name.to_compact_str(), param_symbol_id); let ident = BindingIdentifier { diff --git a/crates/oxc_traverse/src/context/scoping.rs b/crates/oxc_traverse/src/context/scoping.rs index 45519f8965b4f..cea6a97a59ba3 100644 --- a/crates/oxc_traverse/src/context/scoping.rs +++ b/crates/oxc_traverse/src/context/scoping.rs @@ -6,7 +6,7 @@ use rustc_hash::FxHashSet; #[allow(clippy::wildcard_imports)] use oxc_ast::{ast::*, visit::Visit}; -use oxc_semantic::{AstNodeId, Reference, ScopeTree, SymbolTable}; +use oxc_semantic::{NodeId, Reference, ScopeTree, SymbolTable}; use oxc_span::{Atom, CompactStr, Span, SPAN}; use oxc_syntax::{ reference::{ReferenceFlags, ReferenceId}, @@ -82,7 +82,7 @@ impl TraverseScoping { /// `flags` provided are amended to inherit from parent scope's flags. pub fn create_child_scope(&mut self, parent_id: ScopeId, flags: ScopeFlags) -> ScopeId { let flags = self.scopes.get_new_scope_flags(flags, parent_id); - self.scopes.add_scope(Some(parent_id), AstNodeId::DUMMY, flags) + self.scopes.add_scope(Some(parent_id), NodeId::DUMMY, flags) } /// Create new scope as child of current scope. @@ -222,7 +222,7 @@ impl TraverseScoping { // Add binding to scope let symbol_id = - self.symbols.create_symbol(SPAN, name.clone(), flags, scope_id, AstNodeId::DUMMY); + self.symbols.create_symbol(SPAN, name.clone(), flags, scope_id, NodeId::DUMMY); self.scopes.add_binding(scope_id, name, symbol_id); symbol_id } @@ -281,7 +281,7 @@ impl TraverseScoping { symbol_id: SymbolId, flags: ReferenceFlags, ) -> ReferenceId { - let reference = Reference::new_with_symbol_id(AstNodeId::DUMMY, symbol_id, flags); + let reference = Reference::new_with_symbol_id(NodeId::DUMMY, symbol_id, flags); let reference_id = self.symbols.create_reference(reference); self.symbols.resolved_references[symbol_id].push(reference_id); reference_id @@ -305,7 +305,7 @@ impl TraverseScoping { name: CompactStr, flags: ReferenceFlags, ) -> ReferenceId { - let reference = Reference::new(AstNodeId::DUMMY, flags); + let reference = Reference::new(NodeId::DUMMY, flags); let reference_id = self.symbols.create_reference(reference); self.scopes.add_root_unresolved_reference(name, reference_id); reference_id