From 63a95e4aa2ba15aa03df83425337354e5bec2d5f Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:17:54 +0000 Subject: [PATCH] feat(ast): add `AstBulder::move_property_key` (#7998) Add `AstBuilder::move_property_key` method, same as the rest of `move_*` methods. --- crates/oxc_ast/src/ast_builder_impl.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/oxc_ast/src/ast_builder_impl.rs b/crates/oxc_ast/src/ast_builder_impl.rs index f1532b052083b..7ea077656e4ca 100644 --- a/crates/oxc_ast/src/ast_builder_impl.rs +++ b/crates/oxc_ast/src/ast_builder_impl.rs @@ -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> {