use of com.intellij.compiler.impl.generic.GenericCompilerPersistentData in project intellij-community by JetBrains.
the class GenericCompilerRunner method invokeCompiler.
private <T extends BuildTarget, Item extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState> boolean invokeCompiler(GenericCompiler<Key, SourceState, OutputState> compiler, final GenericCompilerInstance<T, Item, Key, SourceState, OutputState> instance) throws IOException, ExitException {
final GenericCompilerCache<Key, SourceState, OutputState> cache = CompilerCacheManager.getInstance(myProject).getGenericCompilerCache(compiler);
GenericCompilerPersistentData data = new GenericCompilerPersistentData(getGenericCompilerCacheDir(myProject, compiler), compiler.getVersion());
if (data.isVersionChanged()) {
LOG.info("Clearing cache for " + compiler.getDescription());
cache.wipe();
data.save();
}
final Set<String> targetsToRemove = new HashSet<>(data.getAllTargets());
new ReadAction() {
protected void run(@NotNull final Result result) {
for (T target : instance.getAllTargets()) {
targetsToRemove.remove(target.getId());
}
}
}.execute();
if (!myOnlyCheckStatus) {
for (final String target : targetsToRemove) {
final int id = data.removeId(target);
if (LOG.isDebugEnabled()) {
LOG.debug("Removing obsolete target '" + target + "' (id=" + id + ")");
}
final List<Key> keys = new ArrayList<>();
CompilerUtil.runInContext(myContext, "Processing obsolete targets...", () -> {
cache.processSources(id, new CommonProcessors.CollectProcessor<>(keys));
List<GenericCompilerCacheState<Key, SourceState, OutputState>> obsoleteSources = new ArrayList<>();
for (Key key : keys) {
final GenericCompilerCache.PersistentStateData<SourceState, OutputState> state = cache.getState(id, key);
obsoleteSources.add(new GenericCompilerCacheState<>(key, state.mySourceState, state.myOutputState));
}
instance.processObsoleteTarget(target, obsoleteSources);
});
checkForErrorsOrCanceled();
for (Key key : keys) {
cache.remove(id, key);
}
}
}
final List<T> selectedTargets = new ReadAction<List<T>>() {
protected void run(@NotNull final Result<List<T>> result) {
result.setResult(instance.getSelectedTargets());
}
}.execute().getResultObject();
boolean didSomething = false;
for (T target : selectedTargets) {
int id = data.getId(target.getId());
didSomething |= processTarget(target, id, compiler, instance, cache);
}
data.save();
return didSomething;
}
Aggregations