use of javax.lang.model.element.TypeParameterElement in project buck by facebook.
the class TreeBackedTypeParameterElementTest method testToString.
@Test
public void testToString() throws IOException {
compile("class Foo<T extends java.lang.Runnable> { }");
TypeParameterElement typeParam = elements.getTypeElement("Foo").getTypeParameters().get(0);
assertEquals("T", typeParam.toString());
}
use of javax.lang.model.element.TypeParameterElement 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.TypeParameterElement in project buck by facebook.
the class TreeBackedTypeParameterElementTest method testGetSimpleName.
@Test
public void testGetSimpleName() throws IOException {
compile("class Foo<T> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
final List<? extends TypeParameterElement> typeParameters = fooElement.getTypeParameters();
assertSame(1, typeParameters.size());
TypeParameterElement typeParam = typeParameters.get(0);
assertNameEquals("T", typeParam.getSimpleName());
}
use of javax.lang.model.element.TypeParameterElement in project buck by facebook.
the class TreeBackedTypeParameterElementTest method testGetEnclosingElement.
@Test
public void testGetEnclosingElement() throws IOException {
compile("class Foo<T> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
final List<? extends TypeParameterElement> typeParameters = fooElement.getTypeParameters();
assertSame(1, typeParameters.size());
TypeParameterElement typeParam = typeParameters.get(0);
assertSame(fooElement, typeParam.getGenericElement());
}
use of javax.lang.model.element.TypeParameterElement in project buck by facebook.
the class TreeBackedTypeParameterElementTest method testAccept.
@Test
public void testAccept() throws IOException {
compile("class Foo<T> { }");
TypeParameterElement expectedTypeParameter = elements.getTypeElement("Foo").getTypeParameters().get(0);
Object expectedResult = new Object();
Object actualResult = expectedTypeParameter.accept(new SimpleElementVisitor8<Object, Object>() {
@Override
protected Object defaultAction(Element e, Object o) {
return null;
}
@Override
public Object visitTypeParameter(TypeParameterElement actualTypeParameter, Object o) {
assertSame(expectedTypeParameter, actualTypeParameter);
return o;
}
}, expectedResult);
assertSame(expectedResult, actualResult);
}
Aggregations