PY-17265 Placement of inserted function is consistent with Move refactoring
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Fri, 21 Oct 2016 17:39:54 +0000 (20:39 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 24 Oct 2016 21:03:49 +0000 (00:03 +0300)
commitcd45e79ab272055de8165914bfc07f481268f1a2
tree867387bf6e705be631ca181a9ce96f54b577b416
parent19eee0612a8dca0e58ffae329c94375c0d00cbfc
PY-17265 Placement of inserted function is consistent with Move refactoring

Namely, if a function is being moved to another file it will be
inserted at its end unless there is a top-level usage of it. In this
case the generated function will be inserted right before the first
such usage so as not to produce unresolved references. If function
stays in the same file, it will be inserted after its original parent
statement i.e. another function or a class, again if there is no
conflicting usages.
15 files changed:
python/src/com/jetbrains/python/codeInsight/imports/AddImportHelper.java
python/src/com/jetbrains/python/refactoring/move/PyMoveRefactoringUtil.java
python/src/com/jetbrains/python/refactoring/move/makeFunctionTopLevel/PyBaseMakeFunctionTopLevelProcessor.java
python/src/com/jetbrains/python/refactoring/move/moduleMembers/PyMoveSymbolProcessor.java
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionNoUsageInAnotherFile/after/main.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionNoUsageInAnotherFile/after/other.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionNoUsageInAnotherFile/before/main.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionNoUsageInAnotherFile/before/other.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionSameFileClassAndUsageNotTopLevel.after.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionSameFileClassAndUsageNotTopLevel.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionUsageInAnotherFile/after/main.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionUsageInAnotherFile/after/other.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionUsageInAnotherFile/before/main.py [new file with mode: 0644]
python/testData/refactoring/makeFunctionTopLevel/methodInsertionPositionUsageInAnotherFile/before/other.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/refactoring/PyMakeFunctionTopLevelTest.java