mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-22 10:34:51 +01:00
fix: don't call processingEnv before it's initialised
This commit is contained in:
parent
ed70355a86
commit
3f730c69d3
1 changed files with 21 additions and 11 deletions
|
@ -48,7 +48,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
/**
|
/**
|
||||||
* An object representing the various options passed to the processor.
|
* An object representing the various options passed to the processor.
|
||||||
*/
|
*/
|
||||||
public final ProcessorOptions options = new ProcessorOptions(processingEnv);
|
private ProcessorOptions options = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method overriding default implementation to manually pass supported options.
|
* Method overriding default implementation to manually pass supported options.
|
||||||
|
@ -59,6 +59,16 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
return ProcessorOptions.SUPPORTED;
|
return ProcessorOptions.SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link ProcessorOptions} for this instance, creating the object if
|
||||||
|
* it hasn't been already.
|
||||||
|
* @return the {@link ProcessorOptions} for this instance
|
||||||
|
*/
|
||||||
|
public ProcessorOptions getProcessorOptions() {
|
||||||
|
if(this.options == null) this.options = new ProcessorOptions(this.processingEnv);
|
||||||
|
return this.options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where the actual processing happens.
|
* Where the actual processing happens.
|
||||||
* It filters through whatever annotated class it's fed, and checks whether it contains
|
* It filters through whatever annotated class it's fed, and checks whether it contains
|
||||||
|
@ -90,7 +100,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.options.noServiceProvider && !this.injectors.isEmpty()) {
|
if (!this.getProcessorOptions().noServiceProvider && !this.injectors.isEmpty()) {
|
||||||
generateServiceProvider();
|
generateServiceProvider();
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
|
@ -134,7 +144,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
//find class information
|
//find class information
|
||||||
Patch patchAnn = cl.getAnnotation(Patch.class);
|
Patch patchAnn = cl.getAnnotation(Patch.class);
|
||||||
ClassContainer targetClass = ClassContainer.from(
|
ClassContainer targetClass = ClassContainer.from(
|
||||||
patchAnn, Patch::value, patchAnn.innerName(), this.options
|
patchAnn, Patch::value, patchAnn.innerName(), this.getProcessorOptions()
|
||||||
);
|
);
|
||||||
//find package information
|
//find package information
|
||||||
Element packageElement = cl.getEnclosingElement();
|
Element packageElement = cl.getEnclosingElement();
|
||||||
|
@ -165,10 +175,10 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
if(type == ProxyType.TYPE) {
|
if(type == ProxyType.TYPE) {
|
||||||
//find and validate
|
//find and validate
|
||||||
ClassContainer clazz = ClassContainer.findOrFallback(
|
ClassContainer clazz = ClassContainer.findOrFallback(
|
||||||
ClassContainer.from(cl, this.options),
|
ClassContainer.from(cl, this.getProcessorOptions()),
|
||||||
patchAnn,
|
patchAnn,
|
||||||
proxyVar.getAnnotation(Find.class),
|
proxyVar.getAnnotation(Find.class),
|
||||||
this.options
|
this.getProcessorOptions()
|
||||||
);
|
);
|
||||||
//types can be generated with a single instruction
|
//types can be generated with a single instruction
|
||||||
constructorBuilder.addStatement(
|
constructorBuilder.addStatement(
|
||||||
|
@ -184,7 +194,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
constructorBuilder,
|
constructorBuilder,
|
||||||
this.options
|
this.getProcessorOptions()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +253,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
matchedInjectors.add(injector);
|
matchedInjectors.add(injector);
|
||||||
toGenerate.put(
|
toGenerate.put(
|
||||||
String.format("%sInjector%d", cl.getSimpleName(), iterationNumber),
|
String.format("%sInjector%d", cl.getSimpleName(), iterationNumber),
|
||||||
new InjectorInfo(injector, tg, targetAnn, this.options)
|
new InjectorInfo(injector, tg, targetAnn, this.getProcessorOptions())
|
||||||
);
|
);
|
||||||
iterationNumber++; //increment is only used by injectors
|
iterationNumber++; //increment is only used by injectors
|
||||||
} else {
|
} else {
|
||||||
|
@ -255,7 +265,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
tg,
|
tg,
|
||||||
targetAnn,
|
targetAnn,
|
||||||
constructorBuilder,
|
constructorBuilder,
|
||||||
this.options
|
this.getProcessorOptions()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,9 +290,9 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
.addMethod(constructorBuilder.build())
|
.addMethod(constructorBuilder.build())
|
||||||
.addMethod(buildStringReturnMethod("name", injName))
|
.addMethod(buildStringReturnMethod("name", injName))
|
||||||
.addMethod(buildStringReturnMethod("reason", toGenerate.get(injName).reason))
|
.addMethod(buildStringReturnMethod("reason", toGenerate.get(injName).reason))
|
||||||
.addMethod(buildStringReturnMethod("targetClass", this.options.obfuscateInjectorMetadata ? targetClass.fqnObf : targetClass.fqn))
|
.addMethod(buildStringReturnMethod("targetClass", this.getProcessorOptions().obfuscateInjectorMetadata ? targetClass.fqnObf : targetClass.fqn))
|
||||||
.addMethod(buildStringReturnMethod("methodName", this.options.obfuscateInjectorMetadata ? target.nameObf : target.name))
|
.addMethod(buildStringReturnMethod("methodName", this.getProcessorOptions().obfuscateInjectorMetadata ? target.nameObf : target.name))
|
||||||
.addMethod(buildStringReturnMethod("methodDesc", this.options.obfuscateInjectorMetadata ? target.descriptorObf : target.descriptor))
|
.addMethod(buildStringReturnMethod("methodDesc", this.getProcessorOptions().obfuscateInjectorMetadata ? target.descriptorObf : target.descriptor))
|
||||||
.addMethods(generateDummies(cl))
|
.addMethods(generateDummies(cl))
|
||||||
.addMethod(generateInjector(toGenerate.get(injName), this.processingEnv))
|
.addMethod(generateInjector(toGenerate.get(injName), this.processingEnv))
|
||||||
.build();
|
.build();
|
||||||
|
|
Loading…
Reference in a new issue