use of javax.lang.model.element.ExecutableElement in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessor method processNestedType.
private void processNestedType(String prefix, TypeElement element, ExecutableElement source, String name, ExecutableElement getter, VariableElement field, TypeMirror returnType) {
Element returnElement = this.processingEnv.getTypeUtils().asElement(returnType);
boolean isNested = isNested(returnElement, field, element);
AnnotationMirror annotation = getAnnotation(getter, configurationPropertiesAnnotation());
if (returnElement != null && returnElement instanceof TypeElement && annotation == null && isNested) {
String nestedPrefix = ConfigurationMetadata.nestedPrefix(prefix, name);
this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix, this.typeUtils.getQualifiedName(returnElement), this.typeUtils.getQualifiedName(element), (getter == null ? null : getter.toString())));
processTypeElement(nestedPrefix, (TypeElement) returnElement, source);
}
}
use of javax.lang.model.element.ExecutableElement in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessor method processSimpleLombokTypes.
private void processSimpleLombokTypes(String prefix, TypeElement element, ExecutableElement source, TypeElementMembers members, Map<String, Object> fieldValues) {
for (Map.Entry<String, VariableElement> entry : members.getFields().entrySet()) {
String name = entry.getKey();
VariableElement field = entry.getValue();
if (!isLombokField(field, element)) {
continue;
}
TypeMirror returnType = field.asType();
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
boolean hasSetter = hasLombokSetter(field, element);
if (!isExcluded && !isNested && (hasSetter || isCollection)) {
String dataType = this.typeUtils.getType(returnType);
String sourceType = this.typeUtils.getQualifiedName(element);
String description = this.typeUtils.getJavaDoc(field);
Object defaultValue = fieldValues.get(name);
boolean deprecated = isDeprecated(field) || isDeprecated(source);
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name, dataType, sourceType, null, description, defaultValue, (deprecated ? new ItemDeprecation() : null)));
}
}
}
use of javax.lang.model.element.ExecutableElement in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessor method processNestedTypes.
private void processNestedTypes(String prefix, TypeElement element, ExecutableElement source, TypeElementMembers members) {
for (Map.Entry<String, ExecutableElement> entry : members.getPublicGetters().entrySet()) {
String name = entry.getKey();
ExecutableElement getter = entry.getValue();
VariableElement field = members.getFields().get(name);
processNestedType(prefix, element, source, name, getter, field, getter.getReturnType());
}
}
use of javax.lang.model.element.ExecutableElement in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessor method processSimpleTypes.
private void processSimpleTypes(String prefix, TypeElement element, ExecutableElement source, TypeElementMembers members, Map<String, Object> fieldValues) {
for (Map.Entry<String, ExecutableElement> entry : members.getPublicGetters().entrySet()) {
String name = entry.getKey();
ExecutableElement getter = entry.getValue();
TypeMirror returnType = getter.getReturnType();
ExecutableElement setter = members.getPublicSetter(name, returnType);
VariableElement field = members.getFields().get(name);
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
if (!isExcluded && !isNested && (setter != null || isCollection)) {
String dataType = this.typeUtils.getType(returnType);
String sourceType = this.typeUtils.getQualifiedName(element);
String description = this.typeUtils.getJavaDoc(field);
Object defaultValue = fieldValues.get(name);
boolean deprecated = isDeprecated(getter) || isDeprecated(setter) || isDeprecated(source);
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name, dataType, sourceType, null, description, defaultValue, (deprecated ? getItemDeprecation(getter) : null)));
}
}
}
use of javax.lang.model.element.ExecutableElement in project lombok by rzwitserloot.
the class TestAp method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
roundCounter++;
log("TestAP in round " + roundCounter);
boolean foundGetTest = false;
int annotatedElemCount = 0;
for (Element annotated : roundEnv.getElementsAnnotatedWith(ExampleAnnotation.class)) {
annotatedElemCount++;
for (Element child : annotated.getEnclosedElements()) {
if (child.getSimpleName().toString().equals("getTest") && child.getKind() == ElementKind.METHOD)
foundGetTest = true;
if (child instanceof ExecutableElement) {
TypeMirror returnType = ((ExecutableElement) child).getReturnType();
System.out.println("RETURN TYPE for " + child.getSimpleName() + ": " + returnType.getClass() + " -- " + returnType.toString());
}
}
}
if (foundGetTest)
log("RESULT: POSITIVE -- found the getTest method");
else if (annotatedElemCount > 0)
log("RESULT: NEGATIVE -- found the example class but there's no getTest method in it according to the type mirror.");
else
log("RESULT: AMBIVALENT -- The example class is not provided by 'getElementsAnnotatedWith' in this round. Not an issue, unless previously you got a NEGATIVE result.");
return false;
}
Aggregations