1
0
forked from VimPlug/jedi

remove unused set_vars, but there are still set_vars that shouldn't be in defined_names, #205

This commit is contained in:
David Halter
2013-08-31 23:51:06 +04:30
parent 2ee7ee4473
commit 3d3157eff8
2 changed files with 16 additions and 12 deletions

View File

@@ -348,7 +348,7 @@ class Script(object):
if op and op not in lower_priority_operators: if op and op not in lower_priority_operators:
scopes = set([keywords.get_operator(op, self._pos)]) scopes = set([keywords.get_operator(op, self._pos)])
# Fetch definition of callee # Fetch definition of callee, if there's no path otherwise.
if not goto_path: if not goto_path:
(call, _) = self._func_call_and_param_index() (call, _) = self._func_call_and_param_index()
if call is not None: if call is not None:

View File

@@ -259,7 +259,7 @@ class Scope(Simple, IsScope):
""" """
return [n for n in self.get_set_vars() return [n for n in self.get_set_vars()
if isinstance(n, Import) or len(n) == 1] if isinstance(n, Import) or (len(n) == 1)]
def is_empty(self): def is_empty(self):
""" """
@@ -783,6 +783,7 @@ class Statement(Simple):
def _remove_executions_from_set_vars(self, set_vars): def _remove_executions_from_set_vars(self, set_vars):
""" """
Removes all executions and uses in lookups.
Important mainly for assosiative arrays:: Important mainly for assosiative arrays::
a = 3 a = 3
@@ -796,19 +797,22 @@ class Statement(Simple):
return set_vars return set_vars
result = set(set_vars) result = set(set_vars)
last = None last = None
in_execution = 0 in_lookup = 0
for tok in self.token_list: is_execution = False
for i, tok in enumerate(self.token_list):
if isinstance(tok, Name): if isinstance(tok, Name):
if tok not in result: if in_lookup or is_execution:
break result.discard(tok)
if in_execution:
result.remove(tok)
elif isinstance(tok, tuple): elif isinstance(tok, tuple):
tok = tok[1] tok = tok[1]
if tok in ['(', '['] and isinstance(last, Name): if in_lookup == 0 and tok == '(':
in_execution += 1 is_execution = True
elif tok in [')', ']'] and in_execution > 0: for t in self.token_list[:i]:
in_execution -= 1 result.discard(t)
if tok == '[' and isinstance(last, Name):
in_lookup += 1
elif tok == ']' and in_lookup > 0:
in_lookup -= 1
last = tok last = tok
return list(result) return list(result)