use of javax.lang.model.type.ExecutableType in project mapstruct by mapstruct.
the class TypeFactory method getReturnType.
public Type getReturnType(DeclaredType includingType, Accessor accessor) {
Type type;
TypeMirror accessorType = getMethodType(includingType, accessor.getElement());
if (isExecutableType(accessorType)) {
type = getType(((ExecutableType) accessorType).getReturnType());
} else {
type = getType(accessorType);
}
return type;
}
use of javax.lang.model.type.ExecutableType in project mapstruct by mapstruct.
the class MethodRetrievalProcessor method retrievePrototypeMethods.
private List<SourceMethod> retrievePrototypeMethods(TypeElement mapperTypeElement, MapperOptions mapperAnnotation) {
if (!mapperAnnotation.hasMapperConfig()) {
return Collections.emptyList();
}
TypeElement typeElement = asTypeElement(mapperAnnotation.mapperConfigType());
List<SourceMethod> methods = new ArrayList<>();
for (ExecutableElement executable : elementUtils.getAllEnclosedExecutableElements(typeElement)) {
ExecutableType methodType = typeFactory.getMethodType(mapperAnnotation.mapperConfigType(), executable);
List<Parameter> parameters = typeFactory.getParameters(methodType, executable);
boolean containsTargetTypeParameter = SourceMethod.containsTargetTypeParameter(parameters);
// prototype methods don't have prototypes themselves
List<SourceMethod> prototypeMethods = Collections.emptyList();
SourceMethod method = getMethodRequiringImplementation(methodType, executable, parameters, containsTargetTypeParameter, mapperAnnotation, prototypeMethods, mapperTypeElement);
if (method != null) {
methods.add(method);
}
}
return methods;
}
use of javax.lang.model.type.ExecutableType in project lombok by rzwitserloot.
the class HandleDelegate method addMethodBindings.
public void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTypes types, Set<String> banList) throws DelegateRecursion {
TypeSymbol tsym = ct.asElement();
if (tsym == null)
return;
for (Symbol member : tsym.getEnclosedElements()) {
for (Compound am : member.getAnnotationMirrors()) {
String name = null;
try {
name = am.type.tsym.flatName().toString();
} catch (Exception ignore) {
}
if ("lombok.Delegate".equals(name) || "lombok.experimental.Delegate".equals(name)) {
throw new DelegateRecursion(ct.tsym.name.toString(), member.name.toString());
}
}
if (member.getKind() != ElementKind.METHOD)
continue;
if (member.isStatic())
continue;
if (member.isConstructor())
continue;
ExecutableElement exElem = (ExecutableElement) member;
if (!exElem.getModifiers().contains(Modifier.PUBLIC))
continue;
ExecutableType methodType = (ExecutableType) types.asMemberOf(ct, member);
String sig = printSig(methodType, member.name, types);
// If add returns false, it was already in there
if (!banList.add(sig))
continue;
boolean isDeprecated = (member.flags() & DEPRECATED) != 0;
signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem));
}
for (Type type : types.directSupertypes(ct)) {
if (type instanceof ClassType) {
addMethodBindings(signatures, (ClassType) type, types, banList);
}
}
}
Aggregations