diff --git a/jedi/api.py b/jedi/api.py index 1c76408b..b5d656be 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -189,7 +189,6 @@ class Script(object): completions.append((c, s)) return completions - def _prepare_goto(self, goto_path, is_like_search=False): """ Base for completions/goto. Basically it returns the resolved scopes diff --git a/jedi/parsing.py b/jedi/parsing.py index 0ae97ca7..96525d6f 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -81,7 +81,7 @@ class Parser(object): if self._current[0] in (tokenize.NL, tokenize.NEWLINE): # we added a newline before, so we need to "remove" it again. self.end_pos = self._gen.previous[2] - if self._current[0] == tokenize.INDENT: + elif self._current[0] == tokenize.INDENT: self.end_pos = self._gen.last_previous[2] self.start_pos = self.module.start_pos diff --git a/test/test_parsing.py b/test/test_parsing.py index 3be92145..b5f0bf2a 100644 --- a/test/test_parsing.py +++ b/test/test_parsing.py @@ -1,4 +1,4 @@ -from jedi import parsing +from jedi.parsing import Parser from jedi import parsing_representation as pr def test_user_statement_on_import(): @@ -7,7 +7,17 @@ def test_user_statement_on_import(): " time)" for pos in [(2, 1), (2, 4)]: - u = parsing.Parser(s, user_position=pos).user_stmt + u = Parser(s, user_position=pos).user_stmt assert isinstance(u, pr.Import) assert u.defunct == False assert [str(n) for n in u.get_defined_names()] == ['time'] + + +def test_name_and_call_positions(): + stmt = Parser('name\nsomething_else').module.statements[0] + call = stmt.get_commands()[0] + name = call.name + print call, name + assert str(name) == 'name' + assert name.start_pos == call.start_pos == (1, 0) + assert name.end_pos == call.end_pos == (1, 4)