fix: injector generated correctly

This commit is contained in:
zaaarf 2023-04-13 11:12:41 +02:00
parent f1c413eb2d
commit a259d844a3
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C

View file

@ -151,27 +151,20 @@ public class JavaPoetUtils {
MethodSpec.Builder injectBuilder = MethodSpec.methodBuilder("inject")
.addModifiers(Modifier.PUBLIC)
.returns(void.class)
.addAnnotation(Override.class);
int argumentCount = inj.injector.getParameters().size();
if(argumentCount == 2) {
injectBuilder
.addParameter(ParameterSpec.builder(
TypeName.get(env
.getElementUtils()
.getTypeElement("org.objectweb.asm.tree.ClassNode").asType()), "clazz")
.build());
}
injectBuilder
.addAnnotation(Override.class)
.addParameter(ParameterSpec.builder(
TypeName.get(env
.getElementUtils()
.getTypeElement("org.objectweb.asm.tree.ClassNode").asType()), "clazz")
.build())
.addParameter(ParameterSpec.builder(
TypeName.get(env
.getElementUtils()
.getTypeElement("org.objectweb.asm.tree.MethodNode").asType()), "main")
.build());
if(argumentCount == 2) injectBuilder.addStatement("super.$L(clazz, main)", inj.injector.getSimpleName());
if(inj.injector.getParameters().size() == 2)
injectBuilder.addStatement("super.$L(clazz, main)", inj.injector.getSimpleName());
else injectBuilder.addStatement("super.$L(main)", inj.injector.getSimpleName());
return injectBuilder.build();