mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-22 03:24:49 +01:00
fix: find always falling back
This commit is contained in:
parent
03a2fd37d2
commit
ede3b3503d
5 changed files with 10 additions and 7 deletions
|
@ -202,7 +202,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
ClassContainer targetClass = ClassContainer.from(
|
ClassContainer targetClass = ClassContainer.from(
|
||||||
patchAnn,
|
patchAnn,
|
||||||
Patch::value,
|
Patch::value,
|
||||||
patchAnn.innerClass(),
|
patchAnn.innerName(),
|
||||||
this.processingEnv,
|
this.processingEnv,
|
||||||
this.mapper
|
this.mapper
|
||||||
);
|
);
|
||||||
|
@ -236,6 +236,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
//find and validate
|
//find and validate
|
||||||
ClassContainer clazz = ClassContainer.findOrFallback(
|
ClassContainer clazz = ClassContainer.findOrFallback(
|
||||||
ClassContainer.from(cl, this.processingEnv, this.mapper),
|
ClassContainer.from(cl, this.processingEnv, this.mapper),
|
||||||
|
patchAnn,
|
||||||
proxyVar.getAnnotation(Find.class),
|
proxyVar.getAnnotation(Find.class),
|
||||||
this.processingEnv,
|
this.processingEnv,
|
||||||
this.mapper
|
this.mapper
|
||||||
|
|
|
@ -27,5 +27,5 @@ public @interface Patch {
|
||||||
* defaults to empty string (not an inner class)
|
* defaults to empty string (not an inner class)
|
||||||
* @since 0.5.0
|
* @since 0.5.0
|
||||||
*/
|
*/
|
||||||
String innerClass() default "";
|
String innerName() default "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package ftbsc.lll.processor.tools.containers;
|
||||||
import ftbsc.lll.exceptions.TargetNotFoundException;
|
import ftbsc.lll.exceptions.TargetNotFoundException;
|
||||||
import ftbsc.lll.processor.LilleroProcessor;
|
import ftbsc.lll.processor.LilleroProcessor;
|
||||||
import ftbsc.lll.processor.annotations.Find;
|
import ftbsc.lll.processor.annotations.Find;
|
||||||
|
import ftbsc.lll.processor.annotations.Patch;
|
||||||
import ftbsc.lll.processor.tools.obfuscation.ObfuscationMapper;
|
import ftbsc.lll.processor.tools.obfuscation.ObfuscationMapper;
|
||||||
|
|
||||||
import javax.annotation.processing.ProcessingEnvironment;
|
import javax.annotation.processing.ProcessingEnvironment;
|
||||||
|
@ -127,16 +128,17 @@ public class ClassContainer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds and builds a {@link ClassContainer} based on information contained
|
* Finds and builds a {@link ClassContainer} based on information contained
|
||||||
* within a {@link Find} annotation, else returns a fallback.
|
* within {@link Patch} or a {@link Find} annotations, else returns a fallback.
|
||||||
* @param fallback the {@link ClassContainer} it falls back on
|
* @param fallback the {@link ClassContainer} it falls back on
|
||||||
|
* @param p the {@link Patch} annotation to get info from
|
||||||
* @param f the {@link Find} annotation to get info from
|
* @param f the {@link Find} annotation to get info from
|
||||||
* @param env the {@link ProcessingEnvironment} to perform the operation in
|
* @param env the {@link ProcessingEnvironment} to perform the operation in
|
||||||
* @param mapper the {@link ObfuscationMapper} to use, may be null
|
* @param mapper the {@link ObfuscationMapper} to use, may be null
|
||||||
* @return the built {@link ClassContainer} or the fallback if not enough information was present
|
* @return the built {@link ClassContainer} or the fallback if not enough information was present
|
||||||
* @since 0.5.0
|
* @since 0.5.0
|
||||||
*/
|
*/
|
||||||
public static ClassContainer findOrFallback(ClassContainer fallback, Find f, ProcessingEnvironment env, ObfuscationMapper mapper) {
|
public static ClassContainer findOrFallback(ClassContainer fallback, Patch p, Find f, ProcessingEnvironment env, ObfuscationMapper mapper) {
|
||||||
if(f == null) return fallback;
|
if(f == null) return ClassContainer.from(p, Patch::value, p.innerName(), env, mapper);
|
||||||
ClassContainer cl = ClassContainer.from(f, Find::value, f.innerName(), env, mapper);
|
ClassContainer cl = ClassContainer.from(f, Find::value, f.innerName(), env, mapper);
|
||||||
return cl.fqn.equals("java.lang.Object")
|
return cl.fqn.equals("java.lang.Object")
|
||||||
? fallback
|
? fallback
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class FieldContainer {
|
||||||
|
|
||||||
ClassContainer parent = ClassContainer.findOrFallback(
|
ClassContainer parent = ClassContainer.findOrFallback(
|
||||||
ClassContainer.from((TypeElement) finder.getEnclosingElement(), env, mapper),
|
ClassContainer.from((TypeElement) finder.getEnclosingElement(), env, mapper),
|
||||||
f, env, mapper
|
patchAnn, f, env, mapper
|
||||||
);
|
);
|
||||||
|
|
||||||
String name = f.name().equals("") ? finder.getSimpleName().toString() : f.name();
|
String name = f.name().equals("") ? finder.getSimpleName().toString() : f.name();
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class MethodContainer {
|
||||||
Patch patchAnn = stub.getEnclosingElement().getAnnotation(Patch.class);
|
Patch patchAnn = stub.getEnclosingElement().getAnnotation(Patch.class);
|
||||||
ClassContainer parent = ClassContainer.findOrFallback(
|
ClassContainer parent = ClassContainer.findOrFallback(
|
||||||
ClassContainer.from((TypeElement) stub.getEnclosingElement(), env, mapper),
|
ClassContainer.from((TypeElement) stub.getEnclosingElement(), env, mapper),
|
||||||
f, env, mapper
|
patchAnn, f, env, mapper
|
||||||
);
|
);
|
||||||
String name = !t.methodName().equals("")
|
String name = !t.methodName().equals("")
|
||||||
? t.methodName() //name was specified in target
|
? t.methodName() //name was specified in target
|
||||||
|
|
Loading…
Reference in a new issue