mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(semantic): simplify handling namespace stack (#7987)
We had a BindingIdentifier to `TSModuleDeclarationName` so that we don't need to get binding from name.
This commit is contained in:
parent
48cb52b335
commit
1cf7b83431
2 changed files with 7 additions and 8 deletions
|
|
@ -1989,11 +1989,10 @@ impl<'a> SemanticBuilder<'a> {
|
|||
}
|
||||
AstKind::TSModuleDeclaration(module_declaration) => {
|
||||
module_declaration.bind(self);
|
||||
let symbol_id = self
|
||||
.scope
|
||||
.get_bindings(self.current_scope_id)
|
||||
.get(module_declaration.id.name().as_str())
|
||||
.copied();
|
||||
let symbol_id = match &module_declaration.id {
|
||||
TSModuleDeclarationName::Identifier(ident) => ident.symbol_id.get(),
|
||||
TSModuleDeclarationName::StringLiteral(_) => None,
|
||||
};
|
||||
self.namespace_stack.push(symbol_id);
|
||||
}
|
||||
AstKind::TSTypeAliasDeclaration(type_alias_declaration) => {
|
||||
|
|
@ -2086,7 +2085,7 @@ impl<'a> SemanticBuilder<'a> {
|
|||
AstKind::CatchParameter(_) => {
|
||||
self.resolve_references_for_current_scope();
|
||||
}
|
||||
AstKind::TSModuleBlock(_) => {
|
||||
AstKind::TSModuleDeclaration(_) => {
|
||||
self.namespace_stack.pop();
|
||||
}
|
||||
AstKind::TSTypeName(_) => {
|
||||
|
|
@ -2103,7 +2102,7 @@ impl<'a> SemanticBuilder<'a> {
|
|||
}
|
||||
|
||||
fn make_all_namespaces_valuelike(&mut self) {
|
||||
for &symbol_id in &self.namespace_stack {
|
||||
for symbol_id in self.namespace_stack.iter().copied() {
|
||||
let Some(symbol_id) = symbol_id else {
|
||||
continue;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35516,7 +35516,7 @@ Scope children mismatch:
|
|||
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(7)]
|
||||
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2)]
|
||||
Symbol flags mismatch for "createElement":
|
||||
after transform: SymbolId(2): SymbolFlags(BlockScopedVariable | Function | NameSpaceModule | ValueModule)
|
||||
after transform: SymbolId(2): SymbolFlags(BlockScopedVariable | Function | NameSpaceModule)
|
||||
rebuilt : SymbolId(1): SymbolFlags(BlockScopedVariable | Function)
|
||||
Symbol redeclarations mismatch for "createElement":
|
||||
after transform: SymbolId(2): [Span { start: 243, end: 256 }]
|
||||
|
|
|
|||
Loading…
Reference in a new issue