Search in sources :

Example 1 with CombinedTypeSolver

use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.

the class JavassistClassDeclarationTest method setup.

@Before
public void setup() throws IOException {
    String pathToJar = adaptPath("src/test/resources/javaparser-core-2.1.0.jar");
    typeSolver = new CombinedTypeSolver(new JarTypeSolver(pathToJar), new ReflectionTypeSolver());
    String newPathToJar = adaptPath("src/test/resources/javaparser-core-3.0.0-alpha.2.jar");
    newTypeSolver = new CombinedTypeSolver(new JarTypeSolver(newPathToJar), new ReflectionTypeSolver());
    String anotherPathToJar = adaptPath("src/test/resources/test-artifact-1.0.0.jar");
    anotherTypeSolver = new CombinedTypeSolver(new JarTypeSolver(anotherPathToJar), new ReflectionTypeSolver());
}
Also used : JarTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) CombinedTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver) Before(org.junit.Before)

Example 2 with CombinedTypeSolver

use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.

the class JavassistInterfaceDeclarationTest method setup.

@Before
public void setup() throws IOException {
    String pathToJar = adaptPath("src/test/resources/javaparser-core-3.0.0-alpha.2.jar");
    typeSolver = new CombinedTypeSolver(new JarTypeSolver(pathToJar), new ReflectionTypeSolver());
    String anotherPathToJar = adaptPath("src/test/resources/test-artifact-1.0.0.jar");
    anotherTypeSolver = new CombinedTypeSolver(new JarTypeSolver(anotherPathToJar), new ReflectionTypeSolver());
}
Also used : JarTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) CombinedTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver) Before(org.junit.Before)

Example 3 with CombinedTypeSolver

use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.

the class DifferentiateDotExpressionTest method setup.

@Before
public void setup() {
    CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
    combinedTypeSolver.add(new ReflectionTypeSolver());
    combinedTypeSolver.add(new JavaParserTypeSolver(adaptPath(new File("src/test/resources/differentiate_dot_expressions"))));
    typeSolver = combinedTypeSolver;
}
Also used : JavaParserTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) File(java.io.File) CombinedTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver) Before(org.junit.Before)

Example 4 with CombinedTypeSolver

use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.

the class JavaParserAnonymousClassDeclarationTest method callingSuperClassInnerClassMethod.

@Test
public void callingSuperClassInnerClassMethod() {
    CompilationUnit cu = parseSample("AnonymousClassDeclarations");
    ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
    MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar2");
    MethodCallExpr methodCall = Navigator.findMethodCall(method, "innerClassMethod").get();
    CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
    combinedTypeSolver.add(new ReflectionTypeSolver());
    MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
    assertThat(methodUsage.getQualifiedSignature(), is("AnonymousClassDeclarations.DoFn.ProcessContext.innerClassMethod()"));
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) MethodUsage(com.github.javaparser.resolution.MethodUsage) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) CombinedTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) AbstractResolutionTest(com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest) Test(org.junit.Test)

Example 5 with CombinedTypeSolver

use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.

the class Issue257 method setup.

@Before
public void setup() throws IOException {
    String pathToJar = adaptPath("src/test/resources/issue257/issue257.jar");
    File jar = new File(pathToJar);
    typeSolver = new CombinedTypeSolver(new JarTypeSolver(jar.getAbsolutePath()), new ReflectionTypeSolver());
}
Also used : JarTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) File(java.io.File) CombinedTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver) Before(org.junit.Before)

Aggregations

CombinedTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver)49 ReflectionTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver)46 CompilationUnit (com.github.javaparser.ast.CompilationUnit)23 JavaParserTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver)22 Test (org.junit.Test)21 File (java.io.File)20 AbstractResolutionTest (com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest)19 JarTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver)15 Before (org.junit.Before)15 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)12 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)11 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)9 MethodUsage (com.github.javaparser.resolution.MethodUsage)9 Context (com.github.javaparser.symbolsolver.core.resolution.Context)9 JavaParserFacade (com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade)6 CompilationUnitContext (com.github.javaparser.symbolsolver.javaparsermodel.contexts.CompilationUnitContext)6 TypeSolver (com.github.javaparser.symbolsolver.model.resolution.TypeSolver)6 Value (com.github.javaparser.symbolsolver.model.resolution.Value)4 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)3 SourceFileInfoExtractor (com.github.javaparser.symbolsolver.SourceFileInfoExtractor)3