Skip to content

Commit

Permalink
Class model and builder generation reworked (#7256)
Browse files Browse the repository at this point in the history
Class model and builder generator rework

Signed-off-by: David Kral <[email protected]>
  • Loading branch information
Verdent authored Aug 16, 2023
1 parent 97735c1 commit 66ca33e
Show file tree
Hide file tree
Showing 85 changed files with 7,177 additions and 2,945 deletions.
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@
<artifactId>helidon-common-processor-helidon-copyright</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.common.processor</groupId>
<artifactId>helidon-common-processor-class-model</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.common.testing</groupId>
<artifactId>helidon-common-testing-junit5</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions builder/processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.common.processor</groupId>
<artifactId>helidon-common-processor-class-model</artifactId>
</dependency>
</dependencies>

<build>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static io.helidon.builder.processor.Types.FACTORY_METHOD_TYPE;
import static io.helidon.builder.processor.Types.PROTOTYPE_CUSTOM_METHOD_TYPE;
import static io.helidon.builder.processor.Types.VOID_TYPE;
import static io.helidon.common.processor.classmodel.ClassModel.TYPE_TOKEN;

record CustomMethods(List<CustomMethod> factoryMethods,
List<CustomMethod> builderMethods,
Expand Down Expand Up @@ -101,7 +102,10 @@ private static GeneratedMethod prototypeMethod(Errors.Collector errors,
// return CustomMethodsType.methodName(this, param1, param2)
String generatedCall =
VOID_TYPE.equals(customMethod.returnType) ? "" : "return "
+ customMethodsType.genericTypeName().fqName() + "."
+ TYPE_TOKEN
+ customMethodsType.genericTypeName().fqName()
+ TYPE_TOKEN
+ "."
+ customMethod.name()
+ "("
+ String.join(", ", argumentNames)
Expand Down Expand Up @@ -146,12 +150,15 @@ private static GeneratedMethod builderMethod(Errors.Collector errors,
.toList());

// return CustomMethodsType.methodName(this, param1, param2)
String generatedCall = customMethodsType.genericTypeName().fqName() + "."
String generatedCall = TYPE_TOKEN
+ customMethodsType.genericTypeName().fqName()
+ TYPE_TOKEN
+ "."
+ customMethod.name()
+ "("
+ String.join(", ", argumentNames)
+ ");"
+ " return self()";
+ "\nreturn self()";

return new GeneratedMethod(
new Method(typeInformation.prototypeBuilder(),
Expand Down Expand Up @@ -192,7 +199,10 @@ private static GeneratedMethod factoryMethod(Errors.Collector errors,
// if returns: return CustomMethodsType.methodName(param1, param2)
String generatedCall =
VOID_TYPE.equals(customMethod.returnType) ? "" : "return "
+ customMethodsType.genericTypeName().fqName() + "."
+ TYPE_TOKEN
+ customMethodsType.genericTypeName().fqName()
+ TYPE_TOKEN
+ "."
+ customMethod.name()
+ "("
+ customMethod.arguments().stream().map(Argument::name).collect(Collectors.joining(", "))
Expand Down
Loading

0 comments on commit 66ca33e

Please sign in to comment.