From ad1a143842e1285292250a3c4d6579144b0a27a6 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 27 Nov 2009 20:22:48 +0300 Subject: [PATCH] fix CacheUpdateSession.updatingDone() assertion --- .../intellij/openapi/project/CacheUpdateRunner.java | 20 +++++++++++++------- .../intellij/openapi/project/CacheUpdateSession.java | 7 ++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java index 180ff556ea..47100309d9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java @@ -59,20 +59,27 @@ class CacheUpdateRunner { Consumer progressUpdater = new Consumer() { // need set here to handle queue.pushbacks after checkCancelled() in order // not to count the same file several times - Set processed = new THashSet(); + final Set processed = new THashSet(); public void consume(VirtualFile virtualFile) { indicator.checkCanceled(); - indicator.setFraction(processed.size() / total); processed.add(virtualFile); - indicator.setText2(virtualFile.getPresentableUrl()); + indicator.setFraction(processed.size() / total); + if (virtualFile.isValid()) { + indicator.setText2(virtualFile.getPresentableUrl()); + } + else { + indicator.setText2(""); + } } }; while (!myProject.isDisposed()) { indicator.checkCanceled(); // todo wait for the user... - if (processSomeFilesWhileUserIsInactive(queue, progressUpdater, mySession, processInReadAction)) break; + if (processSomeFilesWhileUserIsInactive(queue, progressUpdater, mySession, processInReadAction)) { + break; + } } if (myProject.isDisposed()) { @@ -125,14 +132,13 @@ class CacheUpdateRunner { } try { - Runnable action = new Runnable() { + final Runnable action = new Runnable() { public void run() { innerIndicator.checkCanceled(); - VirtualFile file = fileContent.getVirtualFile(); - if (!file.isValid()) return; if (myProject.isDisposed()) return; + final VirtualFile file = fileContent.getVirtualFile(); progressUpdater.consume(file); session.processFile(fileContent); } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateSession.java b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateSession.java index 962b7eb83f..7c48de1321 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateSession.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateSession.java @@ -29,7 +29,7 @@ import java.util.*; public class CacheUpdateSession { private static final Logger LOG = Logger.getInstance("#" + CacheUpdateSession.class.getName()); - private static final Key FILED_TO_INDEX = Key.create(CacheUpdateSession.class.getSimpleName() + ".FAILED_TO_INDEX"); + private static final Key FAILED_TO_INDEX = Key.create(CacheUpdateSession.class.getSimpleName() + ".FAILED_TO_INDEX"); private final Collection myFilesToUpdate; private final List>> myUpdatersWithFiles = new ArrayList>>(); @@ -69,6 +69,7 @@ public class CacheUpdateSession { public void processFile(FileContent content) { VirtualFile file = content.getVirtualFile(); + boolean isValid = file.isValid(); Iterator>> it = myUpdatersWithFiles.iterator(); while (it.hasNext()) { @@ -79,7 +80,7 @@ public class CacheUpdateSession { if (!eachFiles.contains(file)) continue; try { - if (!Boolean.TRUE.equals(file.getUserData(FILED_TO_INDEX))) { + if (isValid && !Boolean.TRUE.equals(file.getUserData(FAILED_TO_INDEX))) { eachUpdater.processFile(content); } } @@ -88,7 +89,7 @@ public class CacheUpdateSession { } catch (Throwable e) { LOG.error("Error while indexing " + file.getPresentableUrl() + "\n" + "To reindex this file IDEA has to be restarted", e); - file.putUserData(FILED_TO_INDEX, Boolean.TRUE); + file.putUserData(FAILED_TO_INDEX, Boolean.TRUE); } eachFiles.remove(file); -- 2.11.4.GIT