Skip to content
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

feat(ast_codegen): add ImplGetSpanGenerator. #3852

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

rzvxa
Copy link
Contributor

@rzvxa rzvxa commented Jun 23, 2024

This one is ready to replace the handwritten module.

Copy link

graphite-app bot commented Jun 23, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

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

Copy link

codspeed-hq bot commented Jun 23, 2024

CodSpeed Performance Report

Merging #3852 will not alter performance

Comparing 06-23-feat_ast_codegen_add_implgetspangenerator_ (09f4d3c) with main (f6c4ec4)

Summary

✅ 28 untouched benchmarks

@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from 2f010c1 to 835e59c Compare June 23, 2024 15:32
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 1786d34 to c9606fd Compare June 23, 2024 15:32
@github-actions github-actions bot added the A-ast Area - AST label Jun 23, 2024
@rzvxa rzvxa requested review from Boshen and overlookmotel June 23, 2024 15:58
@Boshen Boshen force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from 835e59c to 743f631 Compare June 23, 2024 16:05
@Boshen Boshen force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from c6e2ae1 to ccf8ff8 Compare June 23, 2024 16:05
@overlookmotel
Copy link
Contributor

overlookmotel commented Jun 23, 2024

A couple of small things:

Can we add #[inline] on all the fn spans for structs? Probably they'll be inlined anyway, but we should make sure. NB: Probably shouldn't #[inline] the functions for enums, as they're more complex.

Is there any way to add line breaks between the impls so the generated code is easier to read? I remember seeing other codegens use a crate which pretty-prints syn output (though I can't remember what it's called).

Update 24/6/24: The crate I was thinking of is prettyplease. #3815 is using it, but it doesn't solve line breaks.

@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from 743f631 to 317fd6b Compare June 24, 2024 11:41
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch 4 times, most recently from 88c536c to 283b3c4 Compare June 24, 2024 14:52
@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from 8aeafe1 to 1e5964c Compare June 24, 2024 14:55
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 283b3c4 to e402485 Compare June 24, 2024 14:55
@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from 1e5964c to 8c3a170 Compare June 24, 2024 14:58
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from e402485 to fc5e589 Compare June 24, 2024 14:58
@rzvxa rzvxa marked this pull request as ready for review June 24, 2024 14:59
@rzvxa rzvxa requested a review from overlookmotel June 24, 2024 15:00
@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from 8c3a170 to f014d23 Compare June 24, 2024 15:29
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 3c67fc9 to 59eaebe Compare June 24, 2024 15:29
@rzvxa
Copy link
Contributor Author

rzvxa commented Jun 24, 2024

@overlookmotel You can go ahead and review it. Let me know if there is anything ambiguous that needs to be addressed.

@overlookmotel
Copy link
Contributor

@overlookmotel You can go ahead and review it. Let me know if there is anything ambiguous that needs to be addressed.

To be honest, I don't follow everything you're doing here. As discussed, I think it'd be simpler if we purely used the DefType types as the source for generation. But if the tests pass, let's go with it!

@overlookmotel
Copy link
Contributor

@Boshen unless you have any comments, this one is ready to merge I think.

@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from f014d23 to d22b9d0 Compare June 25, 2024 09:02
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 6b7bd27 to 7c0c756 Compare June 25, 2024 09:02
@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from d22b9d0 to b6e7c2b Compare June 25, 2024 09:30
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 7c0c756 to 5a51be3 Compare June 25, 2024 09:31
@Boshen Boshen force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from b6e7c2b to 47b89bd Compare June 25, 2024 09:47
@Boshen Boshen force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 5a51be3 to f0b7a57 Compare June 25, 2024 09:48
@overlookmotel
Copy link
Contributor

As discussed in #3900 (comment), it'd be preferable in my view to remove the "special case" code for BindingPattern from the codegen, and use a #[span] attr in AST type to indicate what needs to happen to codegen.

But am really keen to start getting this stack merged, so let's not change it now. Merge without further churn, and then go back and change it in a later PR.

