return myFilesToUpdate.size();
}
private void updateFiles() {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.pushState();
indicator.setText(IdeBundle.message("progress.parsing.files"));
}
int totalFiles = myFilesToUpdate.size();
final MyContentQueue contentQueue = new MyContentQueue();
final Runnable contentLoadingRunnable = new Runnable() {
public void run() {
try {
for (VirtualFile file : myFilesToUpdate) {
if (indicator != null) indicator.checkCanceled();
contentQueue.put(file);
}
}
catch (ProcessCanceledException e) {
// Do nothing, exit the thread.
}
catch (InterruptedException e) {
LOG.error(e);
}
finally {
try {
contentQueue.put(new FileContent(null));
}
catch (InterruptedException e) {
LOG.error(e);
}
}
}
};
ApplicationManager.getApplication().executeOnPooledThread(contentLoadingRunnable);
int count = 0;
while (true) {
FileContent content = null;
try {
content = contentQueue.take();
}
catch (InterruptedException e) {
LOG.error(e);
}
if (content == null) break;
final VirtualFile file = content.getVirtualFile();
if (file == null) break;
if (indicator != null) {
indicator.checkCanceled();
indicator.setFraction((double)++count / totalFiles);
indicator.setText2(file.getPresentableUrl());
}
for (int i = 0; i < myUpdaters.size(); i++) {
CacheUpdater updater = myUpdaters.get(i);
if (myUpdateSets[i].remove(file)) {
try {
updater.processFile(content);
}
catch (ProcessCanceledException e) {
throw e;
}
catch (Throwable e) {
LOG.error(e);
}
if (myUpdateSets[i].isEmpty()) {
try {
updater.updatingDone();
}
catch (ProcessCanceledException e) {
throw e;
}
catch (Throwable e) {
LOG.error(e);
}
myUpdaters.set(i, null);
}
}
}
}
updatingDone();
if (indicator != null) {
indicator.popState();
}
}