Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented Jan 5, 2022

Perform a complete refactoring of the way the SwiftSyntaxBuilder files are generated with the following goals:

  • Move complex Python logic from the .gyb files into proper Python files that are being imported to make the .gyb files more readable
  • Unify the location that the different Buildable, ExpressibleAs etc. types are being generated to reduce the likelihood of making a mistake when generating these types in the .gyb files
  • Reduce the number of extensions being used. All methods of structs should be implemented in the struct itself and all protocols should have a single extension directly underneath it that provides all default conformances. Previously, I was always scanning through the entire code base to find the location one particular method was implement. I think this also makes the result builder methods more discoverable since they are no longer hidden in an extension.
  • Reduce the dependency on gyb_syntax_support by moving protocolMap.py to this repository.

The actual generated source code stays mostly the same, it is just ordered differently and split into multiple files.

@ahoppen
Copy link
Member Author

ahoppen commented Jan 5, 2022

@kimdv Please let me know what you think about this refactoring.

@ahoppen
Copy link
Member Author

ahoppen commented Jan 5, 2022

@swift-ci Please test

Copy link
Contributor

@kimdv kimdv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! 🎉
This is pretty good. Really nice job! 🥳
It was needed!
Just some inline comments/questions 😁

@ahoppen ahoppen force-pushed the pr/refactor-swiftsyntaxbuilder branch from 24392b4 to faa6b1e Compare January 7, 2022 09:38
@ahoppen
Copy link
Member Author

ahoppen commented Jan 7, 2022

@swift-ci Please test

@swiftlang swiftlang deleted a comment from swift-ci Jan 7, 2022
@swiftlang swiftlang deleted a comment from swift-ci Jan 7, 2022
Perform a complete refactoring of the way the `SwiftSyntaxBuilder` files are generated with the following goals:
- Move complex Python logic from the `.gyb` files into proper Python files that are being imported to make the `.gyb` files more readable
- Unify the location that the different `Buildable`, `ExpressibleAs` etc. types are being generated to reduce the likelihood of making a mistake when generating these types in the `.gyb` files
- Reduce the number of extensions being used. All methods of structs should be implemented in the struct itself and all protocols should have a single extension directly underneath it that provides all default conformances. Previously, I was always scanning through the entire code base to find the location one particular method was implement. I think this also makes the result builder methods more discoverable since they are no longer hidden in an extension.
- Reduce the dependency on `gyb_syntax_support` by moving `protocolMap.py` to this repository.

The actual generated source code stays mostly the same, it is just ordered differently and split into multiple files.
@ahoppen ahoppen force-pushed the pr/refactor-swiftsyntaxbuilder branch from faa6b1e to bcb9919 Compare January 7, 2022 10:29
@ahoppen
Copy link
Member Author

ahoppen commented Jan 7, 2022

@swift-ci Please test

Copy link
Contributor

@kimdv kimdv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no further comments!

Really good and impressive work. Nice job 🥳

@swiftlang swiftlang deleted a comment from swift-ci Jan 7, 2022
@swiftlang swiftlang deleted a comment from swift-ci Jan 7, 2022
@ahoppen
Copy link
Member Author

ahoppen commented Jan 7, 2022

Thank you for the good review, Kim.

@ahoppen ahoppen merged commit 8001bbd into swiftlang:main Jan 18, 2022
@ahoppen ahoppen deleted the pr/refactor-swiftsyntaxbuilder branch January 18, 2022 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants