-
-
Notifications
You must be signed in to change notification settings - Fork 457
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
transformer: general helper for insert, delete and replace statement #6993
Comments
Why is a helper needed for replacement? |
As I mentioned above cases, we need to replace a statement with multiple statements. If just one-to-one replacement, we can mutate the original statement directly |
replace -> splice |
Isn't "replace 1 statement with 3 statements" equivalent to "mutate existing statement + insert 2 new statements after it"? (like in your example) So then do we need the "replace" action? Is there a reason why that's unergonomic? 2nd point: "Delete" action doesn't necessarily need an
I can't imagine a situation where a transform actually needs to insert a real Note: Ideal pattern if you're going to delete statements is to do it as early as possible, so then other transforms don't spend time traversing and transforming code which is going to be deleted anyway. Note2: |
Now, we have
StatementInjection
to help us inject statements, this is very useful but is not enough for our usage. So would be better if we combine these usages into one statement helperCases
Delete
oxc/crates/oxc_transformer/src/typescript/annotations.rs
Lines 425 to 440 in 1d41cee
Replace
oxc/crates/oxc_transformer/src/es2018/async_generator_functions/mod.rs
Lines 123 to 133 in 1d41cee
The text was updated successfully, but these errors were encountered: