mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-22 08:38:24 +00:00
Respect remap setting on the Mixin class when processing soft implements
This commit is contained in:
1 parent
4bfaf3ce8b
commit
bc810b25da
5 files changed
+30
-16
No files matched your search
@@ -148,7 +148,7 @@ class AnnotatedMixin {
|
||||
this.annotation = this.handle.getAnnotation(Mixin.class);
|
||||
this.classRef = type.getQualifiedName().toString().replace('.', '/');
|
||||
this.primaryTarget = this.initTargets();
|
||||
this.remap = AnnotatedMixins.getRemapValue(this.annotation) && this.targets.size() > 0;
|
||||
this.remap = this.annotation.getBoolean("remap", true) && this.targets.size() > 0;
|
||||
|
||||
this.overwrites = new AnnotatedMixinElementHandlerOverwrite(ap, this);
|
||||
this.shadows = new AnnotatedMixinElementHandlerShadow(ap, this);
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ class AnnotatedMixinElementHandlerInjector extends AnnotatedMixinElementHandler
|
||||
this.ap.printMessage(Kind.ERROR, "Injector in interface is unsupported", elem.getElement());
|
||||
}
|
||||
|
||||
if (!AnnotatedMixins.getRemapValue(elem.getAt())) {
|
||||
if (!elem.getAt().getBoolean("remap", true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -58,6 +58,10 @@ public class AnnotatedMixinElementHandlerSoftImplements extends AnnotatedMixinEl
|
||||
* @param implementsAnnotation
|
||||
*/
|
||||
public void process(AnnotationHandle implementsAnnotation) {
|
||||
if (!this.mixin.remap()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<AnnotationHandle> interfaces = implementsAnnotation.getAnnotationList("value");
|
||||
|
||||
// Derp?
|
||||
|
||||
@@ -521,14 +521,7 @@ class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITyp
|
||||
}
|
||||
|
||||
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(AnnotationHandle annotation) {
|
||||
return annotation.<Boolean>getValue("remap", Boolean.TRUE).booleanValue();
|
||||
return mixinClass.remap() && annotation.getBoolean("remap", true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,7 @@ public class AnnotationHandle {
|
||||
/**
|
||||
* Return the wrapped mirror, only used to pass to Messager methods
|
||||
*
|
||||
* @return
|
||||
* @return annotation mirror (can be null)
|
||||
*/
|
||||
public AnnotationMirror asMirror() {
|
||||
return this.annotation;
|
||||
@@ -77,6 +77,9 @@ public class AnnotationHandle {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.annotation == null) {
|
||||
return "@{UnknownAnnotation}";
|
||||
}
|
||||
return "@" + this.annotation.getAnnotationType().asElement().getSimpleName();
|
||||
}
|
||||
|
||||
@@ -94,7 +97,7 @@ public class AnnotationHandle {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
AnnotationValue value = this.getAnnotationValue0(key);
|
||||
AnnotationValue value = this.getAnnotationValue(key);
|
||||
if (defaultValue instanceof Enum && value != null) {
|
||||
VariableElement varValue = (VariableElement)value.getValue();
|
||||
if (varValue == null) {
|
||||
@@ -119,12 +122,25 @@ public class AnnotationHandle {
|
||||
* Get the annotation value with the specified key or return null if not
|
||||
* present or not set
|
||||
*
|
||||
* @param key key to fetch
|
||||
* @return value or null if not present or not set
|
||||
*/
|
||||
public <T> T getValue(String key) {
|
||||
return this.getValue(key, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the primitive boolean value with the specified key or return null if
|
||||
* not present or not set
|
||||
*
|
||||
* @param key key to fetch
|
||||
* @param defaultValue default value to return if value is not present
|
||||
* @return value or default if not present or not set
|
||||
*/
|
||||
public boolean getBoolean(String key, boolean defaultValue) {
|
||||
return this.<Boolean>getValue(key, Boolean.valueOf(defaultValue)).booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the annotation value as a list with values of the specified
|
||||
* type. Returns an empty list if the value is not present or not set.
|
||||
@@ -140,11 +156,12 @@ public class AnnotationHandle {
|
||||
* values of the specified type. Returns an empty list if the value is not
|
||||
* present or not set.
|
||||
*
|
||||
* @param key key to fetch
|
||||
* @return list of values
|
||||
*/
|
||||
public <T> List<T> getList(String key) {
|
||||
List<AnnotationValue> list = this.<List<AnnotationValue>>getValue(key, Collections.<AnnotationValue>emptyList());
|
||||
return AnnotationHandle.<T>unfold(list);
|
||||
return AnnotationHandle.<T>unwrapAnnotationValueList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +183,7 @@ public class AnnotationHandle {
|
||||
return annotations;
|
||||
}
|
||||
|
||||
protected AnnotationValue getAnnotationValue0(String key) {
|
||||
protected AnnotationValue getAnnotationValue(String key) {
|
||||
for (ExecutableElement elem : this.annotation.getElementValues().keySet()) {
|
||||
if (elem.getSimpleName().contentEquals(key)) {
|
||||
return this.annotation.getElementValues().get(elem);
|
||||
@@ -177,7 +194,7 @@ public class AnnotationHandle {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static <T> List<T> unfold(List<AnnotationValue> list) {
|
||||
protected static <T> List<T> unwrapAnnotationValueList(List<AnnotationValue> list) {
|
||||
if (list == null) {
|
||||
return Collections.<T>emptyList();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user