mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-14 17:49:19 +01:00
fix: restored isPrimitive() check before converting to string
This commit is contained in:
parent
9f9a9d9324
commit
1f0db87478
2 changed files with 30 additions and 18 deletions
|
@ -341,24 +341,10 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
if(isMethod) {
|
if(isMethod) {
|
||||||
ExecutableElement targetMethod = (ExecutableElement) target;
|
ExecutableElement targetMethod = (ExecutableElement) target;
|
||||||
for(VariableElement p : targetMethod.getParameters()) {
|
for(VariableElement p : targetMethod.getParameters())
|
||||||
ArrayContainer param = new ArrayContainer(p.asType());
|
addTypeToProxyGenerator(b, "bd", "addParameter", p.asType());
|
||||||
b.addStatement(
|
addTypeToProxyGenerator(b, "bd", "setReturnType", targetMethod.getReturnType());
|
||||||
"bd.addParameter($S, $L)",
|
} else addTypeToProxyGenerator(b, "bd", "setType", target.asType());
|
||||||
param.innermostComponent,
|
|
||||||
param.arrayLevel
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ArrayContainer ret = new ArrayContainer(targetMethod.getReturnType());
|
|
||||||
b.addStatement(
|
|
||||||
"bd.setReturnType($S, $L)",
|
|
||||||
ret.innermostComponent,
|
|
||||||
ret.arrayLevel
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ArrayContainer arr = new ArrayContainer(target.asType());
|
|
||||||
b.addStatement("bd.setType($S, $L)", arr.innermostComponent, arr.arrayLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
b.addStatement("return bd.build()");
|
b.addStatement("return bd.build()");
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ package ftbsc.lll.processor.tools;
|
||||||
|
|
||||||
import com.squareup.javapoet.*;
|
import com.squareup.javapoet.*;
|
||||||
import ftbsc.lll.tools.DescriptorBuilder;
|
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.ExecutableElement;
|
||||||
import javax.lang.model.element.Modifier;
|
import javax.lang.model.element.Modifier;
|
||||||
|
@ -109,4 +111,28 @@ public class JavaPoetUtils {
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
return sb.toString();
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue