mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(ast): make AstBuilder non-exhaustive (#4925)
This commit is contained in:
parent
a7750e3303
commit
96422b6489
3 changed files with 5 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ use crate::ast::*;
|
||||||
|
|
||||||
/// AST builder for creating AST nodes
|
/// AST builder for creating AST nodes
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct AstBuilder<'a> {
|
pub struct AstBuilder<'a> {
|
||||||
pub allocator: &'a Allocator,
|
pub allocator: &'a Allocator,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ use es2019::ES2019;
|
||||||
use es2020::ES2020;
|
use es2020::ES2020;
|
||||||
use es2021::ES2021;
|
use es2021::ES2021;
|
||||||
use oxc_allocator::{Allocator, Vec};
|
use oxc_allocator::{Allocator, Vec};
|
||||||
use oxc_ast::{ast::*, AstBuilder, Trivias};
|
use oxc_ast::{ast::*, Trivias};
|
||||||
use oxc_diagnostics::OxcDiagnostic;
|
use oxc_diagnostics::OxcDiagnostic;
|
||||||
use oxc_semantic::{ScopeTree, SemanticBuilder, SymbolTable};
|
use oxc_semantic::{ScopeTree, SemanticBuilder, SymbolTable};
|
||||||
use oxc_span::SourceType;
|
use oxc_span::SourceType;
|
||||||
|
|
@ -107,7 +107,7 @@ impl<'a> Transformer<'a> {
|
||||||
.build(program)
|
.build(program)
|
||||||
.semantic
|
.semantic
|
||||||
.into_symbol_table_and_scope_tree();
|
.into_symbol_table_and_scope_tree();
|
||||||
let TransformCtx { ast: AstBuilder { allocator }, .. } = *self.ctx;
|
let allocator: &'a Allocator = self.ctx.ast.allocator;
|
||||||
let (symbols, scopes) = traverse_mut(&mut self, allocator, program, symbols, scopes);
|
let (symbols, scopes) = traverse_mut(&mut self, allocator, program, symbols, scopes);
|
||||||
TransformerReturn { errors: self.ctx.take_errors(), symbols, scopes }
|
TransformerReturn { errors: self.ctx.take_errors(), symbols, scopes }
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +118,7 @@ impl<'a> Transformer<'a> {
|
||||||
scopes: ScopeTree,
|
scopes: ScopeTree,
|
||||||
program: &mut Program<'a>,
|
program: &mut Program<'a>,
|
||||||
) -> TransformerReturn {
|
) -> TransformerReturn {
|
||||||
let TransformCtx { ast: AstBuilder { allocator }, .. } = *self.ctx;
|
let allocator: &'a Allocator = self.ctx.ast.allocator;
|
||||||
let (symbols, scopes) = traverse_mut(&mut self, allocator, program, symbols, scopes);
|
let (symbols, scopes) = traverse_mut(&mut self, allocator, program, symbols, scopes);
|
||||||
TransformerReturn { errors: self.ctx.take_errors(), symbols, scopes }
|
TransformerReturn { errors: self.ctx.take_errors(), symbols, scopes }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ impl Generator for AstBuilderGenerator {
|
||||||
///@@line_break
|
///@@line_break
|
||||||
/// AST builder for creating AST nodes
|
/// AST builder for creating AST nodes
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct AstBuilder<'a> {
|
pub struct AstBuilder<'a> {
|
||||||
pub allocator: &'a Allocator,
|
pub allocator: &'a Allocator,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue