Skip to content

Commit

Permalink
feat(ast): implement From<Argument> for ArrayExpressionElement
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Dec 13, 2024
1 parent d4b8377 commit dd068a3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ impl<'a> Expression<'a> {
matches!(self, Expression::CallExpression(_))
}


#[allow(missing_docs)]
pub fn is_super_call_expression(&self) -> bool {
matches!(self, Expression::CallExpression(expr) if matches!(&expr.callee, Expression::Super(_)))
Expand Down Expand Up @@ -310,6 +311,16 @@ impl ArrayExpressionElement<'_> {
}
}

impl<'a> From<Argument<'a>> for ArrayExpressionElement<'a> {
fn from(argument: Argument<'a>) -> Self {
if let Argument::SpreadElement(spread) = argument {
ArrayExpressionElement::SpreadElement(spread)
} else {
ArrayExpressionElement::from(argument.into_expression())
}
}
}

impl ObjectPropertyKind<'_> {
/// Returns `true` if this object property is a [spread](SpreadElement).
#[inline]
Expand Down

0 comments on commit dd068a3

Please sign in to comment.