boolean (@NotNull Project project, @NotNull PsiClass psiClass, @NotNull PsiMember psiMember) { int startOffset = psiClass.getTextRange().getStartOffset(); String memberText = psiMember.getText() + "\n"; Document document = myFixture.getDocument(psiMember.getContainingFile()); SmartPsiElementPointer<PsiMember> memberPtr = SmartPointerManager.createPointer(psiMember); WriteCommandAction.runWriteCommandAction(project, () -> { document.insertString(startOffset, memberText); }); PsiDocumentManager.getInstance(project).commitAllDocuments(); PsiMember movedMember = memberPtr.getElement(); if (movedMember == null) return false; WriteCommandAction.runWriteCommandAction(project, () -> movedMember.delete()); return true; }