mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do replace duplicates in different functions in class during extract method
This commit is contained in:
@@ -202,8 +202,11 @@ public class PyExtractMethodUtil {
|
||||
@NotNull final PyFunction generatedMethod,
|
||||
@NotNull final PyDuplicatesFinder finder,
|
||||
@NotNull final Editor editor) {
|
||||
final ScopeOwner owner = ScopeUtil.getScopeOwner(callElement);
|
||||
ScopeOwner owner = ScopeUtil.getScopeOwner(callElement);
|
||||
if (owner instanceof PsiFile) return;
|
||||
if (owner instanceof PyFunction && ((PyFunction)owner).getContainingClass() != null) {
|
||||
owner = ((PyFunction)owner).getContainingClass();
|
||||
}
|
||||
final List<Pair<PsiElement, PsiElement>> duplicates = finder.findDuplicates(owner, generatedMethod);
|
||||
|
||||
if (duplicates.size() > 0) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
class A:
|
||||
def foo(self):
|
||||
print 1
|
||||
|
||||
def baz(self):
|
||||
self.foo()
|
||||
self.foo()
|
||||
|
||||
def bar(self):
|
||||
self.foo()
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
class A:
|
||||
def baz(self):
|
||||
print<caret> 1
|
||||
print 1
|
||||
|
||||
def bar(self):
|
||||
print 1
|
||||
@@ -258,4 +258,8 @@ public class PyExtractMethodTest extends LightMarkedTestCase {
|
||||
public void testDuplicateMultiLine() {
|
||||
doTest("foo");
|
||||
}
|
||||
|
||||
public void testDuplicateInClass() {
|
||||
doTest("foo");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user