use of com.github.javaparser.symbolsolver.SourceFileInfoExtractor 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;
}
use of com.github.javaparser.symbolsolver.SourceFileInfoExtractor 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;
}
use of com.github.javaparser.symbolsolver.SourceFileInfoExtractor in project javaparser by javaparser.
the class AnalyseJavaParserTest method getSourceFileInfoExtractor.
private 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_src/generated"))));
SourceFileInfoExtractor sourceFileInfoExtractor = new SourceFileInfoExtractor();
sourceFileInfoExtractor.setTypeSolver(combinedTypeSolver);
sourceFileInfoExtractor.setPrintFileName(false);
return sourceFileInfoExtractor;
}
use of com.github.javaparser.symbolsolver.SourceFileInfoExtractor in project javaparser by javaparser.
the class AnalyseJavaParserTest method parse.
private void parse(String fileName) throws IOException, ParseException {
File sourceFile = new File(src.getAbsolutePath() + "/" + fileName + ".java");
SourceFileInfoExtractor sourceFileInfoExtractor = getSourceFileInfoExtractor();
OutputStream outErrStream = new ByteArrayOutputStream();
PrintStream outErr = new PrintStream(outErrStream);
sourceFileInfoExtractor.setOut(outErr);
sourceFileInfoExtractor.setErr(outErr);
sourceFileInfoExtractor.solve(sourceFile);
String output = outErrStream.toString();
String path = "src/test/resources/javaparser_expected_output/" + fileName.replaceAll("/", "_") + ".txt";
File dstFile = adaptPath(new File(path));
if (DEBUG && (sourceFileInfoExtractor.getKo() != 0 || sourceFileInfoExtractor.getUnsupported() != 0)) {
System.err.println(output);
}
assertTrue("No failures expected when analyzing " + path, 0 == sourceFileInfoExtractor.getKo());
assertTrue("No UnsupportedOperationException expected when analyzing " + path, 0 == sourceFileInfoExtractor.getUnsupported());
String expected = readFile(dstFile);
String[] outputLines = output.split("\n");
String[] expectedLines = expected.split("\n");
for (int i = 0; i < Math.min(outputLines.length, expectedLines.length); i++) {
assertEquals("Line " + (i + 1) + " of " + path + " is different from what is expected", expectedLines[i].trim(), outputLines[i].trim());
}
assertEquals(expectedLines.length, outputLines.length);
JavaParserFacade.clearInstances();
// If we need to update the file uncomment these lines
// PrintWriter writer = new PrintWriter(dstFile.getAbsoluteFile(), "UTF-8");
// writer.print(output);
// writer.close();
}
Aggregations