use of javax.lang.model.type.NoType in project RoboBinding by RoboBinding.
the class TypeMirrorWrapperTest method unsupportedTypeMirrors.
@DataPoints("unsupportedTypeMirrors")
public static TypeMirror[] unsupportedTypeMirrors() {
Types types = compilation.getTypes();
NullType nullType = types.getNullType();
NoType noneType = types.getNoType(TypeKind.NONE);
return new TypeMirror[] { nullType, noneType };
}
use of javax.lang.model.type.NoType in project querydsl by querydsl.
the class AbstractQuerydslProcessor method collectElements.
protected Set<TypeElement> collectElements() {
// from delegate methods
Set<TypeElement> elements = new HashSet<TypeElement>(processDelegateMethods());
// from class annotations
for (Class<? extends Annotation> annotation : conf.getEntityAnnotations()) {
for (Element element : getElements(annotation)) {
if (element instanceof TypeElement) {
elements.add((TypeElement) element);
}
}
}
// from package annotations
if (conf.getEntitiesAnnotation() != null) {
for (Element element : getElements(conf.getEntitiesAnnotation())) {
AnnotationMirror mirror = TypeUtils.getAnnotationMirrorOfType(element, conf.getEntitiesAnnotation());
elements.addAll(TypeUtils.getAnnotationValuesAsElements(mirror, "value"));
}
}
// from embedded annotations
if (conf.getEmbeddedAnnotation() != null) {
elements.addAll(getEmbeddedTypes());
}
// from embedded
if (conf.isUnknownAsEmbedded()) {
elements.addAll(getTypeFromProperties(elements));
}
// from annotation less supertypes
if (!conf.isStrictMode()) {
elements.addAll(getAnnotationlessSupertypes(elements));
}
// register possible embedded types of non-tracked supertypes
if (conf.getEmbeddedAnnotation() != null) {
Class<? extends Annotation> embedded = conf.getEmbeddedAnnotation();
Set<TypeElement> embeddedElements = new HashSet<TypeElement>();
for (TypeElement element : elements) {
TypeMirror superTypeMirror = element.getSuperclass();
while (superTypeMirror != null) {
TypeElement superTypeElement = (TypeElement) processingEnv.getTypeUtils().asElement(superTypeMirror);
if (superTypeElement != null) {
List<? extends Element> enclosed = superTypeElement.getEnclosedElements();
for (Element child : enclosed) {
if (child.getAnnotation(embedded) != null) {
handleEmbeddedType(child, embeddedElements);
}
}
superTypeMirror = superTypeElement.getSuperclass();
if (superTypeMirror instanceof NoType) {
superTypeMirror = null;
}
} else {
superTypeMirror = null;
}
}
}
// register found elements
for (TypeElement element : embeddedElements) {
if (!elements.contains(element)) {
elementHandler.handleEntityType(element);
}
}
}
return elements;
}
use of javax.lang.model.type.NoType in project buck by facebook.
the class TreeBackedTypeElementTest method testAsType.
@Test
public void testAsType() throws IOException {
compile("class Foo { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeMirror fooTypeMirror = fooElement.asType();
assertEquals(TypeKind.DECLARED, fooTypeMirror.getKind());
DeclaredType fooDeclaredType = (DeclaredType) fooTypeMirror;
assertSame(fooElement, fooDeclaredType.asElement());
assertEquals(0, fooDeclaredType.getTypeArguments().size());
TypeMirror enclosingType = fooDeclaredType.getEnclosingType();
assertEquals(TypeKind.NONE, enclosingType.getKind());
assertTrue(enclosingType instanceof NoType);
}
use of javax.lang.model.type.NoType in project buck by facebook.
the class TreeBackedTypesTest method testGetDeclaredTypeTopLevelNoGenerics.
@Test
public void testGetDeclaredTypeTopLevelNoGenerics() throws IOException {
compile("class Foo { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeMirror fooTypeMirror = types.getDeclaredType(fooElement);
assertEquals(TypeKind.DECLARED, fooTypeMirror.getKind());
DeclaredType fooDeclaredType = (DeclaredType) fooTypeMirror;
assertNotSame(fooElement.asType(), fooDeclaredType);
assertSame(fooElement, fooDeclaredType.asElement());
assertEquals(0, fooDeclaredType.getTypeArguments().size());
TypeMirror enclosingType = fooDeclaredType.getEnclosingType();
assertEquals(TypeKind.NONE, enclosingType.getKind());
assertTrue(enclosingType instanceof NoType);
}
use of javax.lang.model.type.NoType in project RoboBinding by RoboBinding.
the class TypeMirrorWrapperTest method supportedTypeMirrors.
@DataPoints("supportedTypeMirrors")
public static TypeMirrorToWrapped[] supportedTypeMirrors() {
Types types = compilation.getTypes();
NoType voidType = types.getNoType(TypeKind.VOID);
PrimitiveType primitiveType = types.getPrimitiveType(TypeKind.INT);
Elements elements = compilation.getElements();
DeclaredType declaredType = (DeclaredType) elements.getTypeElement(Object.class.getName()).asType();
ArrayType arrayType = types.getArrayType(declaredType);
return new TypeMirrorToWrapped[] { a(voidType).itsWrapped(WrappedVoidType.class), a(primitiveType).itsWrapped(WrappedPrimitiveType.class), a(declaredType).itsWrapped(WrappedDeclaredType.class), a(arrayType).itsWrapped(WrappedArrayType.class) };
}
Aggregations