use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class TypeExtractor method visit.
@Override
public ResolvedType visit(ClassExpr node, Boolean solveLambdas) {
// This implementation does not regard the actual type argument of the ClassExpr.
com.github.javaparser.ast.type.Type astType = node.getType();
ResolvedType jssType = facade.convertToUsage(astType, node.getType());
return new ReferenceTypeImpl(new ReflectionClassDeclaration(Class.class, typeSolver), ImmutableList.of(jssType), typeSolver);
}
use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class FunctionInterfaceLogicTest method testGetFunctionalMethodNegativeCaseOnClass.
@Test
public void testGetFunctionalMethodNegativeCaseOnClass() {
TypeSolver typeSolver = new ReflectionTypeSolver();
ResolvedType string = new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver);
assertEquals(false, FunctionalInterfaceLogic.getFunctionalMethod(string).isPresent());
}
use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class ArrayTypeTest 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);
arrayOfStrings = new ResolvedArrayType(STRING);
tpA = ResolvedTypeParameterDeclaration.onType("A", "foo.Bar", Collections.emptyList());
arrayOfListOfA = new ResolvedArrayType(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(new ResolvedTypeVariable(tpA)), typeSolver));
arrayOfListOfStrings = new ResolvedArrayType(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver)), typeSolver));
}
use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class NullTypeTest 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.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class ReferenceTypeTest method testGetFieldTypeExisting.
@Test
public void testGetFieldTypeExisting() {
class Foo<A> {
List<A> elements;
}
TypeSolver typeSolver = new ReflectionTypeSolver();
ReferenceTypeImpl ref = new ReferenceTypeImpl(new ReflectionClassDeclaration(Foo.class, typeSolver), typeSolver);
assertEquals(true, ref.getFieldType("elements").isPresent());
assertEquals(true, ref.getFieldType("elements").get().isReferenceType());
assertEquals(List.class.getCanonicalName(), ref.getFieldType("elements").get().asReferenceType().getQualifiedName());
assertEquals(1, ref.getFieldType("elements").get().asReferenceType().typeParametersValues().size());
assertEquals(true, ref.getFieldType("elements").get().asReferenceType().typeParametersValues().get(0).isTypeVariable());
assertEquals("A", ref.getFieldType("elements").get().asReferenceType().typeParametersValues().get(0).asTypeParameter().getName());
ref = new ReferenceTypeImpl(new ReflectionClassDeclaration(Foo.class, typeSolver), ImmutableList.of(new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver)), typeSolver);
assertEquals(true, ref.getFieldType("elements").isPresent());
assertEquals(true, ref.getFieldType("elements").get().isReferenceType());
assertEquals(List.class.getCanonicalName(), ref.getFieldType("elements").get().asReferenceType().getQualifiedName());
assertEquals(1, ref.getFieldType("elements").get().asReferenceType().typeParametersValues().size());
assertEquals(true, ref.getFieldType("elements").get().asReferenceType().typeParametersValues().get(0).isReferenceType());
assertEquals(String.class.getCanonicalName(), ref.getFieldType("elements").get().asReferenceType().typeParametersValues().get(0).asReferenceType().getQualifiedName());
}
Aggregations