mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-21 04:32:33 +00:00
Indicate mixin's parent phase in error messages
This commit is contained in:
1 parent
a85f2cd316
commit
b28f8b73c7
2 files changed
+25
-5
No files matched your search
@@ -48,6 +48,8 @@ import org.objectweb.asm.tree.InnerClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
@@ -141,11 +143,16 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
*/
|
||||
private final transient Set<String> syntheticInnerClasses = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* The environment phase in which this mixin was initialised
|
||||
*/
|
||||
private final transient Phase phase;
|
||||
|
||||
/**
|
||||
* Initial ClassNode created for mixin validation, not used for actual
|
||||
* application
|
||||
*/
|
||||
private ClassNode validationClassNode;
|
||||
private transient ClassNode validationClassNode;
|
||||
|
||||
/**
|
||||
* True if the superclass of the mixin is <b>not</b> the direct superclass
|
||||
@@ -169,6 +176,7 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
this.name = mixinName;
|
||||
this.className = parent.getMixinPackage() + mixinName;
|
||||
this.plugin = plugin;
|
||||
this.phase = MixinEnvironment.getCurrentEnvironment().getPhase();
|
||||
|
||||
// Read the class bytes and transform
|
||||
this.mixinBytes = this.loadMixinClass(this.className, runTransformers);
|
||||
@@ -231,6 +239,9 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
targetClassName = targetClassName.replace('/', '.');
|
||||
if (this.plugin == null || suppressPlugin || this.plugin.shouldApplyMixin(targetClassName, this.className)) {
|
||||
ClassInfo targetInfo = ClassInfo.forName(targetClassName);
|
||||
if (targetInfo == null) {
|
||||
throw new RuntimeException("@Mixin target " + targetClassName + " was not found " + this);
|
||||
}
|
||||
if (targetInfo.isInterface()) {
|
||||
throw new InvalidMixinException(this, "@Mixin target " + targetClassName + " is an interface in " + this);
|
||||
}
|
||||
@@ -266,7 +277,6 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
boolean detached = false;
|
||||
|
||||
for (ClassInfo targetClass : this.targetClasses) {
|
||||
|
||||
if (classNode.superName.equals(targetClass.getSuperName())) {
|
||||
continue;
|
||||
}
|
||||
@@ -416,6 +426,13 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
public Level getLoggingLevel() {
|
||||
return this.parent.getLoggingLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the phase in which this mixin was initialised
|
||||
*/
|
||||
public Phase getPhase() {
|
||||
return this.phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new tree for the class bytecode
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.objectweb.asm.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.MixinApplyError;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.transformers.TreeTransformer;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
@@ -359,12 +360,14 @@ public class MixinTransformer extends TreeTransformer {
|
||||
MixinTransformer.dumpClass(transformedName.replace('.', '/') + ".target", basicClass);
|
||||
}
|
||||
|
||||
MixinConfig config = th.getMixin().getParent();
|
||||
MixinInfo mixin = th.getMixin();
|
||||
Phase phase = mixin.getPhase();
|
||||
MixinConfig config = mixin.getParent();
|
||||
this.logger.log(config.isRequired() ? Level.FATAL : Level.WARN, String.format("Mixin failed applying %s -> %s: %s %s",
|
||||
th.getMixin(), transformedName, th.getClass().getName(), th.getMessage()), th);
|
||||
mixin, transformedName, th.getClass().getName(), th.getMessage()), th);
|
||||
|
||||
if (config.isRequired()) {
|
||||
throw new MixinApplyError("Mixin [" + th.getMixin() + "] FAILED for REQUIRED config [" + config + "]", th);
|
||||
throw new MixinApplyError("Mixin [" + mixin + "] from " + phase + " FAILED for REQUIRED config [" + config + "]", th);
|
||||
}
|
||||
|
||||
th.printStackTrace();
|
||||
|
||||
Reference in new issue
Block a user