use of com.github.javaparser.ParseResult in project javaparser by javaparser.
the class SourceRoot method saveAll.
/**
* Save all previously parsed files back to a new path.
*/
public SourceRoot saveAll(Path root) {
assertNotNull(root);
Log.info("Saving all files (%s) to %s", cache.size(), root);
for (Map.Entry<Path, ParseResult<CompilationUnit>> cu : cache.entrySet()) {
final Path path = root.resolve(cu.getKey());
if (cu.getValue().getResult().isPresent()) {
Log.trace("Saving %s", path);
save(cu.getValue().getResult().get(), path);
}
}
return this;
}
use of com.github.javaparser.ParseResult in project scheduler by btrplace.
the class DSN method specLength.
// @Test
public void specLength() throws Exception {
SpecScanner sc = new SpecScanner();
List<Constraint> l = sc.scan();
System.out.println(l.stream().map(Constraint::pretty).collect(Collectors.joining("\n")));
Path path = Paths.get(root, "inv.csv");
String out = l.stream().map(c -> Integer.toString(c.proposition().toString().length())).collect(Collectors.joining("\n"));
Files.write(path, out.getBytes());
List<Integer> funcs = new ArrayList<>();
List<Path> paths = Files.list(Paths.get("safeplace/src/main/java/org/btrplace/safeplace/spec/term/func")).filter(Files::isRegularFile).collect(Collectors.toList());
for (Path p : paths) {
try (InputStream in = Files.newInputStream(p)) {
ParseResult<CompilationUnit> cu = new JavaParser().parse(in);
new FunctionVisitor(funcs).visit(cu.getResult().get(), null);
}
}
path = Paths.get(root, "func.csv");
out = funcs.stream().map(c -> Integer.toString(c)).collect(Collectors.joining("\n"));
Files.write(path, out.getBytes());
}
Aggregations