void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { PsiElement expression = descriptor.getPsiElement(); PyPsiUtils.assertValid(expression); if (expression != null && expression.isValid()) { final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); final PyAssignmentStatement assignment = elementGenerator.createFromText(LanguageLevel.forElement(expression), PyAssignmentStatement.class, "var = " + expression.getText()); expression = expression.replace(assignment); if (expression == null) return; expression = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(expression); if (expression == null) return; final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(expression); final PyExpression leftHandSideExpression = ((PyAssignmentStatement)expression).getLeftHandSideExpression(); assert leftHandSideExpression != null; builder.replaceElement(leftHandSideExpression, "var"); final Editor editor = PythonUiService.getInstance().openTextEditor(project, expression); if (editor != null) { builder.run(editor, false); } else { builder.runNonInteractively(false); } } }