void () { AtomicInteger rebuildCacheCount = new AtomicInteger(0); AllTodosTreeBuilder all = new AllTodosTreeBuilder(new Tree(), this.myProject) { @Override protected void onUpdateStarted() { } @Override protected void onUpdateFinished() { rebuildCacheCount.incrementAndGet(); } }; try { all.init(); //second rebuild, e.g. switching scope in scope based t.o.d.o panel CompletableFuture<?> rebuildCache = all.rebuildCache(); while (!rebuildCache.isDone()) { IdeEventQueue.getInstance().flushQueue(); } Assert.assertEquals(1, rebuildCacheCount.get()); TodoTreeStructure structure = all.getTodoTreeStructure(); structure.setFlattenPackages(true); ProjectViewTestUtil.assertStructureEqual(structure, """ Root Summary package2 toDoFileCount=1,toDoItemCount=2 JavaClass.java Item: (62,78) Item: (145,162) """, myPrintInfo); checkOccurrences(all, new String[]{"Item: (62,78)", "Item: (145,162)"}); } finally { Disposer.dispose(all); } }