use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveExistingGenericType.
@Test
public void solveExistingGenericType() {
CompilationUnit cu = parseSample("ClassWithTypeVariables");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<ResolvedType> a = context.solveGenericType("A", new MemoryTypeSolver());
Optional<ResolvedType> b = context.solveGenericType("B", new MemoryTypeSolver());
Optional<ResolvedType> c = context.solveGenericType("C", new MemoryTypeSolver());
assertEquals(true, a.isPresent());
assertEquals("A", a.get().describe());
assertEquals(true, a.get().isTypeVariable());
assertEquals(true, b.isPresent());
assertEquals("B", b.get().describe());
assertEquals(true, b.get().isTypeVariable());
assertEquals(true, c.isPresent());
assertEquals("C", c.get().describe());
assertEquals(true, c.get().isTypeVariable());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolReferringToDeclaredInstanceField.
@Test
public void solveSymbolReferringToDeclaredInstanceField() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("i", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("int", ref.getCorrespondingDeclaration().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolReferringToDeclaredStaticField.
@Test
public void solveSymbolReferringToDeclaredStaticField() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("j", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("long", ref.getCorrespondingDeclaration().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveTypeRefToAnotherClassInFile.
@Test
public void solveTypeRefToAnotherClassInFile() {
CompilationUnit cu = parseSample("ClassWithTypes");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("Super", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveTypeRefToQualifiedInternalClass.
@Test
public void solveTypeRefToQualifiedInternalClass() {
CompilationUnit cu = parseSample("ClassWithTypes");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("A.B", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
}
Aggregations