use of javax.lang.model.type.DeclaredType in project buck by facebook.
the class TypeResolverTest method testArrayTypeResolves.
@Test
public void testArrayTypeResolves() throws IOException {
compile("abstract class Foo extends java.util.ArrayList<java.lang.String[]> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeElement listElement = elements.getTypeElement("java.util.ArrayList");
TypeMirror stringType = elements.getTypeElement("java.lang.String").asType();
ArrayType stringArrayType = types.getArrayType(stringType);
DeclaredType expectedSuperclass = types.getDeclaredType(listElement, stringArrayType);
assertSameType(expectedSuperclass, fooElement.getSuperclass());
}
use of javax.lang.model.type.DeclaredType in project buck by facebook.
the class TypeResolverTest method testTypeVariableResolves.
@Test
public void testTypeVariableResolves() throws IOException {
compile("abstract class Foo<T extends java.lang.Runnable> extends java.util.ArrayList<T> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeElement listElement = elements.getTypeElement("java.util.ArrayList");
TypeMirror tType = fooElement.getTypeParameters().get(0).asType();
DeclaredType expectedSuperclass = types.getDeclaredType(listElement, tType);
assertSameType(expectedSuperclass, fooElement.getSuperclass());
}
use of javax.lang.model.type.DeclaredType 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.DeclaredType in project hibernate-orm by hibernate.
the class ClassWriter method findMappedSuperClass.
private static String findMappedSuperClass(MetaEntity entity, Context context) {
TypeMirror superClass = entity.getTypeElement().getSuperclass();
//superclass of Object is of NoType which returns some other kind
while (superClass.getKind() == TypeKind.DECLARED) {
//F..king Ch...t Have those people used their horrible APIs even once?
final Element superClassElement = ((DeclaredType) superClass).asElement();
String superClassName = ((TypeElement) superClassElement).getQualifiedName().toString();
if (extendsSuperMetaModel(superClassElement, entity.isMetaComplete(), context)) {
return superClassName;
}
superClass = ((TypeElement) superClassElement).getSuperclass();
}
return null;
}
use of javax.lang.model.type.DeclaredType in project j2objc by google.
the class SwitchRewriter method fixEnumValue.
private void fixEnumValue(SwitchStatement node) {
Expression expr = node.getExpression();
TypeMirror type = expr.getTypeMirror();
if (!TypeUtil.isEnum(type)) {
return;
}
DeclaredType enumType = typeUtil.getSuperclass(type);
ExecutablePair ordinalMethod = typeUtil.findMethod(enumType, "ordinal");
MethodInvocation invocation = new MethodInvocation(ordinalMethod, TreeUtil.remove(expr));
node.setExpression(invocation);
}
Aggregations