Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable processing mixins when the input tag is null #122

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class MixinExtension implements TinyRemapper.Extension {
private final Map<Integer, Collection<Consumer<CommonData>>> tasks;
private final Set<AnnotationTarget> targets;
private final /* @Nullable */ Predicate<InputTag> inputTagFilter;
private final boolean processNullTags;

public enum AnnotationTarget {
/**
Expand Down Expand Up @@ -89,15 +90,24 @@ public MixinExtension(/* @Nullable */ Predicate<InputTag> inputTagFilter) {
this(EnumSet.allOf(AnnotationTarget.class), Level.WARN, inputTagFilter);
}

public MixinExtension(/* @Nullable */ Predicate<InputTag> inputTagFilter, boolean processNullTags) {
this(EnumSet.allOf(AnnotationTarget.class), Level.WARN, inputTagFilter, processNullTags);
}

public MixinExtension(Set<AnnotationTarget> targets, Logger.Level logLevel) {
this(targets, logLevel, null);
}

public MixinExtension(Set<AnnotationTarget> targets, Logger.Level logLevel, /* @Nullable */ Predicate<InputTag> inputTagFilter) {
this(targets, logLevel, inputTagFilter, true);
}

public MixinExtension(Set<AnnotationTarget> targets, Logger.Level logLevel, /* @Nullable */ Predicate<InputTag> inputTagFilter, boolean processNullTags) {
this.logger = new Logger(logLevel);
this.tasks = new ConcurrentHashMap<>();
this.targets = targets;
this.inputTagFilter = inputTagFilter;
this.processNullTags = processNullTags;
}

@Override
Expand Down Expand Up @@ -134,7 +144,9 @@ public ClassVisitor insertAnalyzeVisitor(int mrjVersion, String className, Class

@Override
public ClassVisitor insertAnalyzeVisitor(int mrjVersion, String className, ClassVisitor next, InputTag[] inputTags) {
if (inputTagFilter == null || inputTags == null) {
if (!processNullTags && inputTags == null) {
return next;
} else if (inputTagFilter == null || inputTags == null) {
return insertAnalyzeVisitor(mrjVersion, className, next);
} else {
for (InputTag tag : inputTags) {
Expand All @@ -159,7 +171,9 @@ public ClassVisitor insertApplyVisitor(TrClass cls, ClassVisitor next) {

@Override
public ClassVisitor insertApplyVisitor(TrClass cls, ClassVisitor next, InputTag[] inputTags) {
if (inputTagFilter == null || inputTags == null) {
if (!processNullTags && inputTags == null) {
return next;
} else if (inputTagFilter == null || inputTags == null) {
return insertApplyVisitor(cls, next);
} else {
for (InputTag tag : inputTags) {
Expand Down