mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-22 13:09:57 +00:00
Flesh out missing validator javadoc
This commit is contained in:
1 parent
79b55797fd
commit
5ca43d3dd3
4 files changed
+72
-1
No files matched your search
@@ -29,8 +29,23 @@ import java.util.Collection;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import org.spongepowered.tools.obfuscation.TypeHandle;
|
||||
|
||||
|
||||
/**
|
||||
* A mixin validator module, basically just a way of making the various sanity
|
||||
* checks modular
|
||||
*/
|
||||
public interface IMixinValidator {
|
||||
|
||||
public abstract boolean validate(TypeElement mixin, AnnotationMirror annotation, Collection<TypeElement> targets);
|
||||
/**
|
||||
* Validate all the things, return false to halt processing of further
|
||||
* validators. Raise compiler errors/warnings directly.
|
||||
*
|
||||
* @param mixin Mixin being validated
|
||||
* @param annotation Mixin annotation
|
||||
* @param targets Mixin targets
|
||||
* @return False to halt processing of further validators
|
||||
*/
|
||||
public abstract boolean validate(TypeElement mixin, AnnotationMirror annotation, Collection<TypeHandle> targets);
|
||||
}
|
||||
@@ -29,22 +29,52 @@ import javax.lang.model.element.Element;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for mixin validators
|
||||
*/
|
||||
public abstract class MixinValidator implements IMixinValidator {
|
||||
|
||||
/**
|
||||
* Processing environment for this validator, used for raising compiler
|
||||
* errors and warnings
|
||||
*/
|
||||
protected final ProcessingEnvironment processingEnv;
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*
|
||||
* @param processingEnv Processing environment
|
||||
*/
|
||||
public MixinValidator(ProcessingEnvironment processingEnv) {
|
||||
this.processingEnv = processingEnv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a compiler note
|
||||
*
|
||||
* @param note Message
|
||||
* @param element Element to attach the note to
|
||||
*/
|
||||
protected final void note(String note, Element element) {
|
||||
this.processingEnv.getMessager().printMessage(Kind.NOTE, note, element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a compiler note
|
||||
*
|
||||
* @param warning Message
|
||||
* @param element Element to attach the warning to
|
||||
*/
|
||||
protected final void warning(String warning, Element element) {
|
||||
this.processingEnv.getMessager().printMessage(Kind.WARNING, warning, element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a compiler note
|
||||
*
|
||||
* @param error Message
|
||||
* @param element Element to attach the error to
|
||||
*/
|
||||
protected final void error(String error, Element element) {
|
||||
this.processingEnv.getMessager().printMessage(Kind.ERROR, error, element);
|
||||
}
|
||||
|
||||
@@ -35,12 +35,25 @@ import javax.lang.model.element.TypeElement;
|
||||
import org.spongepowered.tools.obfuscation.TypeHandle;
|
||||
|
||||
|
||||
/**
|
||||
* Validator which checks that the mixin parent is sane
|
||||
*/
|
||||
public class ParentValidator extends MixinValidator {
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*
|
||||
* @param processingEnv Processing environment
|
||||
*/
|
||||
public ParentValidator(ProcessingEnvironment processingEnv) {
|
||||
super(processingEnv);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.tools.obfuscation.validation.IMixinValidator
|
||||
* #validate(javax.lang.model.element.TypeElement,
|
||||
* javax.lang.model.element.AnnotationMirror, java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public boolean validate(TypeElement mixin, AnnotationMirror annotation, Collection<TypeHandle> targets) {
|
||||
if (mixin.getEnclosingElement().getKind() != ElementKind.PACKAGE && !mixin.getModifiers().contains(Modifier.STATIC)) {
|
||||
|
||||
@@ -34,12 +34,25 @@ import javax.lang.model.type.TypeMirror;
|
||||
import org.spongepowered.tools.obfuscation.TypeHandle;
|
||||
|
||||
|
||||
/**
|
||||
* Validator which checks that the mixin targets are sane
|
||||
*/
|
||||
public class TargetValidator extends MixinValidator {
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*
|
||||
* @param processingEnv Processing environment
|
||||
*/
|
||||
public TargetValidator(ProcessingEnvironment processingEnv) {
|
||||
super(processingEnv);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.tools.obfuscation.validation.IMixinValidator
|
||||
* #validate(javax.lang.model.element.TypeElement,
|
||||
* javax.lang.model.element.AnnotationMirror, java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public boolean validate(TypeElement mixin, AnnotationMirror annotation, Collection<TypeHandle> targets) {
|
||||
TypeMirror superClass = mixin.getSuperclass();
|
||||
|
||||
Reference in new issue
Block a user