mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-21 08:02:13 +00:00
Refactor annotation handling in the AP
This commit is contained in:
1 parent
4934071ee7
commit
c007eabc31
18 files changed
+378
-258
No files matched your search
@@ -58,7 +58,6 @@ import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.util.ITokenProvider;
|
||||
import org.spongepowered.tools.MirrorUtils;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IJavadocProvider;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinAnnotationProcessor;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinValidator;
|
||||
@@ -357,7 +356,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
return;
|
||||
}
|
||||
|
||||
mixinClass.registerAccessor(method, MirrorUtils.getAnnotation(method, Accessor.class));
|
||||
mixinClass.registerAccessor(method, AnnotationHandle.of(method, Accessor.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,7 +372,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
return;
|
||||
}
|
||||
|
||||
mixinClass.registerInvoker(method, MirrorUtils.getAnnotation(method, Invoker.class));
|
||||
mixinClass.registerInvoker(method, AnnotationHandle.of(method, Invoker.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,7 +388,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
return;
|
||||
}
|
||||
|
||||
mixinClass.registerOverwrite(method, MirrorUtils.getAnnotation(method, Overwrite.class));
|
||||
mixinClass.registerOverwrite(method, AnnotationHandle.of(method, Overwrite.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,7 +398,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
* @param field Shadow field
|
||||
* @param shadow {@link org.spongepowered.asm.mixin.Shadow} annotation
|
||||
*/
|
||||
public void registerShadow(TypeElement mixinType, VariableElement field, AnnotationMirror shadow) {
|
||||
public void registerShadow(TypeElement mixinType, VariableElement field, AnnotationHandle shadow) {
|
||||
AnnotatedMixin mixinClass = this.getMixin(mixinType);
|
||||
if (mixinClass == null) {
|
||||
this.printMessage(Kind.ERROR, "Found @Shadow annotation on a non-mixin field", field);
|
||||
@@ -416,7 +415,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
* @param method Shadow method
|
||||
* @param shadow {@link org.spongepowered.asm.mixin.Shadow} annotation
|
||||
*/
|
||||
public void registerShadow(TypeElement mixinType, ExecutableElement method, AnnotationMirror shadow) {
|
||||
public void registerShadow(TypeElement mixinType, ExecutableElement method, AnnotationHandle shadow) {
|
||||
AnnotatedMixin mixinClass = this.getMixin(mixinType);
|
||||
if (mixinClass == null) {
|
||||
this.printMessage(Kind.ERROR, "Found @Shadow annotation on a non-mixin method", method);
|
||||
@@ -434,11 +433,10 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
* @param inject {@link org.spongepowered.asm.mixin.injection.Inject}
|
||||
* annotation
|
||||
*/
|
||||
public void registerInjector(TypeElement mixinType, ExecutableElement method, AnnotationMirror inject) {
|
||||
public void registerInjector(TypeElement mixinType, ExecutableElement method, AnnotationHandle inject) {
|
||||
AnnotatedMixin mixinClass = this.getMixin(mixinType);
|
||||
if (mixinClass == null) {
|
||||
String type = "@" + inject.getAnnotationType().asElement().getSimpleName() + "";
|
||||
this.printMessage(Kind.ERROR, "Found " + type + " annotation on a non-mixin method", method);
|
||||
this.printMessage(Kind.ERROR, "Found " + inject + " annotation on a non-mixin method", method);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -446,7 +444,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
Message errorMessage = mixinClass.registerInjector(method, inject, remap);
|
||||
int remappedAts = 0;
|
||||
if (remap) {
|
||||
Object ats = MirrorUtils.getAnnotationValue(inject, "at");
|
||||
Object ats = inject.getValue("at");
|
||||
|
||||
if (ats instanceof List) {
|
||||
List<?> annotationList = (List<?>)ats;
|
||||
@@ -456,18 +454,18 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
at = ((AnnotationValue)at).getValue();
|
||||
}
|
||||
if (at instanceof AnnotationMirror) {
|
||||
remappedAts += mixinClass.registerInjectionPoint(method, inject, (AnnotationMirror)at);
|
||||
remappedAts += mixinClass.registerInjectionPoint(method, inject, new AnnotationHandle((AnnotationMirror)at));
|
||||
} else {
|
||||
this.printMessage(Kind.WARNING, "No annotation mirror on " + at.getClass().getName());
|
||||
}
|
||||
}
|
||||
} else if (ats instanceof AnnotationMirror) {
|
||||
remappedAts += mixinClass.registerInjectionPoint(method, inject, (AnnotationMirror)ats);
|
||||
remappedAts += mixinClass.registerInjectionPoint(method, inject, new AnnotationHandle((AnnotationMirror)ats));
|
||||
} else if (ats instanceof AnnotationValue) {
|
||||
// Fix for JDT
|
||||
Object mirror = ((AnnotationValue)ats).getValue();
|
||||
if (mirror instanceof AnnotationMirror) {
|
||||
remappedAts += mixinClass.registerInjectionPoint(method, inject, (AnnotationMirror)mirror);
|
||||
remappedAts += mixinClass.registerInjectionPoint(method, inject, new AnnotationHandle((AnnotationMirror)mirror));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,7 +486,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
* @param implementsAnnotation
|
||||
* {@link org.spongepowered.asm.mixin.Implements} annotation
|
||||
*/
|
||||
public void registerSoftImplements(TypeElement mixin, AnnotationMirror implementsAnnotation) {
|
||||
public void registerSoftImplements(TypeElement mixin, AnnotationHandle implementsAnnotation) {
|
||||
AnnotatedMixin mixinClass = this.getMixin(mixin);
|
||||
if (mixinClass == null) {
|
||||
this.printMessage(Kind.ERROR, "Found @Implements annotation on a non-mixin class");
|
||||
@@ -519,15 +517,15 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldRemap(AnnotatedMixin mixinClass, AnnotationMirror annotation) {
|
||||
private boolean shouldRemap(AnnotatedMixin mixinClass, AnnotationHandle annotation) {
|
||||
return mixinClass.remap() && AnnotatedMixins.getRemapValue(annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we should remap the annotated member or skip it
|
||||
*/
|
||||
public static boolean getRemapValue(AnnotationMirror annotation) {
|
||||
return MirrorUtils.<Boolean>getAnnotationValue(annotation, "remap", Boolean.TRUE).booleanValue();
|
||||
public static boolean getRemapValue(AnnotationHandle annotation) {
|
||||
return annotation.<Boolean>getValue("remap", Boolean.TRUE).booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user