1 20 21 package spoon.aval.support.validator; 22 23 import java.lang.annotation.Annotation ; 24 25 import spoon.aval.Validator; 26 import spoon.aval.annotation.structure.Inside; 27 import spoon.aval.processing.AValProcessor; 28 import spoon.aval.processing.ValidationPoint; 29 import spoon.processing.Severity; 30 import spoon.reflect.declaration.CtElement; 31 32 47 public class InsideValidator implements Validator<Inside> { 48 49 53 public void check(ValidationPoint<Inside> vp) { 54 Class <? extends Annotation > parent = vp.getValAnnotation().value(); 55 56 CtElement pElement = vp.getProgramElement(); 57 pElement = pElement.getParent(); 58 while (pElement != null) { 59 if (pElement.getAnnotation(parent) != null) { 60 return; 61 } 62 pElement = pElement.getParent(); 63 } 64 65 String message = vp.getValAnnotation().message().replace("?val", parent.getSimpleName()); 66 ValidationPoint.report(vp.getValAnnotation().severity(), vp 67 .getProgramElement(), message,vp.fixerFactory(vp.getValAnnotation().fixers())); 68 } 69 70 } 71 | Popular Tags |