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 5059b26b9688..156dca9294a6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java @@ -27,6 +27,7 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.util.ProgressIndicatorBase; import com.intellij.openapi.progress.util.ProgressWrapper; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; @@ -40,6 +41,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public class CacheUpdateRunner { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.project.CacheUpdateRunner"); + private static final Key FAILED_TO_INDEX = Key.create("FAILED_TO_INDEX"); private static final int PROC_COUNT = Runtime.getRuntime().availableProcessors(); private final Project myProject; private final Collection myUpdaters; @@ -251,9 +253,18 @@ public class CacheUpdateRunner { myInnerIndicator.checkCanceled(); if (!myProject.isDisposed()) { final VirtualFile file = fileContent.getVirtualFile(); - if (file.isValid()) { + try { myProgressUpdater.consume(file); - myProcessor.consume(fileContent); + if (file.isValid() && !file.isDirectory() && !Boolean.TRUE.equals(file.getUserData(FAILED_TO_INDEX))) { + myProcessor.consume(fileContent); + } + } + catch (ProcessCanceledException e) { + throw e; + } + catch (Throwable e) { + LOG.error("Error while indexing " + file.getPresentableUrl() + "\n" + "To reindex this file IDEA has to be restarted", e); + file.putUserData(FAILED_TO_INDEX, Boolean.TRUE); } } } 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 9feceed488a9..288b409deecf 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateSession.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateSession.java @@ -21,7 +21,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.util.Condition; -import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; @@ -33,7 +32,6 @@ import java.util.*; public class CacheUpdateSession { private static final Logger LOG = Logger.getInstance("#" + CacheUpdateSession.class.getName()); - private static final Key FAILED_TO_INDEX = Key.create(CacheUpdateSession.class.getSimpleName() + ".FAILED_TO_INDEX"); private final List myFilesToUpdate; private final int myJobsToDo; private final List>> myUpdatersWithFiles = new ArrayList>>(); @@ -94,13 +92,14 @@ public class CacheUpdateSession { VirtualFile file = content.getVirtualFile(); boolean isValid = file.isValid() && !file.isDirectory(); + Throwable exception = null; while (true) { Pair> pair = getPair(file); - if (pair == null) return; + if (pair == null) break; CacheUpdater eachUpdater = pair.getFirst(); Collection eachFiles = pair.getSecond(); try { - if (isValid && !Boolean.TRUE.equals(file.getUserData(FAILED_TO_INDEX))) { + if (isValid && exception == null) { eachUpdater.processFile(content); } } @@ -108,11 +107,13 @@ public class CacheUpdateSession { throw e; } catch (Throwable e) { - LOG.error("Error while indexing " + file.getPresentableUrl() + "\n" + "To reindex this file IDEA has to be restarted", e); - file.putUserData(FAILED_TO_INDEX, Boolean.TRUE); + exception = e; } removeFile(file, eachUpdater, eachFiles); } + if (exception instanceof RuntimeException) throw (RuntimeException)exception; + if (exception instanceof Error) throw (Error)exception; + if (exception != null) throw new RuntimeException(exception); } private synchronized void removeFile(@NotNull VirtualFile file, @NotNull CacheUpdater eachUpdater, @NotNull Collection eachFiles) {