zlataovce / takenaka

A Kotlin library for reconciling multiple obfuscation mapping files from multiple versions of Minecraft: JE.
Apache License 2.0
51 stars 3 forks source link

feat(generator-accessor): naming strategy #39

Closed Misat11 closed 6 months ago

Misat11 commented 7 months ago

This PR provides a way to affect naming of files and symbols generated by the generator-accessor module. This can be done through so called NamingStrategy, an interface which on demand provides names for accessor or mapping classes and for fields representing requested constructors, fields and methods. Three standard implementation have been made, all are part of the StandardNamingStrategies enum and all implements MemberPrefixedNamingStrategy (interface with default methods for naming fields using prefixes FIELD_, CONSTRUCTOR_ and METHOD_). These three variants are:

One small caveat is that the implementation needs to be serializable if we want to use this with the @Input annotation in the Gradle task (thus correctly affecting UP-TO-DATE state). This is okay for our standard naming strategies, since they reside in an enum, which is serializable (at least in the terms of this annotation). Yet from my testing, people cannot use anything else than an enum. As a workaround, one can create an enum of one element, but we probably want to come up with another solution.

Additionally, this PR adds an option to change the location of the generator-accessor-runtime module. This option can be beneficial if one can generate new accessors for already relocated runtime library, for example in addons for a base plugin which relocates the library.

This PR fixes #27