From 22928dbcd002e5469b6a4c0f26e5ac068fe176f4 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 16 Feb 2014 15:04:57 +0100 Subject: [PATCH] simplified some crazy iterator stuff within parser --- jedi/parser/__init__.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/jedi/parser/__init__.py b/jedi/parser/__init__.py index d5ae2bac..c4879e64 100644 --- a/jedi/parser/__init__.py +++ b/jedi/parser/__init__.py @@ -58,6 +58,12 @@ class Parser(object): # StopIteration needs to be added as well, because python 2 has a # strange way of handling StopIterations. # sometimes StopIteration isn't catched. Just ignore it. + + # on finish, set end_pos correctly + s = self._scope + while s is not None: + s.end_pos = self.end_pos + s = s.parent pass # clean up unused decorators @@ -403,15 +409,6 @@ class Parser(object): if typ not in (tokenize.INDENT, tokenize.NEWLINE, tokenize.NL): self.start_pos, self.end_pos = start_pos, end_pos except (StopIteration, common.MultiLevelStopIteration): - # on finish, set end_pos correctly - s = self._scope - while s is not None: - if isinstance(s, pr.Module) \ - and not isinstance(s, pr.SubModule): - self.module.end_pos = self.end_pos - break - s.end_pos = self.end_pos - s = s.parent raise self._current = typ, tok