use of com.github.javaparser.ast.body.ClassOrInterfaceDeclaration 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.ast.body.ClassOrInterfaceDeclaration 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.ast.body.ClassOrInterfaceDeclaration in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodOverrideCase.
@Test
public void solveMethodOverrideCase() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedMethodDeclaration> ref = context.solveMethod("foo1", ImmutableList.of(), false, new ReflectionTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("A", ref.getCorrespondingDeclaration().declaringType().getName());
assertEquals(0, ref.getCorrespondingDeclaration().getNumberOfParams());
}
use of com.github.javaparser.ast.body.ClassOrInterfaceDeclaration 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.ast.body.ClassOrInterfaceDeclaration 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