mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Prevent insertion of redundant import statement in the original file of moved element
It happens if we move global variable that references itself, e.g. VAR = lambda: VAR. Redundant import was optimized out at the end of refactoring though.
This commit is contained in:
@@ -245,7 +245,8 @@ public class PyMoveModuleMembersProcessor extends BaseRefactoringProcessor {
|
||||
PyClassRefactoringUtil.updateImportOfElement(importStmt, newElement);
|
||||
}
|
||||
final PsiFile usageFile = usage.getContainingFile();
|
||||
if (usageFile == oldElement.getContainingFile() && !PsiTreeUtil.isAncestor(oldElement, usage, false)) {
|
||||
final PsiElement oldElementBody = PyMoveModuleMembersHelper.expandNamedElementBody(oldElement);
|
||||
if (usageFile == oldElement.getContainingFile() && !PsiTreeUtil.isAncestor(oldElementBody, usage, false)) {
|
||||
PyClassRefactoringUtil.insertImport(oldElement, newElement);
|
||||
}
|
||||
if (resolvesToLocalStarImport(usage)) {
|
||||
|
||||
Reference in New Issue
Block a user