use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeElementTest method testGetQualifiedNameNamedPackage.
@Test
public void testGetQualifiedNameNamedPackage() throws IOException {
compile(Joiner.on('\n').join("package com.facebook.buck;", "public class Foo {}"));
TypeElement element = elements.getTypeElement("com.facebook.buck.Foo");
assertNameEquals("com.facebook.buck.Foo", element.getQualifiedName());
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeElementTest method testGetSimpleName.
@Test
public void testGetSimpleName() throws IOException {
compile("public class Foo {}");
TypeElement element = elements.getTypeElement("Foo");
assertNameEquals("Foo", element.getSimpleName());
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypeParameterElementTest method testTypeParameterBoundedTypeParameter.
@Test
public void testTypeParameterBoundedTypeParameter() throws IOException {
compile("class Foo<T, U extends T> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeParameterElement uElement = fooElement.getTypeParameters().get(1);
TypeMirror tType = fooElement.getTypeParameters().get(0).asType();
assertSameType(tType, uElement.getBounds().get(0));
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypesTest method testIsNotSameTypeParameterizedType.
@Test
public void testIsNotSameTypeParameterizedType() throws IOException {
initCompiler();
TypeElement listElement = elements.getTypeElement("java.util.List");
TypeMirror stringType = elements.getTypeElement("java.lang.String").asType();
TypeMirror integerType = elements.getTypeElement("java.lang.Integer").asType();
TypeMirror listStringType = types.getDeclaredType(listElement, stringType);
TypeMirror listIntType = types.getDeclaredType(listElement, integerType);
assertNotSameType(listStringType, listIntType);
}
use of javax.lang.model.element.TypeElement in project buck by facebook.
the class TreeBackedTypesTest method testIsSameTypeUnboundedTypeVariable.
@Test
public void testIsSameTypeUnboundedTypeVariable() throws IOException {
compile("class Foo<T> extends java.util.ArrayList<T> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeMirror t1 = fooElement.getTypeParameters().get(0).asType();
TypeMirror t2 = ((DeclaredType) fooElement.getSuperclass()).getTypeArguments().get(0);
assertSameType(t1, t2);
}
Aggregations