void () { if (resolveHappened.get() && (!ApplicationManager.getApplication().isDispatchThread() && ApplicationManager.getApplication().isReadAccessAllowed() || ApplicationManager.getApplication().isWriteAccessAllowed())) { return; // optimization: try not to call getStackTrace() if we can } boolean isFromResolve = isInsideResolve.getAsBoolean(); ; if (isFromResolve) resolveHappened.set(true); assertTrue("Resolve in EDT happened", !isFromResolve || !ApplicationManager.getApplication().isDispatchThread() && ApplicationManager.getApplication().isReadAccessAllowed() // allow resolve from the background thread || ApplicationManager.getApplication().isWriteAccessAllowed()); // allow resolve in the write action because that's how PsiReference.bindToElement() works }