@rzvxa rzvxa force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from 47b89bd to e7b0225 Compare June 25, 2024 10:36
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from f0b7a57 to 9c7d50f Compare June 25, 2024 10:36
Copy link

graphite-app bot commented Jun 25, 2024

Merge activity

  • Jun 25, 9:54 AM EDT: Boshen added this pull request to the Graphite merge queue.
  • Jun 25, 10:00 AM EDT: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Check Unused Dependencies').
  • Jun 25, 10:39 AM EDT: rzvxa added this pull request to the Graphite merge queue.
  • Jun 25, 10:43 AM EDT: rzvxa merged this pull request with the Graphite merge queue.

@Boshen Boshen force-pushed the 06-22-feat_ast_gen_add_ast_code_gen branch from e7b0225 to f6c4ec4 Compare June 25, 2024 13:55
Boshen pushed a commit that referenced this pull request Jun 25, 2024
This one is ready to replace the handwritten module.
@Boshen Boshen force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 9c7d50f to 6a51f3c Compare June 25, 2024 13:55
@Boshen Boshen changed the base branch from 06-22-feat_ast_gen_add_ast_code_gen to main June 25, 2024 13:59
This one is ready to replace the handwritten module.
@rzvxa rzvxa force-pushed the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch from 3de2494 to 09f4d3c Compare June 25, 2024 14:39
@graphite-app graphite-app bot merged commit 09f4d3c into main Jun 25, 2024
24 checks passed
@graphite-app graphite-app bot deleted the 06-23-feat_ast_codegen_add_implgetspangenerator_ branch June 25, 2024 14:43
@github-actions github-actions bot mentioned this pull request Jun 26, 2024
Boshen added a commit that referenced this pull request Jun 27, 2024
## [0.16.0] - 2024-06-26

