mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-17 05:49:37 +08:00
simplified some crazy iterator stuff within parser
This commit is contained in:
@@ -58,6 +58,12 @@ class Parser(object):
|
|||||||
# StopIteration needs to be added as well, because python 2 has a
|
# StopIteration needs to be added as well, because python 2 has a
|
||||||
# strange way of handling StopIterations.
|
# strange way of handling StopIterations.
|
||||||
# sometimes StopIteration isn't catched. Just ignore it.
|
# 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
|
pass
|
||||||
|
|
||||||
# clean up unused decorators
|
# clean up unused decorators
|
||||||
@@ -403,15 +409,6 @@ class Parser(object):
|
|||||||
if typ not in (tokenize.INDENT, tokenize.NEWLINE, tokenize.NL):
|
if typ not in (tokenize.INDENT, tokenize.NEWLINE, tokenize.NL):
|
||||||
self.start_pos, self.end_pos = start_pos, end_pos
|
self.start_pos, self.end_pos = start_pos, end_pos
|
||||||
except (StopIteration, common.MultiLevelStopIteration):
|
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
|
raise
|
||||||
|
|
||||||
self._current = typ, tok
|
self._current = typ, tok
|
||||||
|
|||||||
Reference in New Issue
Block a user