use of javax.lang.model.type.DeclaredType in project buck by facebook.
the class MoreElements method findAnnotation.
@Nullable
private static AnnotationMirror findAnnotation(CharSequence name, Element element) {
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
DeclaredType annotationType = annotationMirror.getAnnotationType();
TypeElement annotationTypeElement = (TypeElement) annotationType.asElement();
if (annotationTypeElement.getQualifiedName().contentEquals(name)) {
return annotationMirror;
}
}
return null;
}
use of javax.lang.model.type.DeclaredType in project buck by facebook.
the class MoreElements method isSourceRetention.
public static boolean isSourceRetention(AnnotationMirror annotation) {
DeclaredType annotationType = annotation.getAnnotationType();
TypeElement annotationTypeElement = (TypeElement) annotationType.asElement();
AnnotationMirror retentionAnnotation = findAnnotation("java.lang.annotation.Retention", annotationTypeElement);
if (retentionAnnotation == null) {
return false;
}
VariableElement retentionPolicy = (VariableElement) Preconditions.checkNotNull(findAnnotationValue(retentionAnnotation, "value"));
return retentionPolicy.getSimpleName().contentEquals("SOURCE");
}
use of javax.lang.model.type.DeclaredType in project hibernate-orm by hibernate.
the class XmlMetaEntity method getCollectionTypes.
private String[] getCollectionTypes(String propertyName, String explicitTargetEntity, String explicitMapKeyClass, ElementKind expectedElementKind) {
for (Element elem : element.getEnclosedElements()) {
if (!expectedElementKind.equals(elem.getKind())) {
continue;
}
String elementPropertyName = elem.getSimpleName().toString();
if (elem.getKind().equals(ElementKind.METHOD)) {
elementPropertyName = StringUtil.getPropertyName(elementPropertyName);
}
if (!propertyName.equals(elementPropertyName)) {
continue;
}
DeclaredType type = determineDeclaredType(elem);
if (type == null) {
continue;
}
return determineTypes(propertyName, explicitTargetEntity, explicitMapKeyClass, type);
}
return null;
}
use of javax.lang.model.type.DeclaredType in project immutables by immutables.
the class TypeHierarchyCollector method collectUnresolvedInterface.
private void collectUnresolvedInterface(TypeMirror typeMirror, TypevarContext context) {
if (typeMirror.getKind() == TypeKind.ERROR) {
DeclaredType declaredType = toDeclaredType(typeMirror);
String stringified = stringify(declaredType, context);
implementedInterfaceNames.add(stringified);
}
}
use of javax.lang.model.type.DeclaredType in project epoxy by airbnb.
the class HashCodeValidator method validateImplementsHashCode.
private void validateImplementsHashCode(TypeMirror mirror) throws EpoxyProcessorException {
if (TypeName.get(mirror).isPrimitive()) {
return;
}
if (mirror.getKind() == TypeKind.ARRAY) {
validateArrayType((ArrayType) mirror);
return;
}
if (!(mirror instanceof DeclaredType)) {
return;
}
DeclaredType declaredType = (DeclaredType) mirror;
Element element = typeUtils.asElement(mirror);
TypeElement clazz = (TypeElement) element;
if (isIterableType(clazz)) {
validateIterableType(declaredType);
return;
}
if (isAutoValueType(element)) {
return;
}
if (isWhiteListedType(element)) {
return;
}
if (!hasHashCodeInClassHierarchy(clazz)) {
throwError("Attribute does not implement hashCode");
}
}
Aggregations