mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-11 09:08:43 +08:00
Make names_dict available in modules.
This commit is contained in:
@@ -76,6 +76,7 @@ class NameFinder(object):
|
|||||||
names = []
|
names = []
|
||||||
self.maybe_descriptor = isinstance(self.scope, er.Class)
|
self.maybe_descriptor = isinstance(self.scope, er.Class)
|
||||||
for name_list_scope, name_list in scope_names_generator:
|
for name_list_scope, name_list in scope_names_generator:
|
||||||
|
print(name_list_scope, hasattr(name_list_scope, 'names_dict'))
|
||||||
break_scopes = []
|
break_scopes = []
|
||||||
if not isinstance(name_list_scope, compiled.CompiledObject):
|
if not isinstance(name_list_scope, compiled.CompiledObject):
|
||||||
# Here is the position stuff happening (sorting of variables).
|
# Here is the position stuff happening (sorting of variables).
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ class Class(use_metaclass(CachedMetaClass, Wrapper)):
|
|||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name not in ['start_pos', 'end_pos', 'parent', 'asserts', 'raw_doc',
|
if name not in ['start_pos', 'end_pos', 'parent', 'asserts', 'raw_doc',
|
||||||
'doc', 'get_imports', 'get_parent_until', 'get_code',
|
'doc', 'get_imports', 'get_parent_until', 'get_code',
|
||||||
'subscopes']:
|
'subscopes', 'names_dict']:
|
||||||
raise AttributeError("Don't touch this: %s of %s !" % (name, self))
|
raise AttributeError("Don't touch this: %s of %s !" % (name, self))
|
||||||
return getattr(self.base, name)
|
return getattr(self.base, name)
|
||||||
|
|
||||||
|
|||||||
+10
-7
@@ -81,16 +81,19 @@ class Parser(object):
|
|||||||
arr.append(new_node)
|
arr.append(new_node)
|
||||||
arr = self.scope_names_stack[-1].setdefault(new_node.value, [])
|
arr = self.scope_names_stack[-1].setdefault(new_node.value, [])
|
||||||
arr.append(new_node)
|
arr.append(new_node)
|
||||||
elif isinstance(new_node, pr.ClassOrFunc) \
|
elif isinstance(new_node, (pr.ClassOrFunc, pr.Module)) \
|
||||||
and raw_node[0] in (pytree.python_symbols.funcdef, pytree.python_symbols.classdef):
|
and raw_node[0] in (pytree.python_symbols.funcdef,
|
||||||
|
pytree.python_symbols.classdef,
|
||||||
|
pytree.python_symbols.file_input):
|
||||||
# scope_name_stack handling
|
# scope_name_stack handling
|
||||||
n = new_node.name
|
|
||||||
scope_names = self.scope_names_stack.pop()
|
scope_names = self.scope_names_stack.pop()
|
||||||
scope_names[n.value].remove(n)
|
if isinstance(new_node, pr.ClassOrFunc):
|
||||||
|
n = new_node.name
|
||||||
|
scope_names[n.value].remove(n)
|
||||||
|
# Set the func name of the current node
|
||||||
|
arr = self.scope_names_stack[-1].setdefault(n.value, [])
|
||||||
|
arr.append(n)
|
||||||
new_node.names_dict = scope_names
|
new_node.names_dict = scope_names
|
||||||
# Set the func name of the current node
|
|
||||||
arr = self.scope_names_stack[-1].setdefault(n.value, [])
|
|
||||||
arr.append(n)
|
|
||||||
return new_node
|
return new_node
|
||||||
|
|
||||||
def __init__old__(self, source, module_path=None, no_docstr=False,
|
def __init__old__(self, source, module_path=None, no_docstr=False,
|
||||||
|
|||||||
Reference in New Issue
Block a user