-
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(transformer): move
BoundIdentifier
into helpers
- Loading branch information
1 parent
d65202d
commit 58af4ce
Showing
4 changed files
with
39 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use oxc_ast::ast::IdentifierReference; | ||
use oxc_span::{Atom, SPAN}; | ||
use oxc_syntax::{reference::ReferenceFlag, symbol::SymbolId}; | ||
use oxc_traverse::TraverseCtx; | ||
|
||
/// Store for a created binding identifier | ||
#[derive(Clone)] | ||
pub struct BoundIdentifier<'a> { | ||
pub name: Atom<'a>, | ||
pub symbol_id: SymbolId, | ||
} | ||
|
||
impl<'a> BoundIdentifier<'a> { | ||
/// Create `IdentifierReference` referencing this binding which is read from | ||
/// in current scope | ||
pub fn create_read_reference(&self, ctx: &mut TraverseCtx) -> IdentifierReference<'a> { | ||
let reference_id = ctx.create_bound_reference( | ||
self.name.to_compact_str(), | ||
self.symbol_id, | ||
ReferenceFlag::Read, | ||
); | ||
IdentifierReference::new_read(SPAN, self.name.clone(), Some(reference_id)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ mod react; | |
mod typescript; | ||
|
||
mod helpers { | ||
pub mod bindings; | ||
pub mod module_imports; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters