01: package spoon.aval.annotation.structure;
02:
03: import java.lang.annotation.Annotation;
04: import java.lang.annotation.Retention;
05: import java.lang.annotation.RetentionPolicy;
06:
07: import spoon.aval.annotation.Implementation;
08: import spoon.aval.support.validator.RequiresInsideValidator;
09: import spoon.aval.support.validator.problemFixer.RemoveThisAnnotation;
10: import spoon.processing.ProblemFixer;
11: import spoon.processing.Severity;
12: import spoon.reflect.declaration.CtAnnotationType;
13:
14: /**
15: * Validator that states that the annotation requires annother annotation on an element inside of a third annotation
16: * <p>
17: * It works in a simlilar manner as to the Requires annotation, but with in the lexical scope of an annotation.
18: * The annotation that defines the scope is defined by means of an <code>@Inside</code> annotation.
19: * <p>
20: * If an annotation <code>@A</code> Requires the annotation <code>@B</code> anywhere inside of the annotation
21: * <code>@C</code>:
22: *
23: *
24: * <pre>
25: * @Inside(C.class)
26: * @ProhibitsInside(B.class)
27: * @Target(FIELD)
28: * public @interface A{}
29: * </pre>
30: *
31: * @see spoon.aval.support.validator.RequiresInsideValidator
32: * @see ProhibitsInside
33: * @see Inside
34: */
35: @Retention(RetentionPolicy.RUNTIME)
36: @Requires(Inside.class)
37: @AValTarget(CtAnnotationType.class)
38: @Implementation(RequiresInsideValidator.class)
39: public @interface RequiresInside {
40:
41: Class<? extends Annotation> value();
42:
43: /**
44: * Message to report when validation fails
45: */
46: String message() default "Annotation ?a2 is required inside ?in by ?ann ";
47:
48: /**
49: * Severity of the validation faliure
50: */
51: Severity severity() default Severity.WARNING;
52:
53: /**
54: * The list of {@link ProblemFixer}s to propose when the validation fails.
55: */
56: Class<? extends ProblemFixer>[] fixers() default { RemoveThisAnnotation.class };
57:
58: }
|