forked from VimPlug/jedi
private variables are not available outside of class for completion, fixes #56
This commit is contained in:
+10
-5
@@ -135,13 +135,18 @@ class Script(object):
|
|||||||
completions += ((k, bs) for k in keywords.get_keywords(
|
completions += ((k, bs) for k in keywords.get_keywords(
|
||||||
all=True))
|
all=True))
|
||||||
|
|
||||||
completions = [(c, s) for c, s in completions
|
comps = []
|
||||||
if settings.case_insensitive_completion
|
for c, s in completions:
|
||||||
and c.names[-1].lower().startswith(like.lower())
|
n = c.names[-1]
|
||||||
or c.names[-1].startswith(like)]
|
if settings.case_insensitive_completion \
|
||||||
|
and n.lower().startswith(like.lower()) \
|
||||||
|
or n.startswith(like):
|
||||||
|
if not evaluate.filter_private_variable(s,
|
||||||
|
self.parser.user_stmt, n):
|
||||||
|
comps.append((c, s))
|
||||||
|
|
||||||
needs_dot = not dot and path
|
needs_dot = not dot and path
|
||||||
completions = set(completions)
|
completions = set(comps)
|
||||||
|
|
||||||
c = [api_classes.Completion(
|
c = [api_classes.Completion(
|
||||||
c, needs_dot, len(like), s) for c, s in completions]
|
c, needs_dot, len(like), s) for c, s in completions]
|
||||||
|
|||||||
@@ -1550,12 +1550,9 @@ def follow_path(path, scope, call_scope, position=None):
|
|||||||
def filter_private_variable(scope, call_scope, var_name):
|
def filter_private_variable(scope, call_scope, var_name):
|
||||||
if isinstance(var_name, (str, unicode)) \
|
if isinstance(var_name, (str, unicode)) \
|
||||||
and var_name.startswith('__') and isinstance(scope, Instance):
|
and var_name.startswith('__') and isinstance(scope, Instance):
|
||||||
#print 'a', scope, var_name, call_scope
|
|
||||||
s = call_scope.get_parent_until((parsing.Class, Instance), include_current=True)
|
s = call_scope.get_parent_until((parsing.Class, Instance), include_current=True)
|
||||||
if s != scope and s != scope.base.base:
|
if s != scope and s != scope.base.base:
|
||||||
#print s, scope, call_scope.parent()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user