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.ProhibitsInsideValidator;
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: import spoon.support.builder.SpoonBuildingManager;
14:
15: /**
16: * Validator that states that the annotation prohibits the use of another annotation on elements which
17: * are inside of of a given annotation
18: * <p>
19: * It works in a simlilar manner as to the Prohibits annotation, but with in the lexical scope of an annotation.
20: * The annotation that defines the scope is defined by means of an <code>@Inside</code> annotation.
21: * <p>
22: * If an annotation <code>@A</code> prohibits the annotation <code>@B</code> anywhere inside of the annotation
23: * <code>@C</code>:
24: *
25: *
26: * <pre>
27: * @Inside(C.class)
28: * @ProhibitsInside(B.class)
29: * @Target(FIELD)
30: * public @interface A{}
31: * </pre>
32: *
33: * @see spoon.aval.support.validator.ProhibitsInsideValidator
34: * @see RequiresInside
35: * @see Inside
36: */
37:
38: @Retention(RetentionPolicy.RUNTIME)
39: @Requires(Inside.class)
40: @AValTarget(CtAnnotationType.class)
41: @Implementation(ProhibitsInsideValidator.class)
42: public @interface ProhibitsInside {
43:
44: Class<? extends Annotation> value();
45:
46: /**
47: * Message to report when validation fails
48: */
49: String message() default "Annotation ?a2 is prohibited inside ?in by?ann";
50:
51: /**
52: * Severity of the validation faliure
53: */
54: Severity severity() default Severity.WARNING;
55:
56: /**
57: * The list of {@link ProblemFixer}s to propose when the validation fails.
58: */
59: Class<? extends ProblemFixer>[] fixers() default { RemoveThisAnnotation.class };
60: }
|