use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolReferringToInheritedStaticField.
@Test
public void solveSymbolReferringToInheritedStaticField() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("m", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("char", ref.getCorrespondingDeclaration().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveTypeRefToInternalEnum.
@Test
public void solveTypeRefToInternalEnum() {
CompilationUnit cu = parseSample("ClassWithTypes");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("E", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveTypeRefToInternalClass.
@Test
public void solveTypeRefToInternalClass() {
CompilationUnit cu = parseSample("ClassWithTypes");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("B", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolAsValueReferringToInheritedInstanceField.
@Test
public void solveSymbolAsValueReferringToInheritedInstanceField() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("k", new MemoryTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("boolean", ref.get().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveSymbolReferringToUnknownElement.
@Test
public void solveSymbolReferringToUnknownElement() {
CompilationUnit cu = parseSample("ClassWithSymbols");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("zzz", new MemoryTypeSolver());
assertEquals(false, ref.isSolved());
}
Aggregations