void () { getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject)); final AbstractProjectViewPane pane = myStructure.createPane(); final JTree tree = pane.getTree(); PlatformTestUtil.assertTreeEqual(tree, """ -Project +PsiDirectory: showClassMembers +External Libraries """); myStructure.setShowMembers(true); PsiJavaFile classFile = (PsiJavaFile)getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java"); PsiClass aClass = classFile.getClasses()[0]; PsiFile containingFile = aClass.getContainingFile(); pane.select(aClass, containingFile.getVirtualFile(), true); PlatformTestUtil.waitWhileBusy(pane.getTree()); PlatformTestUtil.assertTreeEqual(pane.getTree(), """ -Project -PsiDirectory: showClassMembers -PsiDirectory: src -PsiDirectory: com -PsiDirectory: package1 -[Class1] +InnerClass getValue():int myField1:boolean myField2:boolean +Class2 +External Libraries """, true); final Document document = FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile()); final int caretPosition = document.getText().indexOf("public class InnerClass") - 1; ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(myProject, () -> document.insertString(caretPosition, "\n"), "typing", null)); PsiDocumentManager.getInstance(myProject).commitDocument(document); PlatformTestUtil.waitWhileBusy(pane.getTree()); PlatformTestUtil.assertTreeEqual(pane.getTree(), """ -Project -PsiDirectory: showClassMembers -PsiDirectory: src -PsiDirectory: com -PsiDirectory: package1 -[Class1] +InnerClass getValue():int myField1:boolean myField2:boolean +Class2 +External Libraries """, true); classFile = (PsiJavaFile)getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java"); aClass = classFile.getClasses()[0]; final PsiField lastField = aClass.getFields()[1]; pane.select(lastField, containingFile.getVirtualFile(), true); PlatformTestUtil.waitWhileBusy(pane.getTree()); PlatformTestUtil.assertTreeEqual(pane.getTree(), """ -Project -PsiDirectory: showClassMembers -PsiDirectory: src -PsiDirectory: com -PsiDirectory: package1 -Class1 +InnerClass getValue():int myField1:boolean [myField2:boolean] +Class2 +External Libraries """, true); CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> { try { assertEquals("myField2", lastField.getName()); lastField.setName("_firstField"); } catch (IncorrectOperationException e) { fail(e.getMessage()); } }), null, null); PlatformTestUtil.waitWhileBusy(pane.getTree()); if (tree.getModel() instanceof AsyncTreeModel) { // TODO:SAM new model loses selection of moved node for now tree.setSelectionPath(PlatformTestUtil.waitForPromise(pane.promisePathToElement(lastField))); } PlatformTestUtil.assertTreeEqual(pane.getTree(), """ -Project -PsiDirectory: showClassMembers -PsiDirectory: src -PsiDirectory: com -PsiDirectory: package1 -Class1 +InnerClass getValue():int [_firstField:boolean] myField1:boolean +Class2 +External Libraries """, true); }