mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-11858 Fix rename functon parameter along with decorator argument
If docorated function has a parameter and the decorator has an argument with the same name as the parameter then we must not rename the argument in case of renaming the parameter. GitOrigin-RevId: ebc5dcf7448080e2762004a2779cd06700c042a8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
941cdc466b
commit
a7668df48f
+1
-1
@@ -561,7 +561,7 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
|
||||
final PsiElement ourContainer = findContainer(getElement());
|
||||
final PsiElement theirContainer = findContainer(element);
|
||||
if (ourContainer != null) {
|
||||
if (ourContainer == theirContainer) {
|
||||
if (ourContainer == theirContainer && ourScopeOwner == theirScopeOwner) {
|
||||
return true;
|
||||
}
|
||||
if (PsiTreeUtil.isAncestor(theirContainer, ourContainer, true)) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
from functools import wraps
|
||||
|
||||
|
||||
def d(x):
|
||||
def dec(f):
|
||||
@wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
print(f'x = {x}')
|
||||
return f(*args, **kwargs)
|
||||
return wrapper
|
||||
return dec
|
||||
|
||||
|
||||
class C:
|
||||
foo = 0
|
||||
|
||||
@d(foo) # 2. This is renamed either but it shouldn't
|
||||
def f(self, <caret>foo): # 1. Rename this 'foo' to 'bar'
|
||||
print(foo)
|
||||
|
||||
|
||||
C().f(1)
|
||||
@@ -0,0 +1,22 @@
|
||||
from functools import wraps
|
||||
|
||||
|
||||
def d(x):
|
||||
def dec(f):
|
||||
@wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
print(f'x = {x}')
|
||||
return f(*args, **kwargs)
|
||||
return wrapper
|
||||
return dec
|
||||
|
||||
|
||||
class C:
|
||||
foo = 0
|
||||
|
||||
@d(foo) # 2. This is renamed either but it shouldn't
|
||||
def f(self, bar): # 1. Rename this 'foo' to 'bar'
|
||||
print(bar)
|
||||
|
||||
|
||||
C().f(1)
|
||||
@@ -43,6 +43,10 @@ public class PyRenameTest extends PyTestCase {
|
||||
doTest("qu");
|
||||
}
|
||||
|
||||
public void testRenameParameterWithDecorator() { // PY-11858
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
public void testRenameMultipleDefinitionsLocal() { // PY-727
|
||||
doTest("qu");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user