use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolAsValueReferringToDeclaredInstanceField.
@Test
public void solveSymbolAsValueReferringToDeclaredInstanceField() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("i", new MemoryTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("int", ref.get().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolAsValueReferringToUnknownElement.
@Test
public void solveSymbolAsValueReferringToUnknownElement() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("zzz", new MemoryTypeSolver());
assertEquals(false, ref.isPresent());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveTypeRefToQualifiedInternalOfInternalClass.
@Test
public void solveTypeRefToQualifiedInternalOfInternalClass() {
CompilationUnit cu = parseSample("ClassWithTypes");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("B.C", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolAsValueReferringToInterfaceInheritedInstanceField.
@Test
public void solveSymbolAsValueReferringToInterfaceInheritedInstanceField() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
ClassOrInterfaceDeclarationContext context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("o", new MemoryTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("int", ref.get().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolAsValueReferringToDeclaredStaticField.
@Test
public void solveSymbolAsValueReferringToDeclaredStaticField() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("j", new MemoryTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("long", ref.get().getType().describe());
}
Aggregations