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