Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/oxc_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ impl<'a> Codegen<'a> {
self
}

/// Sets the source text for the code generator.
#[must_use]
pub fn with_source_text(mut self, source_text: &'a str) -> Self {
self.source_text = source_text;
self
}

/// Set the symbol table used for identifier renaming.
///
/// Can be used for easy renaming of variables (based on semantic analysis).
Expand Down Expand Up @@ -251,6 +258,8 @@ impl<'a> Codegen<'a> {

/// Print a single [`Expression`], adding it to the code generator's
/// internal buffer. Unlike [`Codegen::build`], this does not consume `self`.
///
/// NOTE: you must call [`Codegen::with_source_text`] before calling this method
#[inline]
pub fn print_expression(&mut self, expr: &Expression<'_>) {
expr.print_expr(self, Precedence::Lowest, Context::empty());
Expand Down
Loading