forked from VimPlug/jedi
Private variable filtering improved.
This commit is contained in:
@@ -247,7 +247,7 @@ class Script(object):
|
|||||||
for names_dict in s.names_dicts(search_global=False):
|
for names_dict in s.names_dicts(search_global=False):
|
||||||
names += chain.from_iterable(names_dict.values())
|
names += chain.from_iterable(names_dict.values())
|
||||||
|
|
||||||
names = filter_definition_names(names)
|
names = filter_definition_names(names, self._parser.user_stmt())
|
||||||
for c in names:
|
for c in names:
|
||||||
completions.append((c, s))
|
completions.append((c, s))
|
||||||
return completions
|
return completions
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from jedi.evaluate import helpers
|
|||||||
from jedi.evaluate.cache import memoize_default
|
from jedi.evaluate.cache import memoize_default
|
||||||
|
|
||||||
|
|
||||||
def filter_definition_names(names, position=None):
|
def filter_definition_names(names, origin, position=None):
|
||||||
# Just calculate the scope from the first
|
# Just calculate the scope from the first
|
||||||
stmt = names[0].get_definition()
|
stmt = names[0].get_definition()
|
||||||
scope = stmt.get_parent_scope()
|
scope = stmt.get_parent_scope()
|
||||||
@@ -45,7 +45,7 @@ def filter_definition_names(names, position=None):
|
|||||||
names = list(names)
|
names = list(names)
|
||||||
for name in names:
|
for name in names:
|
||||||
if name.value.startswith('__') and not name.value.endswith('__'):
|
if name.value.startswith('__') and not name.value.endswith('__'):
|
||||||
if filter_private_variable(scope, name):
|
if filter_private_variable(scope, origin):
|
||||||
names.remove(name)
|
names.remove(name)
|
||||||
|
|
||||||
if not (isinstance(scope, er.FunctionExecution)
|
if not (isinstance(scope, er.FunctionExecution)
|
||||||
@@ -106,7 +106,7 @@ class NameFinder(object):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
names = filter_definition_names(names, position)
|
names = filter_definition_names(names, self.name_str, position)
|
||||||
|
|
||||||
name_scope = None
|
name_scope = None
|
||||||
# Only the names defined in the last position are valid definitions.
|
# Only the names defined in the last position are valid definitions.
|
||||||
|
|||||||
@@ -388,6 +388,8 @@ class PrivateVar():
|
|||||||
self.__var = 1
|
self.__var = 1
|
||||||
#? int()
|
#? int()
|
||||||
self.__var
|
self.__var
|
||||||
|
#? ['__var']
|
||||||
|
self.__var
|
||||||
#? []
|
#? []
|
||||||
PrivateVar().__var
|
PrivateVar().__var
|
||||||
#?
|
#?
|
||||||
|
|||||||
Reference in New Issue
Block a user