- 6796891 ast: [**BREAKING**] Rename all instances of `BigintLiteral` to
`BigIntLiteral`. (#3898) (rzvxa)

- 1f85f1a ast: [**BREAKING**] Revert adding `span` field to the
`BindingPattern` type. (#3899) (rzvxa)

- ae09a97 ast: [**BREAKING**] Remove `Modifiers` from ts nodes (#3846)
(Boshen)

- 1af5ed3 ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`const` on `EnumDeclaration` (#3845) (Boshen)

- 0673677 ast: [**BREAKING**] Replace `Modifiers` with `declare` on
`Function` (#3844) (Boshen)

- ee6ec4e ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`abstract` on `Class` (#3841) (Boshen)

- 9b38119 ast: [**BREAKING**] Replace `Modifiers` with `declare` on
`VariableDeclaration` (#3839) (Boshen)

- cfcef24 ast: [**BREAKING**] Add `directives` field to `TSModuleBlock`
(#3830) (Boshen)

- 4456034 ast: [**BREAKING**] Add `IdentifierReference` to
`ExportSpecifier` (#3820) (Boshen)

### Features

- 497769c ast: Add some visitor functions (#3785) (Dunqing)
- 4b06dc7 ast: Add TSType::TSIntrinsicKeyword to is_keyword (#3775)
(Dunqing)
- 5847e16 ast,parser: Add `intrinsic` keyword (#3767) (Boshen)
- 2e026e1 ast_codegen: Generate `ast_kind.rs`. (#3888) (rzvxa)
- 09f4d3c ast_codegen: Add `ImplGetSpanGenerator`. (#3852) (rzvxa)
- 3e78f98 cfg: Add depth first search with hash sets. (#3771) (rzvxa)
- 01da2f7 codegen: Print TSThisParameter for TSCallSignatureDeclaration
and TSMethodSignature (#3792) (Dunqing)
- 2821e0e codegen: Print readonly keyword for TSIndexSignature (#3791)
(Dunqing)
- 97575d8 codegen: Print TSClassImplements and TSThisParameter (#3786)
(Dunqing)
- 5e2baf3 isolated-declarations: Report error for expando functions
(#3872) (Dunqing)
- 2cdb34f isolated-declarations: Support for class function overloads
(#3811) (Dunqing)
- 231b8f0 isolated-declarations: Support for export default function
overloads (#3809) (Dunqing)
- a37138f isolated-declarations: Improve the inference template literal
(#3797) (Dunqing)
- b0d7355 isolated-declarations: Transform const expression correctly
(#3793) (Dunqing)
- b38c34d isolated-declarations: Support inferring
ParenthesizedExpression (#3769) (Dunqing)
- 4134de8 isolated-declarations: Add ts error code to the error message
(#3755) (Dunqing)
- 94202de isolated-declarations: Add `export {}` when needed (#3754)
(Dunqing)
- e95d8e3 isolated-declarations: Shrink span for arrow function that
needs an explicit return type (#3752) (Dunqing)
- df9971d isolated-declarations: Improve inferring the return type from
function (#3750) (Dunqing)
- 4aea2b1 isolated-declarations: Improve inferring the type of accessor
(#3749) (Dunqing)
- 9ea30c4 isolated-declarations: Treat AssignmentPattern as optional
(#3748) (Dunqing)
- dd540c8 minifier: Add skeleton for ReplaceGlobalDefines ast pass
(#3803) (Boshen)
- f3c3970 minifier: Add skeleton for RemoveDeadCode ast pass (#3802)
(Boshen)
- 4fb90eb oxc: Export isolated-declarations (#3765) (Boshen)
- d5f6aeb semantic: Check for illegal symbol modifiers (#3838) (Don
Isaac)
- 01572f0 sourcemap: Impl `std::fmt::Display` for `Error` (#3902)
(DonIsaac)
- 5501d5c transformer/typescript: Transform `import {} from "mod"` to
import `"mod"` (#3866) (Dunqing)
- 2a16ce0 traverse: Disable syntax check and disable build module record
(#3794) (Boshen)- d3cd3ea Oxc transform binding (#3896) (underfin)

### Bug Fixes

- 063cfde ast: Correct JSON serialization of `TSModuleBlock` (#3858)
(overlookmotel)
- 66f404c ast: Fix JSON serialization of `BindingPattern` (#3856)
(overlookmotel)
- 2766594 codegen: Print type parameters for MethodDefinition (#3922)
(Dunqing)
- 27f0531 isolated-declarations: Private constructor reaching
unreachable (#3921) (Dunqing)
- 59ce38b isolated-declarations: Inferring of UnrayExpression
incorrectly (#3920) (Dunqing)
- 58e54f4 isolated-declarations: Report an error for parameters if they
are ObjectPattern or ArrayPattern without an explicit type (#3810)
(Dunqing)
- cb8a272 isolated-declarations: Cannot infer nested `as const` (#3807)
(Dunqing)
- d8ecce5 isolated-declarations: Infer BigInt number as `bigint` type
(#3806) (Dunqing)
- 4e241fc isolated-declarations: Missing `const` after transformed const
enum (#3805) (Dunqing)
- 683c7b0 isolated-declarations: Shouldn’t add declare in declaration
with export default (#3804) (Dunqing)
- 7d47fc3 isolated-declarations: Should stripe async and generator
keyword after transformed (#3790) (Dunqing)
- 8ce794d isolated-declarations: Inferring an incorrect return type when
there is an arrow function inside a function (#3768) (Dunqing)
- d29316a isolated-declarations: Transform incorrectly when there are
multiple functions with the same name (#3753) (Dunqing)
- bf1c250 isolated-declarations: False positives for non-exported
binding elements (#3751) (Dunqing)
- 275349a parser: Parse function type parameter name `accessor` (#3926)
(Boshen)
- ef82c78 parser: Trailing comma is not allowed in
ParenthesizedExpression (#3885) (Dunqing)
- 13754cb parser: Change diagnostic to "modifier cannot be used here"
(#3853) (Boshen)
- 8c9fc63 semantic: Apply strict mode scope flag for strict mode TS
Modules (#3861) (overlookmotel)
- 99a40ce semantic: `export default foo` should have
`ExportLocalName::Default(NameSpan)` entry (#3823) (Boshen)
- 08fcfb3 transformer: Fix spans and scopes in TS enum transform (#3911)
(overlookmotel)
- 17ad8f7 transformer: Create new scopes for new blocks in TS transform
(#3908) (overlookmotel)
- d76f34b transformer: TODO comments for missing scopes (#3837)
(overlookmotel)
- e470731 transformer: TS transform handle when type exports first
(#3833) (overlookmotel)
- d774e54 transformer: TS transform generate do not copy statements
(#3832) (overlookmotel)
- ff1da27 transformer: Correct comment in example (#3831)
(overlookmotel)
- 6dcc3f4 transformer: Fix TS annotation transform scopes (#3816)
(overlookmotel)
- aea3e9a transformer: Correct spans for TS annotations transform
(#3782) (overlookmotel)

### Performance

- 92c21b2 diagnostics: Optimize string-buffer reallocations (#3897)
(Luca Bruno)
- 4bf405d parser: Add a few more inline hints to cursor functions
(#3894) (Boshen)
- 10d1de5 semantic: Remove uneccessary allocation in builder (#3867)
(DonIsaac)- 4f7ff7e Do not pass `&Atom` to functions (#3818)
(overlookmotel)

### Refactor

- 6f26087 ast: Add comment about alternatives to `AstBuilder::copy`
(#3905) (overlookmotel)
- 442aca3 ast: Add comment not to use `AstBuilder::copy` (#3891)
(overlookmotel)
- acf69fa ast: Refactor custom `Serialize` impls (#3859) (overlookmotel)
- 9e148e9 ast: Add line breaks (#3860) (overlookmotel)
- 363d3d5 ast: Add span field to the `BindingPattern` type. (#3855)
(rzvxa)
- a648748 ast: Shorten code in AST builder (#3835) (overlookmotel)
- 1206967 ast: Reduce allocations in AST builder (#3834) (overlookmotel)
- 2f5d50e isolated-declarations: Remove `Modifiers` (#3847) (Boshen)
- 8027b1e minifier: Change prepass to ast_passes::remove_parens (#3801)
(Boshen)
- a471e62 parser: Clean up `try_parse` (#3925) (Boshen)
- 3db2553 parser: Improve parsing of TypeScript type arguments (#3923)
(Boshen)
- 4cf3c76 parser: Improve parsing of TypeScript types (#3903) (Boshen)
- 187f078 parser: Improve parsing of
`parse_function_or_constructor_type` (#3892) (Boshen)
- 97d59fc parser: Move code around for parsing `Modifiers` (#3849)
(Boshen)
- 5ef28b7 transformer: Shorten code (#3912) (overlookmotel)
- d9f268d transformer: Shorten TS transform code (#3836) (overlookmotel)
- 21b0d01 transformer: Pass ref to function (#3781) (overlookmotel)
- 7c44703 transformer: Remove needless `pub` on TS enum transform
methods (#3774) (overlookmotel)
- 22c56d7 transformer: Move TSImportEqualsDeclaration transform code
(#3764) (overlookmotel)
- cd56aa9 transformer: Simplify TS export assignment transform (#3762)
(overlookmotel)
- 512740d transformer: Move and simplify TS enum transform entry point
(#3760) (overlookmotel)
- 1061baa traverse: Separate `#[scope]` attr (#3901) (overlookmotel)
- fcd21a6 traverse: Indicate scope entry point with
`scope(enter_before)` attr (#3882) (overlookmotel)
- 24979c9 traverse: Use camel case props internally (#3880)
(overlookmotel)
- 2045c92 traverse: Improve parsing attrs in traverse codegen (#3879)
(overlookmotel)- d6437fe Clean up some usages of `with_labels` (#3854)
(Boshen)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants