Search in sources :

Example 6 with JavaParserTypeSolver

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

the class AnalyseJavaSymbolSolver060Test method getSourceFileInfoExtractor.

private static SourceFileInfoExtractor getSourceFileInfoExtractor() {
    CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
    combinedTypeSolver.add(new ReflectionTypeSolver());
    combinedTypeSolver.add(new JavaParserTypeSolver(new File(src + "/java-symbol-solver-core")));
    combinedTypeSolver.add(new JavaParserTypeSolver(new File(src + "/java-symbol-solver-logic")));
    combinedTypeSolver.add(new JavaParserTypeSolver(new File(src + "/java-symbol-solver-model")));
    try {
        combinedTypeSolver.add(new JarTypeSolver(lib + "/guava-21.0.jar"));
        combinedTypeSolver.add(new JarTypeSolver(lib + "/javaparser-core-3.3.0.jar"));
        combinedTypeSolver.add(new JarTypeSolver(lib + "/javaslang-2.0.3.jar"));
        combinedTypeSolver.add(new JarTypeSolver(lib + "/javassist-3.19.0-GA.jar"));
    } catch (IOException e) {
        Assert.fail("one or more jar dependencies could not be found.");
        e.printStackTrace();
    }
    SourceFileInfoExtractor sourceFileInfoExtractor = new SourceFileInfoExtractor();
    sourceFileInfoExtractor.setTypeSolver(combinedTypeSolver);
    sourceFileInfoExtractor.setPrintFileName(false);
    sourceFileInfoExtractor.setVerbose(true);
    return sourceFileInfoExtractor;
}
Also used : SourceFileInfoExtractor(com.github.javaparser.symbolsolver.SourceFileInfoExtractor) JavaParserTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver) JarTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) CombinedTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver)

Example 7 with JavaParserTypeSolver

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

the class AnalyseNewJavaParserTest method getSourceFileInfoExtractor.

private static SourceFileInfoExtractor getSourceFileInfoExtractor() {
    CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
    combinedTypeSolver.add(new ReflectionTypeSolver());
    combinedTypeSolver.add(new JavaParserTypeSolver(src));
    combinedTypeSolver.add(new JavaParserTypeSolver(adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources"))));
    SourceFileInfoExtractor sourceFileInfoExtractor = new SourceFileInfoExtractor();
    sourceFileInfoExtractor.setTypeSolver(combinedTypeSolver);
    sourceFileInfoExtractor.setPrintFileName(false);
    sourceFileInfoExtractor.setVerbose(true);
    return sourceFileInfoExtractor;
}
Also used : SourceFileInfoExtractor(com.github.javaparser.symbolsolver.SourceFileInfoExtractor) JavaParserTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) CombinedTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver)

Example 8 with JavaParserTypeSolver

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

the class Issue144 method setup.

@Before
public void setup() throws IOException {
    File srcDir = adaptPath(new File("src/test/resources/issue144"));
    typeSolver = new JavaParserTypeSolver(srcDir);
}
Also used : JavaParserTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver) File(java.io.File) Before(org.junit.Before)

Example 9 with JavaParserTypeSolver

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

the class Issue185 method testIssue.

@Test
public void testIssue() throws FileNotFoundException {
    File src = adaptPath(new File("src/test/resources/recursion-issue"));
    CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
    combinedTypeSolver.add(new JavaParserTypeSolver(src));
    combinedTypeSolver.add(new ReflectionTypeSolver());
    CompilationUnit agendaCu = JavaParser.parse(adaptPath(new File("src/test/resources/recursion-issue/Usage.java")));
    MethodCallExpr foo = Navigator.findMethodCall(agendaCu, "foo").get();
    assertNotNull(foo);
    JavaParserFacade.get(combinedTypeSolver).getType(foo);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) 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) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) AbstractResolutionTest(com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest) Test(org.junit.Test)

Example 10 with JavaParserTypeSolver

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

the class Issue128 method setup.

@Before
public void setup() throws IOException {
    File srcDir = adaptPath(new File("src/test/resources/issue128"));
    typeSolver = new CombinedTypeSolver(new ReflectionTypeSolver(), new JavaParserTypeSolver(srcDir));
}
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)

Aggregations

JavaParserTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver)23 CombinedTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver)22 ReflectionTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver)22 File (java.io.File)20 CompilationUnit (com.github.javaparser.ast.CompilationUnit)9 Before (org.junit.Before)9 Test (org.junit.Test)8 TypeSolver (com.github.javaparser.symbolsolver.model.resolution.TypeSolver)6 AbstractResolutionTest (com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest)6 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)5 JavaParserFacade (com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade)4 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)3 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)3 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)3 SourceFileInfoExtractor (com.github.javaparser.symbolsolver.SourceFileInfoExtractor)3 LambdaExpr (com.github.javaparser.ast.expr.LambdaExpr)2 ResolvedReferenceType (com.github.javaparser.resolution.types.ResolvedReferenceType)2 Context (com.github.javaparser.symbolsolver.core.resolution.Context)2 LambdaExprContext (com.github.javaparser.symbolsolver.javaparsermodel.contexts.LambdaExprContext)2 Value (com.github.javaparser.symbolsolver.model.resolution.Value)2