mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-20 20:22:31 +00:00
Better wiring for injector annotations, fixes issue w/missed annotations
ModifyVariable and ModifyConstant were previously missing from declared annotation types. Now delegate to the same registration logic as runtime
This commit is contained in:
1 parent
eb7a548f92
commit
6d9fcfe635
6 files changed
+217
-41
No files matched your search
@@ -60,6 +60,7 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.util.ITokenProvider;
|
||||
import org.spongepowered.asm.util.VersionNumber;
|
||||
import org.spongepowered.asm.util.logging.MessageRouter;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IJavadocProvider;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinAnnotationProcessor;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinValidator;
|
||||
@@ -144,9 +145,12 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
private AnnotatedMixins(ProcessingEnvironment processingEnv) {
|
||||
this.env = this.detectEnvironment(processingEnv);
|
||||
this.processingEnv = processingEnv;
|
||||
|
||||
MessageRouter.setMessager(processingEnv.getMessager());
|
||||
|
||||
this.printMessage(Kind.NOTE, "SpongePowered MIXIN Annotation Processor Version=" + MixinBootstrap.VERSION);
|
||||
this.checkPluginVersion(this.getOption(SupportedOptions.PLUGIN_VERSION));
|
||||
String pluginVersion = this.checkPluginVersion(this.getOption(SupportedOptions.PLUGIN_VERSION));
|
||||
String pluginVersionString = pluginVersion != null ? String.format(" (MixinGradle Version=%s)", pluginVersion) : "";
|
||||
this.printMessage(Kind.NOTE, "SpongePowered MIXIN Annotation Processor Version=" + MixinBootstrap.VERSION + pluginVersionString);
|
||||
|
||||
this.targets = this.initTargetMap();
|
||||
this.obf = new ObfuscationManager(this);
|
||||
@@ -165,9 +169,9 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
* the user if the version of MixinGradle is out of date relative to the
|
||||
* Mixin library version
|
||||
*/
|
||||
private void checkPluginVersion(String version) {
|
||||
private String checkPluginVersion(String version) {
|
||||
if (version == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
VersionNumber pluginVersion = VersionNumber.parse(version);
|
||||
@@ -176,6 +180,7 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
this.printMessage(Kind.WARNING, String.format("MixinGradle version %s is out of date. Update to the recommended version %s",
|
||||
pluginVersion, recommendedVersion));
|
||||
}
|
||||
return pluginVersion.toString();
|
||||
}
|
||||
|
||||
protected TargetMap initTargetMap() {
|
||||
|
||||
+18
-21
@@ -25,10 +25,10 @@
|
||||
package org.spongepowered.tools.obfuscation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
@@ -37,26 +37,25 @@ import javax.tools.Diagnostic.Kind;
|
||||
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.tools.obfuscation.mirror.AnnotationHandle;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeUtils;
|
||||
|
||||
/**
|
||||
* Annotation processor which finds {@link Inject} and {@link At} annotations in
|
||||
* mixin classes and generates obfuscation mappings
|
||||
* Annotation processor which finds injector annotations in mixin classes and
|
||||
* generates obfuscation mappings
|
||||
*/
|
||||
@SupportedAnnotationTypes({
|
||||
"org.spongepowered.asm.mixin.injection.Inject",
|
||||
"org.spongepowered.asm.mixin.injection.ModifyArg",
|
||||
"org.spongepowered.asm.mixin.injection.ModifyArgs",
|
||||
"org.spongepowered.asm.mixin.injection.Redirect",
|
||||
"org.spongepowered.asm.mixin.injection.At"
|
||||
})
|
||||
public class MixinObfuscationProcessorInjection extends MixinObfuscationProcessor {
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedAnnotationTypes() {
|
||||
Set<String> supportedAnnotationTypes = new HashSet<String>();
|
||||
supportedAnnotationTypes.add(At.class.getName());
|
||||
for (Class<? extends Annotation> annotationType : InjectionInfo.getRegisteredAnnotations()) {
|
||||
supportedAnnotationTypes.add(annotationType.getName());
|
||||
}
|
||||
return supportedAnnotationTypes;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.annotation.processing.AbstractProcessor
|
||||
@@ -71,12 +70,9 @@ public class MixinObfuscationProcessorInjection extends MixinObfuscationProcesso
|
||||
}
|
||||
|
||||
this.processMixins(roundEnv);
|
||||
this.processInjectors(roundEnv, Inject.class);
|
||||
this.processInjectors(roundEnv, ModifyArg.class);
|
||||
this.processInjectors(roundEnv, ModifyArgs.class);
|
||||
this.processInjectors(roundEnv, Redirect.class);
|
||||
this.processInjectors(roundEnv, ModifyVariable.class);
|
||||
this.processInjectors(roundEnv, ModifyConstant.class);
|
||||
for (Class<? extends Annotation> annotationType : InjectionInfo.getRegisteredAnnotations()) {
|
||||
this.processInjectors(roundEnv, annotationType);
|
||||
}
|
||||
this.postProcess(roundEnv);
|
||||
|
||||
return true;
|
||||
@@ -115,4 +111,5 @@ public class MixinObfuscationProcessorInjection extends MixinObfuscationProcesso
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,7 +64,8 @@ public final class SupportedOptions {
|
||||
SupportedOptions.OVERWRITE_ERROR_LEVEL,
|
||||
SupportedOptions.DEFAULT_OBFUSCATION_ENV,
|
||||
SupportedOptions.DEPENDENCY_TARGETS_FILE,
|
||||
SupportedOptions.MAPPING_TYPES
|
||||
SupportedOptions.MAPPING_TYPES,
|
||||
SupportedOptions.PLUGIN_VERSION
|
||||
);
|
||||
options.addAll(
|
||||
ObfuscationServices.getInstance().getSupportedOptions()
|
||||
|
||||
Reference in new issue
Block a user