use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.CompilationUnitContext in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method solveTypeImported.
@Test
public void solveTypeImported() throws ParseException, IOException {
CompilationUnit cu = parseSample("CompilationUnitWithImports");
Context context = new CompilationUnitContext(cu, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("Assert", new JarTypeSolver(adaptPath("src/test/resources/junit-4.8.1.jar")));
assertEquals(true, ref.isSolved());
assertEquals("org.junit.Assert", ref.getCorrespondingDeclaration().getQualifiedName());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.CompilationUnitContext in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method solveSymbolReferringToStaticField.
@Test
public void solveSymbolReferringToStaticField() throws ParseException, IOException {
CompilationUnit cu = parseSample("CompilationUnitSymbols");
Context context = new CompilationUnitContext(cu, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("java.lang.System.out", new ReflectionTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("java.io.PrintStream", ref.getCorrespondingDeclaration().getType().asReferenceType().getQualifiedName());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.CompilationUnitContext in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method getParent.
@Test
public void getParent() {
CompilationUnit cu = parseSample("ClassWithTypeVariables");
Context context = new CompilationUnitContext(cu, typeSolver);
assertTrue(null == context.getParent());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.CompilationUnitContext in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method solveSymbolAsValueReferringToStaticField.
@Test
public void solveSymbolAsValueReferringToStaticField() throws ParseException, IOException {
CompilationUnit cu = parseSample("CompilationUnitSymbols");
Context context = new CompilationUnitContext(cu, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("java.lang.System.out", new ReflectionTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("java.io.PrintStream", ref.get().getType().describe());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.CompilationUnitContext in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method solveUnexistingGenericType.
@Test
public void solveUnexistingGenericType() {
CompilationUnit cu = parseSample("ClassWithTypeVariables");
Context context = new CompilationUnitContext(cu, typeSolver);
Optional<ResolvedType> d = context.solveGenericType("D", new MemoryTypeSolver());
assertEquals(false, d.isPresent());
}
Aggregations