Add "non-strict" mode flag to interface checker module, closes #150

This commit is contained in:
Mumfrey committed 2016-11-22 16:09:09 +00:00
1 parent 961296a6fd
commit 70e36777a4
2 files changed
+26

No files matched your search

@@ -360,6 +360,20 @@ public final class MixinEnvironment implements ITokenProvider {
*/
CHECK_IMPLEMENTS(Option.CHECK_ALL, "interfaces"),
/**
* If interface check is enabled, "strict mode" (default) applies the
* implementation check even to abstract target classes. Setting this
* option to <tt>false</tt> causes abstract targets to be skipped when
* generating the implementation report.
*/
CHECK_IMPLEMENTS_STRICT(Option.CHECK_IMPLEMENTS, "strict") {
@Override
boolean getBooleanValue() {
// Allow a local FALSE to override a parent TRUE
return Booleans.parseBoolean(System.getProperty(this.property), super.getBooleanValue());
}
},
/**
* Ignore all constraints on mixin annotations, output warnings instead
*/
@@ -34,6 +34,10 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.MixinEnvironment;
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
import org.spongepowered.asm.mixin.transformer.ClassInfo.SearchType;
import org.spongepowered.asm.mixin.transformer.ClassInfo.Traversal;
@@ -51,6 +55,8 @@ import com.google.common.io.Files;
*/
public class MixinTransformerModuleInterfaceChecker implements IMixinTransformerModule {
private static final Logger logger = LogManager.getLogger("mixin");
/**
* CSV Report file
*/
@@ -106,6 +112,12 @@ public class MixinTransformerModuleInterfaceChecker implements IMixinTransformer
@Override
public void postApply(TargetClassContext context) {
ClassInfo targetClassInfo = context.getClassInfo();
// If the target is abstract and strict mode is not enabled, skip this class
if (targetClassInfo.isAbstract() && !MixinEnvironment.getCurrentEnvironment().getOption(Option.CHECK_IMPLEMENTS_STRICT)) {
MixinTransformerModuleInterfaceChecker.logger.info("{} is skipping abstract target {}", this.getClass().getSimpleName(), context);
return;
}
String className = targetClassInfo.getName().replace('/', '.');
int missingMethodCount = 0;