void (@NotNull Environment env) { PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass("com.jetbrains.A", GlobalSearchScope.allScope(getProject())); assertNotNull(psiClass); myFixture.openFileInEditor(psiClass.getContainingFile().getVirtualFile()); Context context = new Context(env); String methodText = context.generateOptionalCall(true); String afterStepText = context.afterStep; PsiMethod newMethod = replaceMethod(psiClass, methodText); SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(getProject()); PsiStatement lastStatement = addLastStatement(afterStepText, newMethod); SmartPsiElementPointer<PsiStatement> lastStatementPtr = lastStatement == null ? null : smartPointerManager.createSmartPsiElementPointer(lastStatement); env.logMessage("Code before conversion:\n" + psiClass.getText()); Editor editor = myFixture.getEditor(); applyConversion(newMethod, editor); env.logMessage("Code after conversion:\n" + psiClass.getText()); assertFalse(hasErrors(newMethod, editor, lastStatementPtr)); }