01: package spoon.aval.support.validator.util;
02:
03: import java.lang.annotation.Annotation;
04:
05: import spoon.reflect.declaration.CtElement;
06:
07: public class ValidatorHelper {
08:
09: public static CtElement getParentAnnotatedWith(
10: Class<? extends Annotation> scope, CtElement element) {
11: CtElement ret = element;
12: boolean found = false;
13: while (!found) {
14: if (ret.getAnnotation(scope) == null) {
15: ret = ret.getParent();
16: if (ret == null)
17: break;
18: } else {
19: found = true;
20: }
21: }
22:
23: return found ? ret : null;
24: }
25:
26: }
|