diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java index 5595894a..dbe15129 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java @@ -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); diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerInjector.java b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerInjector.java index 62cbdf61..7be6e45e 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerInjector.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerInjector.java @@ -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; } diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerSoftImplements.java b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerSoftImplements.java index b6cf9903..786d0c3c 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerSoftImplements.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixinElementHandlerSoftImplements.java @@ -58,6 +58,10 @@ public class AnnotatedMixinElementHandlerSoftImplements extends AnnotatedMixinEl * @param implementsAnnotation */ public void process(AnnotationHandle implementsAnnotation) { + if (!this.mixin.remap()) { + return; + } + List interfaces = implementsAnnotation.getAnnotationList("value"); // Derp? diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java index 778e48e7..45a941f9 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java @@ -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.getValue("remap", Boolean.TRUE).booleanValue(); + return mixinClass.remap() && annotation.getBoolean("remap", true); } /** diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/mirror/AnnotationHandle.java b/src/ap/java/org/spongepowered/tools/obfuscation/mirror/AnnotationHandle.java index 8b646a8e..ed633770 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/mirror/AnnotationHandle.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/mirror/AnnotationHandle.java @@ -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 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.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 List getList(String key) { List list = this.>getValue(key, Collections.emptyList()); - return AnnotationHandle.unfold(list); + return AnnotationHandle.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 List unfold(List list) { + protected static List unwrapAnnotationValueList(List list) { if (list == null) { return Collections.emptyList(); }