use of com.github.javaparser.utils.SourceRoot in project javaparser by javaparser.
the class MetaModelGenerator method main.
public static void main(String[] args) throws IOException, NoSuchMethodException {
if (args.length != 1) {
throw new RuntimeException("Need 1 parameter: the JavaParser source checkout root directory.");
}
final Path root = Paths.get(args[0], "..", "javaparser-core", "src", "main", "java");
final SourceRoot sourceRoot = new SourceRoot(root);
sourceRoot.setPrinter(new PrettyPrinter(new PrettyPrinterConfiguration().setEndOfLineCharacter("\n"))::print);
new MetaModelGenerator().run(sourceRoot);
sourceRoot.saveAll();
}
use of com.github.javaparser.utils.SourceRoot in project javaparser by javaparser.
the class SymbolSolverQuickSetupTest method notResolve.
@Test(expected = IllegalStateException.class)
public void notResolve() throws IOException {
SourceRoot sourceRoot = new SourceRoot(root);
sourceRoot.tryToParse();
// try to resolve, this will fail
sourceRoot.getCompilationUnits().forEach(compilationUnit -> compilationUnit.findAll(ClassOrInterfaceDeclaration.class).forEach(ClassOrInterfaceDeclaration::resolve));
}
use of com.github.javaparser.utils.SourceRoot in project javaparser by javaparser.
the class SymbolSolverQuickSetupTest method resolve.
@Test
public void resolve() throws IOException {
SourceRoot sourceRoot = new SourceRoot(root, parserConfiguration);
sourceRoot.tryToParse();
// try to resolve, this should succeed
sourceRoot.getCompilationUnits().forEach(compilationUnit -> compilationUnit.findAll(ClassOrInterfaceDeclaration.class).forEach(ClassOrInterfaceDeclaration::resolve));
}
use of com.github.javaparser.utils.SourceRoot in project javaparser by javaparser.
the class CoreGenerator method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new RuntimeException("Need 1 parameter: the JavaParser source checkout root directory.");
}
Log.setAdapter(new Log.StandardOutStandardErrorAdapter());
final Path root = Paths.get(args[0], "..", "javaparser-core", "src", "main", "java");
final SourceRoot sourceRoot = new SourceRoot(root, parserConfiguration);
final Path generatedJavaCcRoot = Paths.get(args[0], "..", "javaparser-core", "target", "generated-sources", "javacc");
final SourceRoot generatedJavaCcSourceRoot = new SourceRoot(generatedJavaCcRoot, parserConfiguration);
new CoreGenerator().run(sourceRoot, generatedJavaCcSourceRoot);
sourceRoot.saveAll();
}
use of com.github.javaparser.utils.SourceRoot in project checker-framework by typetools.
the class RemoveAnnotationsForInference method process.
/**
* Process each file in the given directory; see the {@link RemoveAnnotationsForInference class
* documentation} for details.
*
* @param dir directory to process
*/
private static void process(String dir) {
Path root = JavaStubifier.dirnameToPath(dir);
RemoveAnnotationsCallback rac = new RemoveAnnotationsCallback();
CollectionStrategy strategy = new ParserCollectionStrategy();
// Required to include directories that contain a module-info.java, which don't parse by
// default.
strategy.getParserConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_11);
ProjectRoot projectRoot = strategy.collect(root);
for (SourceRoot sourceRoot : projectRoot.getSourceRoots()) {
try {
sourceRoot.parse("", rac);
} catch (IOException e) {
throw new BugInCF(e);
}
}
}
Aggregations