From fac5042afafc6e1acd6953150f3857d086ba945d Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Tue, 5 Nov 2024 02:25:28 +0000 Subject: [PATCH] refactor(ast): use `scope_id` etc methods (#7130) Utilize the methods added in #7127 in `oxc_ast`. --- crates/oxc_ast/src/ast_impl/js.rs | 4 +-- crates/oxc_ast/src/ast_kind_impl.rs | 38 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index e455c42f0e012..60d4f5ee9a522 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -970,10 +970,10 @@ impl<'a> Function<'a> { /// Get the [`SymbolId`] this [`Function`] is bound to. /// - /// Returns [`None`] for anonymous functions, or if semantic analysis was skipped. + /// Returns [`None`] for anonymous functions. #[inline] pub fn symbol_id(&self) -> Option { - self.id.as_ref().and_then(|id| id.symbol_id.get()) + self.id.as_ref().map(BindingIdentifier::symbol_id) } /// `true` for overload signatures and `declare function` statements. diff --git a/crates/oxc_ast/src/ast_kind_impl.rs b/crates/oxc_ast/src/ast_kind_impl.rs index 0a018adb2f7e3..68c1a2b530357 100644 --- a/crates/oxc_ast/src/ast_kind_impl.rs +++ b/crates/oxc_ast/src/ast_kind_impl.rs @@ -100,25 +100,25 @@ impl<'a> AstKind<'a> { /// Will always be none if semantic analysis has not been run. pub fn get_container_scope_id(self) -> Option { match self { - Self::Program(p) => p.scope_id.get(), - Self::BlockStatement(b) => b.scope_id.get(), - Self::ForStatement(f) => f.scope_id.get(), - Self::ForInStatement(f) => f.scope_id.get(), - Self::ForOfStatement(f) => f.scope_id.get(), - Self::SwitchStatement(switch) => switch.scope_id.get(), - Self::CatchClause(catch) => catch.scope_id.get(), - Self::Function(f) => f.scope_id.get(), - Self::ArrowFunctionExpression(f) => f.scope_id.get(), - Self::Class(class) => class.scope_id.get(), - Self::StaticBlock(b) => b.scope_id.get(), - Self::TSEnumDeclaration(e) => e.scope_id.get(), - Self::TSConditionalType(e) => e.scope_id.get(), - Self::TSTypeAliasDeclaration(e) => e.scope_id.get(), - Self::TSInterfaceDeclaration(e) => e.scope_id.get(), - Self::TSMethodSignature(e) => e.scope_id.get(), - Self::TSConstructSignatureDeclaration(e) => e.scope_id.get(), - Self::TSModuleDeclaration(e) => e.scope_id.get(), - Self::TSMappedType(e) => e.scope_id.get(), + Self::Program(p) => Some(p.scope_id()), + Self::BlockStatement(b) => Some(b.scope_id()), + Self::ForStatement(f) => Some(f.scope_id()), + Self::ForInStatement(f) => Some(f.scope_id()), + Self::ForOfStatement(f) => Some(f.scope_id()), + Self::SwitchStatement(switch) => Some(switch.scope_id()), + Self::CatchClause(catch) => Some(catch.scope_id()), + Self::Function(f) => Some(f.scope_id()), + Self::ArrowFunctionExpression(f) => Some(f.scope_id()), + Self::Class(class) => Some(class.scope_id()), + Self::StaticBlock(b) => Some(b.scope_id()), + Self::TSEnumDeclaration(e) => Some(e.scope_id()), + Self::TSConditionalType(e) => Some(e.scope_id()), + Self::TSTypeAliasDeclaration(e) => Some(e.scope_id()), + Self::TSInterfaceDeclaration(e) => Some(e.scope_id()), + Self::TSMethodSignature(e) => Some(e.scope_id()), + Self::TSConstructSignatureDeclaration(e) => Some(e.scope_id()), + Self::TSModuleDeclaration(e) => Some(e.scope_id()), + Self::TSMappedType(e) => Some(e.scope_id()), _ => None, } }