use of javax.lang.model.element.TypeParameterElement in project robolectric by robolectric.
the class RobolectricModel method appendParameterList.
public void appendParameterList(StringBuilder message, List<? extends TypeParameterElement> tpeList) {
boolean first = true;
for (TypeParameterElement tpe : tpeList) {
if (first) {
first = false;
} else {
message.append(',');
}
message.append(tpe.toString());
boolean iFirst = true;
for (TypeMirror bound : getExplicitBounds(tpe)) {
if (iFirst) {
message.append(" extends ");
iFirst = false;
} else {
message.append(',');
}
message.append(bound);
}
}
}
use of javax.lang.model.element.TypeParameterElement in project immutables by immutables.
the class TypeExtractor method initParameters.
private Type.Parameters initParameters(Parameterizable context) {
Type.Parameters parameters = factory.parameters();
for (TypeParameterElement p : context.getTypeParameters()) {
String name = p.getSimpleName().toString();
List<Type.Defined> bounds = getBounds(parameters, p);
parameters = parameters.introduce(name, bounds);
}
return parameters;
}
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());
}
Aggregations