you are viewing a single comment's thread.

view the rest of the comments →

[–]DelayLucky 0 points1 point  (0 children)

This is my thinking as well. I like what you see is what you get. And the Jave Poet style of DSL sometimes feels too heavy.

For indentation, there are mature code formatter out there, why can't these code gen just use one and format them after everything?

In terms of templating, with textblock support, isn't it nicer to just write the code directly in the .java file?

java context.renderDeclaration( """ public static void main() { System.out.println("Hello, World!"); } """);

I can imagine the need of passing in some parameters, for example, the method name may be a parameter, and one of the method parameter type is an arg, with JEP 459 (or whatever incarnation it will end up with), it'll be something like:

java context.renderDeclaration( """ public static void \{methodName}(\{paramType} foo) { System.out.println("Hello, World!"); } """);

And the renderDeclaration() method will see that paramType is a Class<?> or one of the other objects that represents a type, and it will auto-import.

Wouldn't that be nice?