void () { PsiFile file = findFile(createFile()); assertNotNull(file); assertTrue(file.isPhysical()); final Document document = getDocument(file); assertNotNull(document); final Semaphore semaphore = new Semaphore(); semaphore.down(); getPsiDocumentManager().performWhenAllCommitted(() -> { assertTrue(getPsiDocumentManager().isCommitted(document)); semaphore.up(); }); waitAndPump(semaphore); assertTrue(getPsiDocumentManager().isCommitted(document)); WriteCommandAction.runWriteCommandAction(null, () -> document.insertString(0, "class X {}")); semaphore.down(); getPsiDocumentManager().performWhenAllCommitted(() -> { assertTrue(getPsiDocumentManager().isCommitted(document)); semaphore.up(); }); waitAndPump(semaphore); assertTrue(getPsiDocumentManager().isCommitted(document)); final AtomicInteger count = new AtomicInteger(); WriteCommandAction.runWriteCommandAction(null, () -> { document.insertString(0, "/**/"); boolean executed = getPsiDocumentManager().cancelAndRunWhenAllCommitted("xxx", count::incrementAndGet); assertFalse(executed); executed = getPsiDocumentManager().cancelAndRunWhenAllCommitted("xxx", count::incrementAndGet); assertFalse(executed); assertEquals(0, count.get()); }); while (!getPsiDocumentManager().isCommitted(document)) { UIUtil.dispatchAllInvocationEvents(); } assertTrue(getPsiDocumentManager().isCommitted(document)); assertEquals(1, count.get()); count.set(0); WriteCommandAction.runWriteCommandAction(null, () -> { document.insertString(0, "/**/"); boolean executed = getPsiDocumentManager().performWhenAllCommitted(count::incrementAndGet); assertFalse(executed); executed = getPsiDocumentManager().performWhenAllCommitted(count::incrementAndGet); assertFalse(executed); assertEquals(0, count.get()); }); while (!getPsiDocumentManager().isCommitted(document)) { UIUtil.dispatchAllInvocationEvents(); } assertTrue(getPsiDocumentManager().isCommitted(document)); assertEquals(2, count.get()); }