diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java index 11807aaaf..3473619cc 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixin.java @@ -466,6 +466,25 @@ public void registerOverwrite(ExecutableElement method, AnnotationMirror overwri String obfName = obfMethod.name.substring(obfMethod.name.lastIndexOf('/') + 1); this.addMethodMapping(type, mcpName, obfName, mcpSignature, obfMethod.sig); } + + if ("true".equalsIgnoreCase(this.mixins.getOption(SupportedOptions.DISABLE_OVERWRITE_CHECKER))) { + Kind overwriteErrorKind = "error".equalsIgnoreCase(this.mixins.getOption(SupportedOptions.OVERWRITE_ERROR_LEVEL)) + ? Kind.ERROR : Kind.WARNING; + + String javadoc = this.mixins.getJavadoc(method); + if (javadoc == null) { + this.mixins.printMessage(overwriteErrorKind, "@Overwrite is missing javadoc comment", method); + return; + } + + if (!javadoc.toLowerCase().contains("@author")) { + this.mixins.printMessage(overwriteErrorKind, "@Overwrite is missing an @author tag", method); + } + + if (!javadoc.toLowerCase().contains("@reason")) { + this.mixins.printMessage(overwriteErrorKind, "@Overwrite is missing an @reason tag", method); + } + } } /** diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java index 4dbe5d368..0f59555fc 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java @@ -662,6 +662,17 @@ public TypeHandle getTypeHandle(String name) { return null; } + /** + * Get javadoc on element + * + * @param element Element to fetch javadoc for + * @return javadoc + */ + public String getJavadoc(Element element) { + Elements elements = this.processingEnv.getElementUtils(); + return elements.getDocComment(element); + } + /** * Get the mixin manager instance for this environment */ diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/SupportedOptions.java b/src/ap/java/org/spongepowered/tools/obfuscation/SupportedOptions.java index 7ca778428..aef3103f5 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/SupportedOptions.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/SupportedOptions.java @@ -30,14 +30,16 @@ public final class SupportedOptions { - public static final String REOBF_SRG_FILE = "reobfSrgFile"; - public static final String REOBF_NOTCH_FILE = "reobfNotchSrgFile"; - public static final String OUT_SRG_SRG_FILE = "outSrgFile"; - public static final String OUT_NOTCH_SRG_FILE = "outNotchSrgFile"; - public static final String OUT_REFMAP_FILE = "outRefMapFile"; - public static final String DISABLE_TARGET_VALIDATOR = "disableTargetValidator"; - public static final String DISABLE_TARGET_EXPORT = "disableTargetExport"; - public static final String DEFAULT_OBFUSCATION_ENV = "defaultObfuscationEnv"; + public static final String REOBF_SRG_FILE = "reobfSrgFile"; + public static final String REOBF_NOTCH_FILE = "reobfNotchSrgFile"; + public static final String OUT_SRG_SRG_FILE = "outSrgFile"; + public static final String OUT_NOTCH_SRG_FILE = "outNotchSrgFile"; + public static final String OUT_REFMAP_FILE = "outRefMapFile"; + public static final String DISABLE_TARGET_VALIDATOR = "disableTargetValidator"; + public static final String DISABLE_TARGET_EXPORT = "disableTargetExport"; + public static final String DISABLE_OVERWRITE_CHECKER = "disableOverwriteChecker"; + public static final String OVERWRITE_ERROR_LEVEL = "overwriteErrorLevel"; + public static final String DEFAULT_OBFUSCATION_ENV = "defaultObfuscationEnv"; public static final Set all = ImmutableSet.of( SupportedOptions.REOBF_SRG_FILE, @@ -47,6 +49,8 @@ public final class SupportedOptions { SupportedOptions.OUT_REFMAP_FILE, SupportedOptions.DISABLE_TARGET_VALIDATOR, SupportedOptions.DISABLE_TARGET_EXPORT, + SupportedOptions.DISABLE_OVERWRITE_CHECKER, + SupportedOptions.OVERWRITE_ERROR_LEVEL, SupportedOptions.DEFAULT_OBFUSCATION_ENV ); diff --git a/src/ap/java/org/spongepowered/tools/obfuscation/TargetObfuscationEnvironment.java b/src/ap/java/org/spongepowered/tools/obfuscation/TargetObfuscationEnvironment.java index 79aeea51b..ebb40b204 100644 --- a/src/ap/java/org/spongepowered/tools/obfuscation/TargetObfuscationEnvironment.java +++ b/src/ap/java/org/spongepowered/tools/obfuscation/TargetObfuscationEnvironment.java @@ -156,7 +156,7 @@ public MethodData getObfMethod(MemberInfo method) { // Get a type handle for the declared method owner TypeHandle type = this.typeProvider.getTypeHandle(method.owner); - if (type.isImaginary()) { + if (type == null || type.isImaginary()) { return null; }