void (@NotNull final PsiElement newElement, @Nullable final PsiElement oldElement, final PsiElement @NotNull [] otherMovedElements) { Set<FutureFeature> fromFutureImports = newElement.getCopyableUserData(ENCODED_FROM_FUTURE_IMPORTS); newElement.putCopyableUserData(ENCODED_FROM_FUTURE_IMPORTS, null); PsiFile destFile = newElement.getContainingFile(); if (fromFutureImports != null & destFile != null) { for (FutureFeature futureFeature: fromFutureImports) { AddImportHelper.addOrUpdateFromImportStatement(destFile, PyNames.FUTURE_MODULE, futureFeature.toString(), null, AddImportHelper.ImportPriority.FUTURE, null); } } newElement.acceptChildren(new PyRecursiveElementVisitor() { @Override public void visitPyReferenceExpression(@NotNull PyReferenceExpression node) { super.visitPyReferenceExpression(node); restoreReference(node, node, otherMovedElements); } @Override public void visitPyStringLiteralExpression(@NotNull PyStringLiteralExpression node) { super.visitPyStringLiteralExpression(node); if (oldElement != null) { for (PsiReference ref : node.getReferences()) { if (ref.isReferenceTo(oldElement)) { ref.bindToElement(newElement); } } } restoreReference(node, node, otherMovedElements); } @Override public void visitComment(@NotNull PsiComment comment) { super.visitComment(comment); if (comment instanceof PsiLanguageInjectionHost) { restoreReference(comment, comment, otherMovedElements); } } }); }