Closed
Description
Sometime a Generator
can run 1 or more times on a library. It might want to write some code that should only appear once in the output, regardless of how many elements were run. Potential use cases are utility methods, and (maybe?) imports for standalone builders.
A few ways we could solve this:
- Add an argument to the
Generator.generate
method that has an explicit way to add a utility method and knows it should only add it once. - Make the Generators run more explicitly serially and operate on a
StringBuffer
or similar so they can see previous content and check whether it contains certain strings already. - Change the api
Generator.generate(List<Element> elements, BuildStep buildStep)
and have it run once per library with all elements available together. - Add some sort of 'context' object, maybe a
Map<String, Object>
, which gets passed repeatedly to each Generator and allows it to communicate with itself across elements in the library.
cc @matanlurey
Metadata
Metadata
Assignees
Labels
No labels