});
}
@Override
protected CompilationUnit createCompilationUnit(CompilerConfiguration configuration, CodeSource source) {
CompilationUnit cu = super.createCompilationUnit(configuration, source);
getLocalCompilationUnit().set(cu);
final StringSetMap cache = getDepCache().get();
// "." is used to transfer compilation dependencies, which will be
// recollected later during compilation
for (String depSourcePath : cache.get(".")) {
try {
cu.addSource(getResourceConnection(depSourcePath).getURL());
} catch (ResourceException e) {
/* ignore */
}
}
// remove all old entries including the "." entry
cache.clear();
cu.addPhaseOperation(new CompilationUnit.PrimaryClassNodeOperation() {
@Override
public void call(final SourceUnit source, GeneratorContext context, ClassNode classNode)
throws CompilationFailedException {
// GROOVY-4013: If it is an inner class, tracking its dependencies doesn't really
// serve any purpose and also interferes with the caching done to track dependencies
if (classNode instanceof InnerClassNode) return;
DependencyTracker dt = new DependencyTracker(source, cache);
dt.visitClass(classNode);
}
}, Phases.CLASS_GENERATION);
final List<CompilationCustomizer> customizers = config.getCompilationCustomizers();
if (customizers!=null) {
// GROOVY-4813 : apply configuration customizers
for (CompilationCustomizer customizer : customizers) {
cu.addPhaseOperation(customizer, customizer.getPhase().getPhaseNumber());
}
}
return cu;
}