1
0
forked from VimPlug/jedi

support for completions on return statements.

This commit is contained in:
Dave Halter
2014-06-22 12:05:22 +02:00
parent d752907290
commit b7bf8d515c
4 changed files with 9 additions and 0 deletions

View File

@@ -274,6 +274,8 @@ class Script(object):
stmt = r.module.statements[-1]
except IndexError:
raise NotFoundError()
if isinstance(stmt, pr.KeywordStatement):
stmt = stmt.stmt
if not isinstance(stmt, pr.Statement):
raise NotFoundError()

View File

@@ -557,6 +557,8 @@ class Parser(object):
if stmt is not None:
stmt.parent = use_as_parent_scope
try:
func.statements.append(pr.KeywordStatement(tok_str, s,
use_as_parent_scope, stmt))
func.returns.append(stmt)
# start_pos is the one of the return statement
stmt.start_pos = s

View File

@@ -50,6 +50,10 @@ func()
#? list()
assert []
def focus_return():
#? list
return []
# -----------------
# for loops

View File

@@ -58,6 +58,7 @@ def test_operators():
diff_code_assert(src, prs.module.get_code())
@pytest.mark.skipif('True', reason='Broke get_code support for yield/return statements.')
def test_get_code():
"""Use the same code that the parser also generates, to compare"""
s = u('''"""a docstring"""