Repository: intellij-rust/intellij-rust
Issue: IndexNotReadyException exception

## Environment

* **Intellij-Rust plugin version:** 0.2.100.2662-192-nightly
* **Rust toolchain version:** rustc 1.37.0-nightly (02564de47 2019-06-10)
* **IDE name and version:** IU-192.5118.30
* **Operating system:** macOS 10.13

## Problem description
<details><summary>stacktrace</summary>
<p>

```
com.intellij.openapi.project.IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation
	at com.intellij.openapi.project.IndexNotReadyException.create(IndexNotReadyException.java:81)
	at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:773)
	at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:722)
	at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:705)
	at com.intellij.psi.stubs.StubIndexImpl.doProcessStubs(StubIndexImpl.java:306)
	at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:282)
	at com.intellij.psi.stubs.StubIndex.processElements(StubIndex.java:65)
	at org.rust.lang.core.stubs.index.RsIncludeMacroIndex$Companion.getIncludingModInternal(RsIncludeMacroIndex.kt:56)
	at org.rust.lang.core.stubs.index.RsIncludeMacroIndex$Companion.access$getIncludingModInternal(RsIncludeMacroIndex.kt:29)
	at org.rust.lang.core.stubs.index.RsIncludeMacroIndex$Companion$getIncludingMod$1.compute(RsIncludeMacroIndex.kt:45)
	at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:148)
	at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$1(CachedValueBase.java:240)
	at com.intellij.openapi.util.RecursionManager$1.doPreventingRecursion(RecursionManager.java:113)
	at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:71)
	at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:241)
	at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
	at com.intellij.util.CachedValuesManagerImpl.getCachedValueFromExHolder(CachedValuesManagerImpl.java:72)
	at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:45)
	at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:147)
	at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:129)
	at org.rust.lang.core.stubs.index.RsIncludeMacroIndex$Companion.getIncludingMod(RsIncludeMacroIndex.kt:43)
	at org.rust.lang.core.macros.RsExpandedElement$Companion.getContextImpl(RsExpandedElement.kt:32)
	at org.rust.lang.core.psi.ext.RsMacroCallImplMixin.getContext(RsMacroCall.kt:31)
	at com.intellij.psi.util.PsiTreeUtil.getContextOfType(PsiTreeUtil.java:637)
	at org.rust.lang.core.psi.ext.RsModificationTrackerOwnerKt.findModificationTrackerOwner(RsModificationTrackerOwner.kt:36)
	at org.rust.lang.core.psi.RsPsiManagerImpl.updateModificationCount(RsPsiManager.kt:123)
	at org.rust.lang.core.psi.RsPsiManagerImpl.access$updateModificationCount(RsPsiManager.kt:56)
	at org.rust.lang.core.psi.RsPsiManagerImpl$CacheInvalidator.handleEvent(RsPsiManager.kt:103)
	at org.rust.lang.core.psi.RsPsiTreeChangeAdapter.beforeChildRemoval(RsPsiTreeChangeListener.kt:211)
	at com.intellij.psi.impl.PsiManagerImpl.fireEvent(PsiManagerImpl.java:362)
	at com.intellij.psi.impl.PsiManagerImpl.beforeChildRemoval(PsiManagerImpl.java:218)
	at com.intellij.psi.impl.DiffLog$DeleteEntry.doActualPsiChange(DiffLog.java:141)
	at com.intellij.psi.impl.DiffLog.performActualPsiChange(DiffLog.java:44)
	at com.intellij.psi.impl.DiffLog$1.runInner(DiffLog.java:270)
	at com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:46)
	at com.intellij.pom.core.impl.PomModelImpl.lambda$null$1(PomModelImpl.java:151)
	at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:564)
	at com.intellij.pom.core.impl.PomModelImpl.lambda$runTransaction$2(PomModelImpl.java:144)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:194)
	at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:135)
	at com.intellij.psi.impl.DiffLog.lambda$doActualPsiChange$0(DiffLog.java:267)
	at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.lambda$performActionWithFormatterDisabled$6(CodeStyleManagerImpl.java:703)
	at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:108)
	at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.lambda$performActionWithFormatterDisabled$8(CodeStyleManagerImpl.java:732)
	at com.intellij.formatting.FormatterImpl.runWithFormattingDisabled(FormatterImpl.java:691)
	at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:730)
	at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:702)
	at com.intellij.psi.impl.DiffLog.doActualPsiChange(DiffLog.java:255)
	at com.intellij.psi.impl.DocumentCommitThread.lambda$doCommit$8(DocumentCommitThread.java:702)
	at com.intellij.psi.impl.PsiDocumentManagerBase.commitToExistingPsi(PsiDocumentManagerBase.java:397)
	at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$finishCommitInWriteAction$1(PsiDocumentManagerBase.java:369)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:593)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:539)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:199)
	at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommitInWriteAction(PsiDocumentManagerBase.java:364)
	at com.intellij.psi.impl.PsiDocumentManagerImpl.finishCommitInWriteAction(PsiDocumentManagerImpl.java:145)
	at com.intellij.psi.impl.PsiDocumentManagerBase$1.run(PsiDocumentManagerBase.java:325)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:997)
	at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommit(PsiDocumentManagerBase.java:332)
	at com.intellij.psi.impl.DocumentCommitThread.lambda$createFinishCommitInEDTRunnable$5(DocumentCommitThread.java:488)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:82)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:106)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:433)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:416)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:782)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:731)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:396)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:707)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:395)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
```

</p>
</details>

## Steps to reproduce

<!--
Please include as much of your codebase as needed to reproduce the error.
If the relevant files are large, please provide a link to a public repository or a [Gist](https://gist.github.com/).
-->


Changed files:
src/main/kotlin/org/rust/lang/core/psi/RsPsiManager.kt

diff --git a/src/main/kotlin/org/rust/lang/core/psi/RsPsiManager.kt b/src/main/kotlin/org/rust/lang/core/psi/RsPsiManager.kt
index 7de2f55c1..1dd57b499 100644
--- a/src/main/kotlin/org/rust/lang/core/psi/RsPsiManager.kt
+++ b/src/main/kotlin/org/rust/lang/core/psi/RsPsiManager.kt
@@ -8,6 +8,7 @@ package org.rust.lang.core.psi
 import com.intellij.ProjectTopics
 import com.intellij.injected.editor.VirtualFileWindow
 import com.intellij.openapi.components.ProjectComponent
+import com.intellij.openapi.project.DumbService
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.roots.ModuleRootEvent
 import com.intellij.openapi.roots.ModuleRootListener
@@ -120,7 +121,7 @@ class RsPsiManagerImpl(val project: Project) : ProjectComponent, RsPsiManager {
         // about it because it is a rare case and implementing it differently
         // is much more difficult.
 
-        val owner = psi.findModificationTrackerOwner(!isChildrenChange)
+        val owner = if (DumbService.isDumb(project)) null else psi.findModificationTrackerOwner(!isChildrenChange)
         if (owner == null || !owner.incModificationCount(psi)) {
             incRustStructureModificationCount(file, psi)
         }