void () { PsiJavaFile file = (PsiJavaFile)createFile("a.java", "class A {}\nclass B{}"); WriteCommandAction.runWriteCommandAction(getProject(), () -> { file.getClasses()[0].delete(); GCUtil.tryGcSoftlyReachableObjects(); }); assertEquals("class B{}", file.getText()); }