aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/processor/tools
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-03-18 20:08:16 +0100
committer zaaarf <zaaarf@proton.me>2023-03-18 20:08:16 +0100
commit1f0db874780948f4483845284a2c5b57a0f2df4e (patch)
treee1d8c0918c0f275144862e60bf8a4b14c8ce528e /src/main/java/ftbsc/lll/processor/tools
parent9f9a9d9324d4941b57c204c9d06ca5771fc5a04f (diff)
fix: restored isPrimitive() check before converting to string
Diffstat (limited to 'src/main/java/ftbsc/lll/processor/tools')
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/JavaPoetUtils.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/lll/processor/tools/JavaPoetUtils.java b/src/main/java/ftbsc/lll/processor/tools/JavaPoetUtils.java
index fe64488..51f058b 100644
--- a/src/main/java/ftbsc/lll/processor/tools/JavaPoetUtils.java
+++ b/src/main/java/ftbsc/lll/processor/tools/JavaPoetUtils.java
@@ -2,6 +2,8 @@ package ftbsc.lll.processor.tools;
import com.squareup.javapoet.*;
import ftbsc.lll.tools.DescriptorBuilder;
+import ftbsc.lll.proxies.MethodProxy;
+import ftbsc.lll.proxies.FieldProxy;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
@@ -109,4 +111,28 @@ public class JavaPoetUtils {
sb.append(")");
return sb.toString();
}
+
+ /**
+ * Adds to the given {@link MethodSpec.Builder} the given line of code,
+ * containing a call to a method of a {@link MethodProxy.Builder} or a
+ * {@link FieldProxy.Builder}.
+ * @param b the {@link MethodSpec.Builder}
+ * @param proxyBuilderName the name of the proxy builder
+ * @param proxyBuilderMethod the method to call
+ * @param t the {@link TypeMirror} to add
+ * @since 0.4.0
+ */
+ public static void addTypeToProxyGenerator(MethodSpec.Builder b, String proxyBuilderName, String proxyBuilderMethod, TypeMirror t) {
+ String insn = String.format("%s.%s", proxyBuilderName, proxyBuilderMethod);
+ if(t.getKind().isPrimitive())
+ b.addStatement(insn + "($T.class)", t);
+ else {
+ ArrayContainer arr = new ArrayContainer(t);
+ b.addStatement(
+ insn + "($S, $L)",
+ arr.innermostComponent,
+ arr.arrayLevel
+ );
+ }
+ }
}