1 20 21 package spoon.aval.support.validator.problemFixer; 22 23 import java.lang.annotation.Annotation ; 24 import java.util.Iterator ; 25 import java.util.Set ; 26 27 import spoon.aval.processing.ValidationPoint; 28 import spoon.processing.AbstractProblemFixer; 29 import spoon.reflect.Changes; 30 import spoon.reflect.declaration.CtAnnotation; 31 import spoon.reflect.declaration.CtElement; 32 33 public class RemoveThisAnnotation extends AbstractProblemFixer implements AValFixer { 34 35 private Class <? extends Annotation > thisAnnotation = null; 36 37 public void setValidationPoint(ValidationPoint vp) { 38 thisAnnotation = (Class <? extends Annotation >)vp.getDslAnnotation().getAnnotationType().getActualClass(); 39 } 40 41 public String getDescription() { 42 return "Remove this annotation"; 43 } 44 45 public String getLabel() { 46 return "Remove this annotation"; 47 } 48 49 public Changes run(CtElement element) { 50 Changes df = new Changes(); 51 Set <CtAnnotation<? extends Annotation >> anns = element.getAnnotations(); 52 for (Iterator iter = anns.iterator(); iter.hasNext();) { 53 CtAnnotation e = (CtAnnotation) iter.next(); 54 if(e.getAnnotationType().getActualClass().equals(thisAnnotation)){ 55 iter.remove(); 56 df.getRemoved().add(e); 57 } 58 } 59 return df; 60 } 61 62 } 63 | Popular Tags |