Skip to content

Is there any way to clone or modify ast? #2690

Answered by Boshen
LIMPIX31 asked this question in Q&A
Discussion options

You must be logged in to vote

The transformer mutates the AST, for example

let params = self.ast.formal_parameters(
SPAN,
FormalParameterKind::ArrowFormalParameters,
self.ast.new_vec(),
None,
);
let statements = self.ast.move_statement_vec(&mut block.body);
let function_body =
self.ast.function_body(SPAN, self.ast.new_vec(), statements);
let callee = self.ast.arrow_function_expression(
SPAN,
false,
false,
params,
function_body,
None,
None,
);
let callee = self.ast.parenthesized_expression(SPAN, callee);
let

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LIMPIX31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants