forked from VimPlug/jedi
keyword statement not includes globals
This commit is contained in:
@@ -185,9 +185,9 @@ class NameFinder(object):
|
||||
types = []
|
||||
if stmt.is_global():
|
||||
# global keyword handling.
|
||||
for token_name in stmt._token_list[1:]:
|
||||
for token_name in stmt._token_list:
|
||||
if isinstance(token_name, pr.Name):
|
||||
return evaluator.find_types(stmt.parent, str(token_name))
|
||||
return evaluator.find_types(stmt.parent.parent, str(token_name))
|
||||
else:
|
||||
# Remove the statement docstr stuff for now, that has to be
|
||||
# implemented with the evaluator class.
|
||||
|
||||
@@ -563,16 +563,6 @@ class Parser(object):
|
||||
stmt.start_pos = s
|
||||
except AttributeError:
|
||||
debug.warning('return in non-function')
|
||||
# globals
|
||||
elif tok_str == 'global':
|
||||
stmt, tok = self._parse_statement(self._gen.current)
|
||||
if stmt:
|
||||
self._scope.add_statement(stmt)
|
||||
for t in stmt._token_list:
|
||||
if isinstance(t, pr.Name):
|
||||
# add the global to the top, because there it is
|
||||
# important.
|
||||
self.module.add_global(t)
|
||||
elif tok_str == 'assert':
|
||||
stmt, tok = self._parse_statement()
|
||||
if stmt is not None:
|
||||
@@ -580,9 +570,14 @@ class Parser(object):
|
||||
self._scope.asserts.append(stmt)
|
||||
elif tok_str in STATEMENT_KEYWORDS:
|
||||
stmt, _ = self._parse_statement()
|
||||
k = pr.KeywordStatement(tok_str, tok.start_pos,
|
||||
use_as_parent_scope, stmt)
|
||||
self._scope.add_statement(k)
|
||||
kw = pr.KeywordStatement(tok_str, tok.start_pos,
|
||||
use_as_parent_scope, stmt)
|
||||
self._scope.add_statement(kw)
|
||||
if stmt is not None and tok_str == 'global':
|
||||
for t in stmt._token_list:
|
||||
if isinstance(t, pr.Name):
|
||||
# Add the global to the top module, it counts there.
|
||||
self.module.add_global(t)
|
||||
# decorator
|
||||
elif tok_str == '@':
|
||||
stmt, tok = self._parse_statement()
|
||||
|
||||
@@ -913,9 +913,8 @@ isinstance(c, (tokenize.Token, Operator)) else unicode(c)
|
||||
return self._set_vars + self.as_names
|
||||
|
||||
def is_global(self):
|
||||
# first keyword of the first token is global -> must be a global
|
||||
tok = self._token_list[0]
|
||||
return isinstance(tok, Name) and str(tok) == "global"
|
||||
p = self.parent
|
||||
return isinstance(p, KeywordStatement) and p.name == 'global'
|
||||
|
||||
@property
|
||||
def assignment_details(self):
|
||||
|
||||
Reference in New Issue
Block a user