refactor(ast)!: Remove AstKind for Argument#13902
Conversation
b9c702a to
1d021ce
Compare
CodSpeed Performance ReportMerging #13902 will improve performances by 5.8%Comparing Summary
Benchmarks breakdown
Footnotes |
|
the CI is fully passing now! I still need to take some time to review my own changes, but I think generally this is ready for review now |
206c534 to
3356209
Compare
|
@taearls Sorry this has taken so long to get to, and thanks for constantly keeping the PR updated. We're aiming to (finally) get this merged next week. @camc314 and @Dunqing are reviewing the parts related to linter and formatter respectively, and then I'm going to do a 2nd pass through the whole thing. I'll co-ordinate with them both on Monday. |
hey! I appreciate that a lot. It's all good! I know this is a big change so I can understand that it's harder to prioritize this with everything else that's in flight right now, especially with the formatter. I just rebased onto main earlier today and got the conformance tests to the same baseline as was on main (with some minor improvements!) so it's all ready to go. |
|
Amazing. Thank you. Can I please ask one thing? Could you please rebase onto main (rebase not merge) and squash everything down to a single commit? The list of commits on this page is so long that it's quite hard to find the review comments! |
47d87eb to
ee46d2c
Compare
done! |
e4b038f to
f777c5c
Compare
f777c5c to
9ef5df9
Compare
9ef5df9 to
be22770
Compare
|
@taearls Thank you for your work on this! |
|
Yes, thank you thank you thank you @taearls. I've actually not reviewed yet, but we decided best to just get it merged now before it accrues more merge conflicts, and I'll go through it later this week, and I can make any follow-ups then. |
That makes sense. I'm happy to help! This effort taught me a lot about working with this project, and I feel much more comfortable in it as a whole because of it. Let me know if I can be helpful with any follow-up items. |
…ent` (oxc-project#15675) Revert all changes in the formatter that were introduced in oxc-project#13902, as none of them are the ideal solution for the change in the formatter.
…was removed (oxc-project#15676) Re-fix all cases that are relevant to the change in oxc-project#13902. I've manually checked that the Prettier coverage compatibility has gone back exactly to the state before oxc-project#13902.
Part of #11490
had to open this new PR because #12525 was closed by mistake.
Motivation
AstKind::Argumentwas an architectural inconsistency. The AstKind system is designed for struct types, butArgumentis an enum (SpreadElement | Expression). This created unnecessary complexity in the AST traversal system.Solution
Replace AST-based argument detection with span-based utilities. Instead of traversing the tree to find
AstKind::Argumentnodes, we now use direct span containment checks.New Utilities
Added to
oxc_linter/src/ast_util.rs:Checks if a node is exactly a direct argument to its parent call expression by checking if the parent is a call and the node's span matches one of the argument spans.
Checks if a node is nested within a specific argument at the given index of the provided call expression.
Added to
oxc_ast/src/ast_kind_impl.rs:Checks if this
AstKindis a call expression with an argument matching the given span.Checks if this
AstKindis a call expression whose callee matches the given span.Architecture Change
Before:
After:
Impact
AstKind::Argumentvariant, reducedAST_TYPE_MAXfrom 186 → 185AstKind::Argumentcaused the formatter to make different formatting decisions for arrow functions and object expressions used as arguments, generally producing more compact output (fewer parentheses). Snapshot tests show formatting changes while maintaining Prettier conformance pass rates.Testing
Breaking Changes
None - this is an internal refactoring that doesn't affect public APIs.