AbstractLayoutCodeProcessor: rethrow INRE so it can be handled (EA-91686 - INRE:...
authorpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 16:32:10 +0000 (17:32 +0100)
committerpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 17:18:28 +0000 (18:18 +0100)
platform/lang-impl/src/com/intellij/codeInsight/actions/AbstractLayoutCodeProcessor.java

index 4749a4e737c978962467339a15534d68ffb803d9..a6878c2318815bd71e2da8dfbaf3a4050ab3d74c 100644 (file)
@@ -51,6 +51,7 @@ import com.intellij.psi.PsiBundle;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiFile;
+import com.intellij.util.ExceptionUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.SequentialTask;
 import com.intellij.util.SmartList;
@@ -228,14 +229,20 @@ public abstract class AbstractLayoutCodeProcessor {
     final FutureTask<Boolean> currentTask = prepareTask(file, processChangedTextOnly);
 
     return new FutureTask<>(() -> {
-      if (previousTask != null) {
-        previousTask.run();
-        if (!previousTask.get() || previousTask.isCancelled()) return false;
-      }
+      try {
+        if (previousTask != null) {
+          previousTask.run();
+          if (!previousTask.get() || previousTask.isCancelled()) return false;
+        }
 
-      ApplicationManager.getApplication().runWriteAction(() -> currentTask.run());
+        ApplicationManager.getApplication().runWriteAction(() -> currentTask.run());
 
-      return currentTask.get() && !currentTask.isCancelled();
+        return currentTask.get() && !currentTask.isCancelled();
+      }
+      catch (ExecutionException e) {
+        ExceptionUtil.rethrowUnchecked(e);
+        throw e;
+      }
     });
   }
 
@@ -337,6 +344,12 @@ public abstract class AbstractLayoutCodeProcessor {
       }
       catch (CancellationException ignored) {
       }
+      catch (ExecutionException e) {
+        if (e.getCause() instanceof IndexNotReadyException) {
+          throw (IndexNotReadyException)e.getCause();
+        }
+        LOG.error(e);
+      }
       catch (Exception e) {
         LOG.error(e);
       }