PsiFile (@NotNull PsiFileStub<?> stub) { ApplicationManager.getApplication().assertReadAccessAllowed(); String reason = stub.getInvalidationReason(); PsiInvalidElementAccessException exception = new PsiInvalidElementAccessException(myStub.getPsi(), "no psi for file stub " + stub + " ("+stub.getClass()+"), invalidation reason=" + reason, null); if (PsiFileImpl.STUB_PSI_MISMATCH.equals(reason)) { // we're between finding stub-psi mismatch and the next EDT spot where the file is reparsed and stub rebuilt // see com.intellij.psi.impl.source.PsiFileImpl.rebuildStub() // most likely it's just another highlighting thread accessing the same PSI concurrently and not yet canceled, so cancel it throw new ProcessCanceledException(exception); } throw exception; }