use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class WildcardUsageTest method setup.
@Before
public void setup() {
typeSolver = new ReflectionTypeSolver();
foo = new ReferenceTypeImpl(new ReflectionClassDeclaration(Foo.class, typeSolver), typeSolver);
bar = new ReferenceTypeImpl(new ReflectionClassDeclaration(Bar.class, typeSolver), typeSolver);
object = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver);
string = new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver);
superFoo = ResolvedWildcard.superBound(foo);
superBar = ResolvedWildcard.superBound(bar);
extendsFoo = ResolvedWildcard.extendsBound(foo);
extendsBar = ResolvedWildcard.extendsBound(bar);
a = new ResolvedTypeVariable(ResolvedTypeParameterDeclaration.onType("A", "foo.Bar", Collections.emptyList()));
superA = ResolvedWildcard.superBound(a);
extendsA = ResolvedWildcard.extendsBound(a);
superString = ResolvedWildcard.superBound(string);
extendsString = ResolvedWildcard.extendsBound(string);
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class VoidTypeTest method setup.
@Before
public void setup() {
typeSolver = new ReflectionTypeSolver();
OBJECT = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver);
STRING = new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver);
arrayOfBooleans = new ResolvedArrayType(ResolvedPrimitiveType.BOOLEAN);
arrayOfListOfA = new ResolvedArrayType(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(new ResolvedTypeVariable(ResolvedTypeParameterDeclaration.onType("A", "foo.Bar", Collections.emptyList()))), typeSolver));
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testIsClass.
@Test
public void testIsClass() {
class Foo<E> {
E field;
}
class Bar extends Foo<String> {
}
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration foo = new ReflectionClassDeclaration(Foo.class, typeResolver);
ResolvedClassDeclaration bar = new ReflectionClassDeclaration(Bar.class, typeResolver);
assertEquals(true, foo.isClass());
assertEquals(true, bar.isClass());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetPackageName.
@Test
public void testGetPackageName() {
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration arraylist = new ReflectionClassDeclaration(ArrayList.class, typeResolver);
assertEquals("java.util", arraylist.getPackageName());
ResolvedClassDeclaration string = new ReflectionClassDeclaration(String.class, typeResolver);
assertEquals("java.lang", string.getPackageName());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetFieldDeclarationTypeVariableInheritance.
@Test
public void testGetFieldDeclarationTypeVariableInheritance() {
class Foo<E> {
E field;
}
class Bar extends Foo<String> {
}
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedReferenceTypeDeclaration foo = new ReflectionClassDeclaration(Foo.class, typeResolver);
ResolvedReferenceTypeDeclaration bar = new ReflectionClassDeclaration(Bar.class, typeResolver);
ResolvedFieldDeclaration fooField = foo.getField("field");
assertEquals(true, fooField.getType().isTypeVariable());
assertEquals("E", fooField.getType().asTypeParameter().getName());
ResolvedFieldDeclaration barField = bar.getField("field");
assertEquals(true, barField.getType().isReferenceType());
assertEquals(String.class.getCanonicalName(), barField.getType().asReferenceType().getQualifiedName());
}
Aggregations