1 20 21 package spoon.aval.support.validator.problemFixer; 22 23 import java.lang.annotation.Annotation ; 24 25 import spoon.aval.annotation.structure.Requires; 26 import spoon.aval.processing.ValidationPoint; 27 import spoon.processing.AbstractProblemFixer; 28 import spoon.reflect.Changes; 29 import spoon.reflect.declaration.CtElement; 30 31 public class DefaultRequiresProblemFixer extends AbstractProblemFixer implements 32 AValFixer<Requires> { 33 34 Class <? extends Annotation > requiredAnn; 35 36 public void setValidationPoint(ValidationPoint<Requires> vp) { 37 requiredAnn = vp.getValAnnotation().value(); 38 } 39 40 public String getDescription() { 41 return "Annotates this element with the required annotation: "+requiredAnn.getName(); 42 } 43 44 public String getLabel() { 45 return "Annotates this element with "+requiredAnn.getSimpleName(); 46 } 47 48 public Changes run(CtElement element) { 49 Changes mod = new Changes(); 50 element.getFactory().Annotation().annotate(element, requiredAnn); 51 mod.getAdded().add(element); 52 return mod; 53 } 54 55 } 56 | Popular Tags |