Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ast): add AstBulder::move_property_key #7998

Merged
merged 1 commit into from
Dec 18, 2024
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
6 changes: 6 additions & 0 deletions crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ impl<'a> AstBuilder<'a> {
mem::replace(target, dummy.into())
}

/// Moves the property key out by replacing it with a [`PropertyKey::NullLiteral`].
pub fn move_property_key(self, key: &mut PropertyKey<'a>) -> PropertyKey<'a> {
let null_expr = PropertyKey::from(self.expression_null_literal(SPAN));
mem::replace(key, null_expr)
}

/// Move a declaration out by replacing it with an empty [`Declaration::VariableDeclaration`].
#[inline]
pub fn move_declaration(self, decl: &mut Declaration<'a>) -> Declaration<'a> {
Expand Down
Loading