use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.ClassOrInterfaceDeclarationContext in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodAsUsageOverrideCase.
@Test
public void solveMethodAsUsageOverrideCase() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<MethodUsage> ref = context.solveMethodAsUsage("foo1", ImmutableList.of(), new ReflectionTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("A", ref.get().declaringType().getName());
assertEquals(0, ref.get().getNoParams());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.ClassOrInterfaceDeclarationContext 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.javaparsermodel.contexts.ClassOrInterfaceDeclarationContext 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());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.ClassOrInterfaceDeclarationContext in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveTypeRefToInternalOfInternalClass.
@Test
public void solveTypeRefToInternalOfInternalClass() {
CompilationUnit cu = parseSample("ClassWithTypes");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("C", new MemoryTypeSolver());
assertEquals(false, ref.isSolved());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.ClassOrInterfaceDeclarationContext in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveUnexistingGenericType.
@Test
public void solveUnexistingGenericType() {
CompilationUnit cu = parseSample("ClassWithTypeVariables");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<ResolvedType> d = context.solveGenericType("D", new MemoryTypeSolver());
assertEquals(false, d.isPresent());
}
Aggregations