|
14 | 14 | import com.intellij.refactoring.RefactoringBundle;
|
15 | 15 | import com.intellij.refactoring.util.CommonRefactoringUtil;
|
16 | 16 | import com.jetbrains.python.PyPsiBundle;
|
| 17 | +import com.jetbrains.python.PyTokenTypes; |
17 | 18 | import com.jetbrains.python.codeInsight.codeFragment.PyCodeFragment;
|
18 | 19 | import com.jetbrains.python.codeInsight.codeFragment.PyCodeFragmentUtil;
|
19 | 20 | import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
20 | 21 | import com.jetbrains.python.psi.PyClass;
|
21 | 22 | import com.jetbrains.python.psi.PyElement;
|
| 23 | +import com.jetbrains.python.psi.PyElementType; |
22 | 24 | import com.jetbrains.python.psi.impl.PyPsiUtils;
|
23 | 25 | import com.jetbrains.python.refactoring.PyRefactoringUtil;
|
24 | 26 | import org.jetbrains.annotations.NotNull;
|
@@ -143,6 +145,17 @@ private static boolean rangeBelongsToSameClassBody(@NotNull PsiElement element1,
|
143 | 145 | element2 == PyPsiUtils.getPrevSignificantLeaf(PsiTreeUtil.getDeepestLast(statement2), !(element2 instanceof PsiComment))) {
|
144 | 146 | return Couple.of(statement1, statement2);
|
145 | 147 | }
|
| 148 | + |
| 149 | + // multi-line function call |
| 150 | + boolean isLeftParen = "(".equals(element2.getText()); |
| 151 | + PsiElement prevSignificantLeaf = PyPsiUtils.getPrevSignificantLeaf( |
| 152 | + PsiTreeUtil.getDeepestLast(statement2), |
| 153 | + !(statement2 instanceof PsiComment) |
| 154 | + ); |
| 155 | + boolean isRightParen = prevSignificantLeaf != null && ")".equals(prevSignificantLeaf.getText()); |
| 156 | + if (isLeftParen && isRightParen) { |
| 157 | + return Couple.of(statement1, statement2); |
| 158 | + } |
146 | 159 | return null;
|
147 | 160 | }
|
148 | 161 | }
|
0 commit comments