mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-20 18:09:37 +00:00
Added "remap" arg to let reobf processing be skipped per-member basis
This commit is contained in:
1 parent
3b3a16db75
commit
fb64777a41
6 files changed
+74
-9
No files matched your search
@@ -141,6 +141,11 @@ class AnnotatedMixin {
|
||||
*/
|
||||
private final String classRef;
|
||||
|
||||
/**
|
||||
* True if we will actually process remappings for this mixin
|
||||
*/
|
||||
private final boolean remap;
|
||||
|
||||
/**
|
||||
* Stored (ordered) field mappings
|
||||
*/
|
||||
@@ -152,13 +157,16 @@ class AnnotatedMixin {
|
||||
private final Set<String> methodMappings = new LinkedHashSet<String>();
|
||||
|
||||
public AnnotatedMixin(AnnotatedMixins mixins, TypeElement type) {
|
||||
AnnotationMirror annotation = MirrorUtils.getAnnotation(type, Mixin.class);
|
||||
|
||||
this.mixins = mixins;
|
||||
this.mixin = type;
|
||||
this.classRef = type.getQualifiedName().toString().replace('.', '/');
|
||||
this.remap = AnnotatedMixins.getRemapValue(annotation);
|
||||
|
||||
String targetRef = null;
|
||||
TypeElement targetType = null;
|
||||
List<AnnotationValue> targetList = MirrorUtils.<List<AnnotationValue>>getAnnotationValue(type, Mixin.class);
|
||||
List<AnnotationValue> targetList = MirrorUtils.<List<AnnotationValue>>getAnnotationValue(annotation);
|
||||
for (TypeMirror target : MirrorUtils.<TypeMirror>unfold(targetList)) {
|
||||
Element element = ((DeclaredType)target).asElement();
|
||||
String targetName = ((TypeElement)element).getQualifiedName().toString();
|
||||
@@ -187,6 +195,13 @@ class AnnotatedMixin {
|
||||
return this.targets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether to remap annotations in this mixin
|
||||
*/
|
||||
public boolean remap() {
|
||||
return this.remap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stored field mappings
|
||||
*/
|
||||
|
||||
@@ -245,7 +245,10 @@ class AnnotatedMixins {
|
||||
"Found @Shadow annotation on a non-mixin field " + field + " in " + mixinType);
|
||||
return;
|
||||
}
|
||||
mixinClass.registerShadow(field, shadow);
|
||||
|
||||
if (this.shouldRemap(mixinClass, shadow)) {
|
||||
mixinClass.registerShadow(field, shadow);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +265,10 @@ class AnnotatedMixins {
|
||||
"Found @Shadow annotation on a non-mixin method " + method + " in " + mixinType);
|
||||
return;
|
||||
}
|
||||
mixinClass.registerShadow(method, shadow);
|
||||
|
||||
if (this.shouldRemap(mixinClass, shadow)) {
|
||||
mixinClass.registerShadow(method, shadow);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,14 +285,28 @@ class AnnotatedMixins {
|
||||
"Found @Inject annotation on a non-mixin method " + method + " in " + mixinType);
|
||||
return;
|
||||
}
|
||||
mixinClass.registerInjector(method, inject);
|
||||
|
||||
List<AnnotationMirror> annotationValue = MirrorUtils.<List<AnnotationMirror>>getAnnotationValue(inject, "at");
|
||||
for (AnnotationMirror at : annotationValue) {
|
||||
mixinClass.registerInjectionPoint(at);
|
||||
|
||||
if (this.shouldRemap(mixinClass, inject)) {
|
||||
mixinClass.registerInjector(method, inject);
|
||||
|
||||
List<AnnotationMirror> annotationValue = MirrorUtils.<List<AnnotationMirror>>getAnnotationValue(inject, "at");
|
||||
for (AnnotationMirror at : annotationValue) {
|
||||
mixinClass.registerInjectionPoint(at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldRemap(AnnotatedMixin mixinClass, AnnotationMirror 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a message to the AP messager
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user