mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-17360 Allow to extract qualifier of a call expression
This commit is contained in:
@@ -60,6 +60,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static com.jetbrains.python.inspections.PyStringFormatParser.*;
|
||||
import static com.jetbrains.python.psi.PyUtil.as;
|
||||
|
||||
/**
|
||||
* @author Alexey.Ivanov
|
||||
@@ -417,8 +418,8 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
}
|
||||
|
||||
private static boolean isValidIntroduceVariant(PsiElement element) {
|
||||
final PyCallExpression call = PsiTreeUtil.getParentOfType(element, PyCallExpression.class);
|
||||
if (call != null && PsiTreeUtil.isAncestor(call.getCallee(), element, false)) {
|
||||
final PyCallExpression call = as(element.getParent(), PyCallExpression.class);
|
||||
if (call != null && call.getCallee() == element) {
|
||||
return false;
|
||||
}
|
||||
final PyComprehensionElement comprehension = PsiTreeUtil.getParentOfType(element, PyComprehensionElement.class, true);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class MyClass:
|
||||
def method(self):
|
||||
return 42
|
||||
|
||||
|
||||
a = MyClass()
|
||||
x = a.method()
|
||||
@@ -0,0 +1,6 @@
|
||||
class MyClass:
|
||||
def method(self):
|
||||
return 42
|
||||
|
||||
|
||||
x = MyCla<caret>ss().method()
|
||||
@@ -309,6 +309,11 @@ public class PyIntroduceVariableTest extends PyIntroduceTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-17360
|
||||
public void testCallExpressionQualifier() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/refactoring/introduceVariable";
|
||||
|
||||
Reference in New Issue
Block a user