I am using inria Spoon to parse Java projects, and then extract information about classes, Interfaces, fields, and methods and all their references.
I am using the below code to build model of an input project.
SpoonAPI spoonAPI = new Launcher();
spoonAPI.addInputResource(projectDirectory);
spoonAPI.buildModel();
CtModel ctModel = spoonAPI.getModel();
However, buildModel() is very time consuming in big projects.
PS: I used JavaParser using the below code and it is more faster than Spoon.
Path pathToSource = Paths.get(projectDirectory);
SourceRoot sourceRoot = new SourceRoot(pathToSource);
sourceRoot.tryToParse();
List<CompilationUnit> compilations = sourceRoot.getCompilationUnits();
I was wondering if there is any faster way to create the CtModel in Spoon.
Instead of parsing the full source directory, you can build the model only for the files you need to analyze or transform: