1
0
forked from VimPlug/jedi

improve docstrings of evaluate

This commit is contained in:
David Halter
2013-02-05 18:21:38 +01:00
parent a14471ad48
commit 650b96dbda
3 changed files with 14 additions and 12 deletions

View File

@@ -94,7 +94,7 @@ class Script(object):
scopes = list(self._prepare_goto(path, True))
except NotFoundError:
scopes = []
scope_generator = evaluate.get_names_for_scope(
scope_generator = evaluate.get_names_of_scope(
self._parser.user_scope, self.pos)
completions = []
for scope, name_list in scope_generator:

View File

@@ -113,10 +113,10 @@ def get_defined_names_for_position(scope, position=None, start_scope=None):
return names_new
def get_names_for_scope(scope, position=None, star_search=True,
def get_names_of_scope(scope, position=None, star_search=True,
include_builtin=True):
"""
Get all completions possible for the current scope.
Get all completions (names) possible for the current scope.
The star search option is only here to provide an optimization. Otherwise
the whole thing would probably start a little recursive madness.
"""
@@ -153,7 +153,7 @@ def get_names_for_scope(scope, position=None, star_search=True,
# Add star imports.
if star_search:
for s in imports.remove_star_imports(non_flow.get_parent_until()):
for g in get_names_for_scope(s, star_search=False):
for g in get_names_of_scope(s, star_search=False):
yield g
# Add builtins to the global scope.
@@ -378,7 +378,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False,
break
if not result and isinstance(nscope, er.Instance):
# getattr() / __getattr__ / __getattribute__
# __getattr__ / __getattribute__
result += check_getattr(nscope, name_str)
debug.dbg('sfn filter "%s" in %s: %s' % (name_str, nscope, result))
return result
@@ -399,7 +399,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False,
return res_new
if search_global:
scope_generator = get_names_for_scope(scope, position=position)
scope_generator = get_names_of_scope(scope, position=position)
else:
if isinstance(scope, er.Instance):
scope_generator = scope.scope_generator()
@@ -418,6 +418,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False,
def check_getattr(inst, name_str):
"""Checks for both __getattr__ and __getattribute__ methods"""
result = []
# str is important to lose the NamePart!
name = pr.Call(str(name_str), pr.Call.STRING, (0, 0), inst)
@@ -482,7 +483,7 @@ def assign_tuples(tup, results, seek_name):
>>> a, b = 1, ""
>>> a, (b, c) = 1, ("", 1.0)
Here, if seek_name is "a", the number type will be returned.
Here, if `seek_name` is "a", the number type will be returned.
The first part (before `=`) is the param tuples, the second one result.
:type tup: pr.Array
@@ -739,6 +740,7 @@ def follow_path(path, scope, call_scope, position=None):
def filter_private_variable(scope, call_scope, var_name):
"""private variables begin with a double underline `__`"""
if isinstance(var_name, (str, unicode)) \
and var_name.startswith('__') and isinstance(scope, er.Instance):
s = call_scope.get_parent_until((pr.Class, er.Instance))

View File

@@ -117,7 +117,7 @@ class ImportPath(pr.Base):
and scope.path.endswith('__init__.py'):
pkg_path = os.path.dirname(scope.path)
names += self.get_module_names([pkg_path])
for s, scope_names in evaluate.get_names_for_scope(scope,
for s, scope_names in evaluate.get_names_of_scope(scope,
include_builtin=False):
for n in scope_names:
if self.import_stmt.from_ns is None \