mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-22 15:04:50 +01:00
fix: added obfuscateInjectorMetadata arg
This commit is contained in:
parent
d451cc3460
commit
cc22e84eb7
1 changed files with 18 additions and 10 deletions
|
@ -40,7 +40,7 @@ import static ftbsc.lll.processor.tools.JavaPoetUtils.*;
|
||||||
*/
|
*/
|
||||||
@SupportedAnnotationTypes("ftbsc.lll.processor.annotations.Patch")
|
@SupportedAnnotationTypes("ftbsc.lll.processor.annotations.Patch")
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||||
@SupportedOptions({"mappingsFile", "badPracticeWarnings", "anonymousClassWarning"})
|
@SupportedOptions({"mappingsFile", "badPracticeWarnings", "anonymousClassWarning", "obfuscateInjectorMetadata"})
|
||||||
public class LilleroProcessor extends AbstractProcessor {
|
public class LilleroProcessor extends AbstractProcessor {
|
||||||
/**
|
/**
|
||||||
* A {@link Set} of {@link String}s that will contain the fully qualified names
|
* A {@link Set} of {@link String}s that will contain the fully qualified names
|
||||||
|
@ -66,6 +66,12 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
*/
|
*/
|
||||||
public static boolean anonymousClassWarning = true;
|
public static boolean anonymousClassWarning = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether injector metadata (what is returned by the functions of {@link IInjector})
|
||||||
|
* is to use obfuscated names instead of its normal names.
|
||||||
|
*/
|
||||||
|
public static boolean obfuscateInjectorMetadata = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the processor with the processing environment by
|
* Initializes the processor with the processing environment by
|
||||||
* setting the {@code processingEnv} field to the value of the
|
* setting the {@code processingEnv} field to the value of the
|
||||||
|
@ -103,13 +109,14 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
StandardCharsets.UTF_8)).lines());
|
StandardCharsets.UTF_8)).lines());
|
||||||
}
|
}
|
||||||
String warns = processingEnv.getOptions().get("badPracticeWarnings");
|
String warns = processingEnv.getOptions().get("badPracticeWarnings");
|
||||||
if(warns == null)
|
if(warns != null)
|
||||||
badPracticeWarnings = true;
|
badPracticeWarnings = parseBooleanArg(warns);
|
||||||
else badPracticeWarnings = parseBooleanArg(warns);
|
|
||||||
String anonymousClassWarn = processingEnv.getOptions().get("anonymousClassWarning");
|
String anonymousClassWarn = processingEnv.getOptions().get("anonymousClassWarning");
|
||||||
if(anonymousClassWarn == null)
|
if(anonymousClassWarn != null)
|
||||||
anonymousClassWarning = true;
|
anonymousClassWarning = parseBooleanArg(anonymousClassWarn);
|
||||||
else anonymousClassWarning = parseBooleanArg(anonymousClassWarn);
|
String obfuscateInj = processingEnv.getOptions().get("obfuscateInjectorMetadata");
|
||||||
|
if(obfuscateInj != null)
|
||||||
|
obfuscateInjectorMetadata = parseBooleanArg(obfuscateInj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,6 +354,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
.addStatement(String.format("super.%s(clazz, main)", toGenerate.get(injName).injector.getSimpleName()), TypeName.get(cl.asType()))
|
.addStatement(String.format("super.%s(clazz, main)", toGenerate.get(injName).injector.getSimpleName()), TypeName.get(cl.asType()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
MethodContainer target = toGenerate.get(injName).target;
|
||||||
TypeSpec injectorClass = TypeSpec.classBuilder(injName)
|
TypeSpec injectorClass = TypeSpec.classBuilder(injName)
|
||||||
.addModifiers(Modifier.PUBLIC)
|
.addModifiers(Modifier.PUBLIC)
|
||||||
.superclass(cl.asType())
|
.superclass(cl.asType())
|
||||||
|
@ -354,9 +362,9 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
.addMethod(constructorBuilder.build())
|
.addMethod(constructorBuilder.build())
|
||||||
.addMethod(buildStringReturnMethod("name", cl.getSimpleName().toString()))
|
.addMethod(buildStringReturnMethod("name", cl.getSimpleName().toString()))
|
||||||
.addMethod(buildStringReturnMethod("reason", toGenerate.get(injName).reason))
|
.addMethod(buildStringReturnMethod("reason", toGenerate.get(injName).reason))
|
||||||
.addMethod(buildStringReturnMethod("targetClass", targetClass.fqnObf))
|
.addMethod(buildStringReturnMethod("targetClass", obfuscateInjectorMetadata ? targetClass.fqnObf : targetClass.fqn))
|
||||||
.addMethod(buildStringReturnMethod("methodName", toGenerate.get(injName).target.nameObf))
|
.addMethod(buildStringReturnMethod("methodName", obfuscateInjectorMetadata ? target.nameObf : target.name))
|
||||||
.addMethod(buildStringReturnMethod("methodDesc", toGenerate.get(injName).target.descriptorObf))
|
.addMethod(buildStringReturnMethod("methodDesc", obfuscateInjectorMetadata ? target.descriptorObf : target.descriptor))
|
||||||
.addMethods(generateDummies(targets))
|
.addMethods(generateDummies(targets))
|
||||||
.addMethod(inject)
|
.addMethod(inject)
|
||||||
.build();
|
.build();
|
||||||
|
|
Loading…
Reference in a new issue