Skip to content

Commit

Permalink
refactor(ast): use scope_id etc methods
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Nov 4, 2024
1 parent d219e50 commit 80ea830
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SymbolId> {
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.
Expand Down
38 changes: 19 additions & 19 deletions crates/oxc_ast/src/ast_kind_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ScopeId> {
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,
}
}
Expand Down

0 comments on commit 80ea830

Please sign in to comment.