void () { myStructure.setProviders(new ClassesTreeStructureProvider(myProject)); myStructure.setHideEmptyMiddlePackages(true); myStructure.setShowMembers(true); myStructure.setShowLibraryContents(false); PsiDirectory directory = getPackageDirectory("com/company"); AbstractProjectViewPane pane = myStructure.createPane(); JTree tree = pane.getTree(); assertTreeEqual(tree, " +PsiDirectory: hideEmptyMiddlePackages\n"); TreeUtil.promiseExpandAll(tree); assertTreeEqual(tree, " -PsiDirectory: hideEmptyMiddlePackages\n" + " -PsiDirectory: src\n" + " -PsiDirectory: name\n" + // com.company.name " -I\n" + " m():void\n"); directory = createSubdirectory(directory, "a"); // PSI listener is notified synchronously and starts modifying new tree model // unfortunately this approach does not work for old tree builders AbstractTreeBuilder builder = pane.getTreeBuilder(); if (builder != null) builder.queueUpdateFrom(directory, true); PlatformTestUtil.waitWhileBusy(tree); TreeUtil.promiseExpandAll(tree); assertTreeEqual(tree, " -PsiDirectory: hideEmptyMiddlePackages\n" + " -PsiDirectory: src\n" + " -PsiDirectory: company\n" + // com.company " PsiDirectory: a\n" + " -PsiDirectory: name\n" + " -I\n" + " m():void\n"); directory = createSubdirectory(directory, "b"); if (builder != null) builder.queueUpdateFrom(directory, true); assertTreeEqual(tree, " -PsiDirectory: hideEmptyMiddlePackages\n" + " -PsiDirectory: src\n" + " -PsiDirectory: company\n" + // com.company " PsiDirectory: b\n" + // a.b " -PsiDirectory: name\n" + " -I\n" + " m():void\n"); directory = createSubdirectory(directory, "z"); if (builder != null) builder.queueUpdateFrom(directory, true); assertTreeEqual(tree, " -PsiDirectory: hideEmptyMiddlePackages\n" + " -PsiDirectory: src\n" + " -PsiDirectory: company\n" + // com.company " PsiDirectory: z\n" + // a.b.z " -PsiDirectory: name\n" + " -I\n" + " m():void\n"); }