-
-
Notifications
You must be signed in to change notification settings - Fork 420
Improve the init buildgen code resolving some TODOs
#5866
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: ShreckYe <[email protected]>
… object declaration, add overrides Co-authored-by: ShreckYe <[email protected]>
…make the name clearer
…tps://github.com/ShreckYe/mill into copilot/fix-9475931d-2457-49c4-9a71-fd7144c9d4ef
…`java` plugin applied in Gradle too` and replace some Yoda conditions
…71-fd7144c9d4ef Convert generic type parameters to abstract type members in BuildGenBase.scala
Achieved by replacing `null ([=!]=) (\w+)` with `$2 $1 null` using regex.
Prompt: ```text Find and replace all Yoda conditions using regex. ```
…g' into improve-init-guildgen
…nto improve-init-guildgen
…-members' into improve-init-guildgen
…odo' into improve-init-guildgen
…of `IrBaseInfo` with `Option[IrBaseInfo]` The original name `IrTrait` looks too broad.
…ldGenMain` and refactor `getBaseInfo` to retrieve `buildExport.projects` directly
| type M | ||
| type D | ||
| type I | ||
| type C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have more descriptive names here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they are respectively Module, Dependency, Input, and Config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also just noticed that D/Dependency is no longer used in the current implementation. Shall I remove it or just keep it for possible use and better readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's unused, remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed D and renamed M and I. C is kept as renaming it would conflict with the Config nested classes. I guess it can be renamed to something like ConfigT if needed, but I am not sure whether this is conventional in Scala.
Consolidated follow-ups of #4586.
A summary of changes:
rename
ConfigtoMavenAndGradleCommonConfiginBuildGenUtilto make it clearerrename
optionalinBuildGenUtiltorenderIfArgsNonEmptyto make it more consistent with the other function namesremove
moduleOptionTreeinBuildGenBase.convertwhich seems redundantconvert generic type parameters to abstract type members for
BuildGenBaseand its subtypesAlso see the TODO comment which is resolved and removed and https://github.com/com-lihaoyi/mill/pull/4586/files#r1970795027. As these types
M,D, andIare only used in the trait and its subtypes, I think parameterization is not needed here, so replacing these type parameters with type members make them more readable and also consistent with the type memberC.remove some TODOs of slight significance without resolving them and convert some into ordinary comments
replace Yoda conditions
rename
IrBuildtoIrModuleBuildRename
IrTraittoIrBaseInfoand replace the original references ofIrBaseInfowithOption[IrBaseInfo]The original name
IrTraitseems too broad and is not very readable.rename
extractScopedDepstoextractConfigurationDepsinGradleBuildGenMainChange
Ito(BuildExport, Tree[Node[Option[Project]]])inSbtBuildGenMainand refactorgetBaseInfoto retrievebuildExport.projectsdirectlySee the resolved and removed TODOs for more detailed explanations of the changes. Also see the added TODO comments showing some alternative renaming options and remove them before merging.