1
0
forked from VimPlug/jedi

invalid for loops completion should work now

This commit is contained in:
David Halter
2012-10-01 09:51:57 +02:00
parent eda2430ad7
commit 74fe520597
3 changed files with 12 additions and 1 deletions

View File

@@ -1055,6 +1055,8 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False,
def handle_for_loops(loop): def handle_for_loops(loop):
# Take the first statement (for has always only # Take the first statement (for has always only
# one, remember `in`). And follow it. # one, remember `in`). And follow it.
if not len(loop.inits):
return []
result = get_iterator_types(follow_statement(loop.inits[0])) result = get_iterator_types(follow_statement(loop.inits[0]))
if len(loop.set_vars) > 1: if len(loop.set_vars) > 1:
var_arr = loop.set_stmt.get_assignment_calls() var_arr = loop.set_stmt.get_assignment_calls()

View File

@@ -1691,7 +1691,8 @@ class PyFuzzyParser(object):
if tok == 'in': if tok == 'in':
statement, tok = self._parse_statement() statement, tok = self._parse_statement()
if tok == ':': if tok == ':':
f = ForFlow([statement], first_pos, set_stmt) s = [] if statement is None else [statement]
f = ForFlow(s, first_pos, set_stmt)
self.scope = self.scope.add_statement(f) self.scope = self.scope.add_statement(f)
elif tok in ['if', 'while', 'try', 'with'] + extended_flow: elif tok in ['if', 'while', 'try', 'with'] + extended_flow:

View File

@@ -64,6 +64,14 @@ a = 1 if
#? int() #? int()
a a
for for_local in :
for_local
#? ['for_local']
for_local
#?
for_local
a2 = [for a2 in [0]] a2 = [for a2 in [0]]
#? #?
a2[0] a2[0]