use of spoon.support.visitor.ClassTypingContext in project spoon by INRIA.
the class CtTypeImpl method getAllMethods.
@Override
public Set<CtMethod<?>> getAllMethods() {
final Set<CtMethod<?>> l = new HashSet<>();
final ClassTypingContext ctc = new ClassTypingContext(this);
map(new AllTypeMembersFunction(CtMethod.class)).forEach(new CtConsumer<CtMethod<?>>() {
@Override
public void accept(CtMethod<?> currentMethod) {
for (CtMethod<?> alreadyVisitedMethod : l) {
if (ctc.isSameSignature(currentMethod, alreadyVisitedMethod)) {
return;
}
}
l.add(currentMethod);
}
});
return Collections.unmodifiableSet(l);
}
use of spoon.support.visitor.ClassTypingContext in project spoon by INRIA.
the class SpoonMetaModel method getInheritedAnnotation.
/**
* @param method a start method
* @param annotationType a searched annotation type
* @return annotation from the first method in superClass and superInterface hierarchy for the method with required annotationType
*/
private static <A extends Annotation> CtAnnotation<A> getInheritedAnnotation(CtMethod<?> method, CtTypeReference<A> annotationType) {
CtAnnotation<A> annotation = method.getAnnotation(annotationType);
if (annotation == null) {
CtType<?> declType = method.getDeclaringType();
final ClassTypingContext ctc = new ClassTypingContext(declType);
annotation = declType.map(new AllTypeMembersFunction(CtMethod.class)).map((CtMethod<?> currentMethod) -> {
if (method == currentMethod) {
return null;
}
if (ctc.isSameSignature(method, currentMethod)) {
CtAnnotation<A> annotation2 = currentMethod.getAnnotation(annotationType);
if (annotation2 != null) {
return annotation2;
}
}
return null;
}).first();
}
return annotation;
}
Aggregations