mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Some more extract improvements
This commit is contained in:
@@ -442,8 +442,16 @@ def _find_non_global_names(context, nodes):
|
|||||||
children = node.children
|
children = node.children
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
if node.type == 'name':
|
if node.type == 'name':
|
||||||
yield node.value
|
name_definitions = context.goto(node, node.start_pos)
|
||||||
|
if not name_definitions \
|
||||||
|
or any(not n.parent_context.is_module() or n.api_type == 'param'
|
||||||
|
for n in name_definitions):
|
||||||
|
yield node.value
|
||||||
else:
|
else:
|
||||||
|
# We only want to check foo in foo.bar
|
||||||
|
if node.type == 'trailer' and node.children[0] == '.':
|
||||||
|
continue
|
||||||
|
|
||||||
for x in _find_non_global_names(context, children): # Python 2...
|
for x in _find_non_global_names(context, children): # Python 2...
|
||||||
yield x
|
yield x
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
# -------------------------------------------------- in-module-1
|
# -------------------------------------------------- in-module-1
|
||||||
|
glob = 3
|
||||||
#? 11 text {'new_name': 'a'}
|
#? 11 text {'new_name': 'a'}
|
||||||
test(100, (30 + b, c) + 1)
|
test(100, (glob.a + b, c) + 1)
|
||||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
glob = 3
|
||||||
#? 11 text {'new_name': 'a'}
|
#? 11 text {'new_name': 'a'}
|
||||||
def a(b):
|
def a(b):
|
||||||
return 30 + b
|
return glob.a + b
|
||||||
|
|
||||||
|
|
||||||
test(100, (a(b), c) + 1)
|
test(100, (a(b), c) + 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user