reparse file on next EDT loop always to avoid potential locking in FileBasedIndexImpl...
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 9 Jun 2016 12:21:16 +0000 (15:21 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 9 Jun 2016 12:21:16 +0000 (15:21 +0300)
platform/core-api/src/com/intellij/psi/LanguageSubstitutors.java

index 149ebc7b5e1959c54fe056541d5f0058f4c06e71..1dca825fd2dacead15100c21bd153beeff7374fe 100644 (file)
@@ -70,7 +70,10 @@ public final class LanguageSubstitutors extends LanguageExtension<LanguageSubsti
         if (ApplicationManager.getApplication().isDispatchThread() && myReparsingInProgress) {
           return; // avoid recursive reparsing
         }
-        invokeLaterIfNeeded(new Runnable() {
+        if (ApplicationManager.getApplication().isUnitTestMode()) {
+          return;
+        }
+        ApplicationManager.getApplication().invokeLater(new Runnable() {
           @Override
           public void run() {
             LOG.info("Reparsing " + file.getPath() + " because of language substitution " +
@@ -99,13 +102,4 @@ public final class LanguageSubstitutors extends LanguageExtension<LanguageSubsti
     }
     return lang;
   }
-
-  private static void invokeLaterIfNeeded(@NotNull Runnable runnable, @NotNull ModalityState modalityState) {
-    if (ApplicationManager.getApplication().isDispatchThread()) {
-      runnable.run();
-    }
-    else if (!ApplicationManager.getApplication().isUnitTestMode()) {
-      ApplicationManager.getApplication().invokeLater(runnable, modalityState);
-    }
-  }
 }