void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); if (!(element instanceof PyReferenceExpression referenceExpression)) { return; } ScopeOwner parentScope = ScopeUtil.getScopeOwner(referenceExpression); if (parentScope == null) return; List<PyReferenceExpression> refs = collectExpressionsToRename(referenceExpression, parentScope); LookupElement[] items = collectLookupItems(parentScope); final String name = referenceExpression.getReferencedName(); ReferenceNameExpression refExpr = new ReferenceNameExpression(items, name); TemplateBuilderImpl builder = (TemplateBuilderImpl)TemplateBuilderFactory.getInstance(). createTemplateBuilder(parentScope); for (PyReferenceExpression expr : refs) { if (!expr.equals(referenceExpression)) { builder.replaceElement(expr, name, name, false); } else { builder.replaceElement(expr, name, refExpr, true); } } PythonTemplateRunner.runInlineTemplate(project, element, builder, parentScope.getTextRange().getStartOffset()); }