INRIA / spoon

Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.

Home Page:http://spoon.gforge.inria.fr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: When I use IncrementalLauncher, if I set setShouldCompile to false, it will always rebuild

honghao12 opened this issue · comments

Describe the bug

When I use IncrementalLauncher, if I set setShouldCompile to false, it will always rebuild and not use cache;

reason:

When setShouldCompile is false, the class file will not be filled into class-files, resulting in an empty folder
image

Finally, the class-files folder will be deleted
image

When analyzed again, the class-files folder doesn't exist, Leading to a constant rebuild
image

Source code you are trying to analyze/transform

No response

Source code for your Spoon processing

FilteringFolder filteringFolder = filteringFolder.addFolder(new FileSystemFolder(projectPath));      
List<SpoonFile> allSpoonFiles = filteringFolder.getAllFiles();
Set<File> allFiles = allSpoonFiles.stream().map(file -> file.toFile()).collect(Collectors.toSet());
IncrementalLauncher incrementalLauncher = new IncrementalLauncher(allFiles, Collections.EMPTY_SET, new File(dataCollector.project.getOutDirStr()));
incrementalLauncher.getEnvironment().setComplianceLevel(11);
incrementalLauncher.getEnvironment().setAutoImports(true);
incrementalLauncher.getEnvironment().setIgnoreDuplicateDeclarations(true);
incrementalLauncher.buildModel();

// This bug occurs only when false is set
incrementalLauncher.getEnvironment().setShouldCompile(false);
incrementalLauncher.saveCache()

Actual output

No response

Expected output

No response

Spoon Version

10.4.0

JVM Version

11

What operating system are you using?

windows