1
0
forked from VimPlug/jedi

Make names_dict available in modules.

This commit is contained in:
Dave Halter
2014-11-02 14:22:00 +01:00
parent afca0ef047
commit 0c3cba166e
3 changed files with 12 additions and 8 deletions

View File

@@ -76,6 +76,7 @@ class NameFinder(object):
names = []
self.maybe_descriptor = isinstance(self.scope, er.Class)
for name_list_scope, name_list in scope_names_generator:
print(name_list_scope, hasattr(name_list_scope, 'names_dict'))
break_scopes = []
if not isinstance(name_list_scope, compiled.CompiledObject):
# Here is the position stuff happening (sorting of variables).

View File

@@ -436,7 +436,7 @@ class Class(use_metaclass(CachedMetaClass, Wrapper)):
def __getattr__(self, name):
if name not in ['start_pos', 'end_pos', 'parent', 'asserts', 'raw_doc',
'doc', 'get_imports', 'get_parent_until', 'get_code',
'subscopes']:
'subscopes', 'names_dict']:
raise AttributeError("Don't touch this: %s of %s !" % (name, self))
return getattr(self.base, name)

View File

@@ -81,16 +81,19 @@ class Parser(object):
arr.append(new_node)
arr = self.scope_names_stack[-1].setdefault(new_node.value, [])
arr.append(new_node)
elif isinstance(new_node, pr.ClassOrFunc) \
and raw_node[0] in (pytree.python_symbols.funcdef, pytree.python_symbols.classdef):
elif isinstance(new_node, (pr.ClassOrFunc, pr.Module)) \
and raw_node[0] in (pytree.python_symbols.funcdef,
pytree.python_symbols.classdef,
pytree.python_symbols.file_input):
# scope_name_stack handling
n = new_node.name
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
# Set the func name of the current node
arr = self.scope_names_stack[-1].setdefault(n.value, [])
arr.append(n)
return new_node
def __init__old__(self, source, module_path=None, no_docstr=False,