use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class ReferenceTypeTest method charSequenceIsAssignableToObject.
@Test
public void charSequenceIsAssignableToObject() {
TypeSolver typeSolver = new ReflectionTypeSolver();
ReferenceTypeImpl charSequence = new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(CharSequence.class, typeSolver), typeSolver);
ReferenceTypeImpl object = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver);
assertEquals(false, charSequence.isAssignableBy(object));
assertEquals(true, object.isAssignableBy(charSequence));
}
use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class TypeVariableUsageTest method setup.
@Before
public void setup() {
tpA = new ResolvedTypeVariable(ResolvedTypeParameterDeclaration.onType("A", "foo.Bar", Collections.emptyList()));
typeSolver = new ReflectionTypeSolver();
tpString = new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver);
}
use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration 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.reflectionmodel.ReflectionClassDeclaration 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.reflectionmodel.ReflectionClassDeclaration in project javaparser by javaparser.
the class ContextTest method resolveReferenceUsingQualifiedName.
@Test
public void resolveReferenceUsingQualifiedName() {
CompilationUnit cu = parseSample("Navigator2");
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration referencesToField = Navigator.demandClass(cu, "Navigator");
MethodDeclaration method = Navigator.demandMethod(referencesToField, "findType");
Parameter param = method.getParameters().get(0);
ResolvedClassDeclaration compilationUnitDecl = mock(ResolvedClassDeclaration.class);
when(compilationUnitDecl.getName()).thenReturn("CompilationUnit");
when(compilationUnitDecl.getQualifiedName()).thenReturn("com.github.javaparser.ast.CompilationUnit");
TypeSolver typeSolver = mock(TypeSolver.class);
// when(typeSolver.tryToSolveType("java.lang.com.github.javaparser.ast.CompilationUnit")).thenReturn(SymbolReference.unsolved(ClassDeclaration.class));
when(typeSolver.getRoot()).thenReturn(typeSolver);
when(typeSolver.solveType("java.lang.Object")).thenReturn(new ReflectionClassDeclaration(Object.class, typeSolver));
when(typeSolver.tryToSolveType("com.github.javaparser.ast.CompilationUnit")).thenReturn(SymbolReference.solved(compilationUnitDecl));
SymbolSolver symbolSolver = new SymbolSolver(typeSolver);
SymbolReference<? extends ResolvedTypeDeclaration> ref = symbolSolver.solveType("com.github.javaparser.ast.CompilationUnit", param);
assertEquals(true, ref.isSolved());
assertEquals("CompilationUnit", ref.getCorrespondingDeclaration().getName());
assertEquals("com.github.javaparser.ast.CompilationUnit", ref.getCorrespondingDeclaration().getQualifiedName());
}
Aggregations