void () { doTest(() -> { PsiClass psiClass = myFixture.findClass("Test"); assertNotNull(psiClass); final PsiField[] fields = psiClass.getFields(); assertEquals(1, fields.length); final PsiExpression initializer = fields[0].getInitializer(); assertNotNull(initializer); assertInstanceOf(initializer, PsiNewExpression.class); final PsiAnonymousClass anonymousClass = ((PsiNewExpression)initializer).getAnonymousClass(); assertNotNull(anonymousClass); final ArrayList<MemberInfo> infos = new ArrayList<>(); MemberInfo.extractClassMembers(anonymousClass, infos, member -> true, false); for (MemberInfo info : infos) { info.setChecked(true); } WriteCommandAction.writeCommandAction(getProject()).run(() -> ExtractSuperClassUtil .extractSuperClass(getProject(), psiClass.getContainingFile().getContainingDirectory(), "TestSubclass", anonymousClass, infos.toArray(new MemberInfo[0]), new DocCommentPolicy(DocCommentPolicy.ASIS))); }); }