Skip to content

refactor(ast): remove AstKind for Argument#12127

Closed
camchenry wants to merge 16 commits intomainfrom
07-08-refactor_ast_remove_astkind_for_argument_
Closed

refactor(ast): remove AstKind for Argument#12127
camchenry wants to merge 16 commits intomainfrom
07-08-refactor_ast_remove_astkind_for_argument_

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Jul 8, 2025

@github-actions github-actions bot added A-ast Area - AST A-ast-tools Area - AST tools A-formatter Area - Formatter labels Jul 8, 2025
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Jul 8, 2025
@graphite-app graphite-app bot changed the base branch from 07-02-refactor_ast_remove_astkind_for_propertykey_ to graphite-base/12127 July 8, 2025 10:32
@graphite-app graphite-app bot force-pushed the graphite-base/12127 branch from a6abb49 to 8814c53 Compare July 8, 2025 10:44
@graphite-app graphite-app bot force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from b7e73d2 to 85b8071 Compare July 8, 2025 10:44
@graphite-app graphite-app bot changed the base branch from graphite-base/12127 to main July 8, 2025 10:45
@graphite-app graphite-app bot force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from 85b8071 to 4cc3e9b Compare July 8, 2025 10:45
@camchenry camchenry force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from 4cc3e9b to 0b68883 Compare July 9, 2025 01:54
@github-actions github-actions bot added the A-linter Area - Linter label Jul 9, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 9, 2025

CodSpeed Instrumentation Performance Report

Merging #12127 will improve performances by 8.02%

Comparing 07-08-refactor_ast_remove_astkind_for_argument_ (2b6ace7) with main (977d3ba)

Summary

⚡ 3 improvements
✅ 31 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
linter[binder.ts] 146.4 ms 135.5 ms +8.02%
linter[cal.com.tsx] 1.2 s 1.2 s +3.65%
linter[react.development.js] 53.4 ms 50.7 ms +5.32%

@camchenry camchenry force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from 44a04fd to 05beb1f Compare July 9, 2025 03:00
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@camchenry camchenry force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch 2 times, most recently from 75d9b75 to a631204 Compare July 11, 2025 04:06
@camc314 camc314 force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from a631204 to 6c60f26 Compare July 15, 2025 16:48
@overlookmotel
Copy link
Member

overlookmotel commented Jul 16, 2025

Prompted by this PR, me, @camc314, and @Dunqing had a lengthy conversation about whether we should add a new node type to AST CallExpressionArguments.

struct CallExpressionArguments<'a> {
    span: Span,
    arguments: Vec<'a, Argument<'a>>,
}
callee( x, y, z );
//    ^^^^^^^^^^^ CallExpressionArguments

The arguments in favour were:

  • Having AstKind::CallExpressionArguments would be a simple way to answer the question "is this node inside the arguments of a call expression?" (a role which AstKind::Argument was playing up until now). That would simplify this PR a lot.
  • It would store the Span of the arguments, including the ( and ). That would be helpful for attaching comments in codegen and formatter.

The main argument against was:

  • Another AstKind = more AstNodes = perf cost.

There wasn't an obvious answer to the question - we debated back and forth quite a bit. But in the end we concluded:

  1. Probably best to not add CallExpressionArguments AST node for now. We'll only do it later on and take the perf hit if we need to, if it turns out there's a case which cannot be solved without it.
  2. Consider later on adding data to AstNodes which allows not just answering the question "what is the parent of this node?" but also "what property of the parent is this node?" (similar to Ancestor in Traverse). This would allow finding out whether a node is inside the arguments of a call expression without using Spans, and would simplify a lot of other code in the linter. It might also allow us to remove other AstKinds e.g. FormalParameters.

So, in short, conclusion was that the approach this PR is taking is good. We should remove AstKind::Argument and not replace it with anything else. I just wanted to record that we did consider other options, and the reasons why we dismissed them.

@camc314
Copy link
Contributor

camc314 commented Jul 21, 2025

thanks Cam for your work on this.

@ulrichstark or @taearls do either of you fancy picking up and continuing these changes?

@taearls
Copy link
Contributor

taearls commented Jul 21, 2025

thanks Cam for your work on this.

@ulrichstark or @taearls do either of you fancy picking up and continuing these changes?

I'd be happy to take a look once I'm done with #12401!

I'm hoping to have that one ready to review later this week, so I could pick this up after that if it hasn't been taken by then.

@camc314 camc314 force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from 4b0135d to ce60e39 Compare July 24, 2025 17:38
@taearls
Copy link
Contributor

taearls commented Jul 25, 2025

I just opened #12401 for review, so I can start working on this now. Since I can only contribute behind a fork of the oxc repository, I will need to create a separate PR that targets this branch. Is that cool?

I'm not sure if there's a better way to do this. @camc314 @overlookmotel

@camc314
Copy link
Contributor

camc314 commented Jul 25, 2025

yes pleas feel free to take over this branch, and just make a new PR from it. I won't push any new commits

thanks!

@overlookmotel
Copy link
Member

Superceded by #12525.

@overlookmotel overlookmotel deleted the 07-08-refactor_ast_remove_astkind_for_argument_ branch September 7, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-ast-tools Area - AST tools A-formatter Area - Formatter A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants