mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't suggest defined unread and unmodified variables in extract method (PY-6391)
This commit is contained in:
@@ -139,9 +139,6 @@ public class PyCodeFragmentBuilder extends PyRecursiveElementVisitor {
|
||||
}
|
||||
// If declaration is before we look for modifications inside
|
||||
if (pos == Position.BEFORE) {
|
||||
if (!isTopLevel(element)) {
|
||||
inElements.add(name);
|
||||
}
|
||||
final List<PyElement> list = modifiedInsideMap.get(name);
|
||||
boolean modificationSeen = false;
|
||||
if (list != null) {
|
||||
@@ -154,6 +151,9 @@ public class PyCodeFragmentBuilder extends PyRecursiveElementVisitor {
|
||||
}
|
||||
}
|
||||
if (modificationSeen) {
|
||||
if (!isTopLevel(element)) {
|
||||
inElements.add(name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
def bar():
|
||||
if 11 > 4:
|
||||
print('ok')
|
||||
|
||||
|
||||
def main(indices):
|
||||
foo = True
|
||||
bar()
|
||||
return foo
|
||||
@@ -0,0 +1,5 @@
|
||||
def main(indices):
|
||||
foo = True
|
||||
<selection>if 11 > 4:
|
||||
print('ok')</selection>
|
||||
return foo
|
||||
@@ -162,4 +162,9 @@ public class PyExtractMethodTest extends LightMarkedTestCase {
|
||||
public void testLocalVarDefinedBeforeModifiedInside() {
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
// PY-6391
|
||||
public void testDefinedBeforeAccessedAfter() {
|
||||
doTest("bar");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user