diff --git a/jedi/fast_parser.py b/jedi/fast_parser.py index 8c8e6568..c5243cf7 100644 --- a/jedi/fast_parser.py +++ b/jedi/fast_parser.py @@ -19,7 +19,7 @@ SCOPE_CONTENTS = ['asserts', 'subscopes', 'imports', 'statements', 'returns'] class Module(pr.Simple, pr.Module): def __init__(self, parsers): - self._end_pos = None, None + self.end_pos = None, None super(Module, self).__init__(self, (1, 0)) self.parsers = parsers self.reset_caches() @@ -78,16 +78,6 @@ class Module(pr.Simple, pr.Module): """ ignore """ raise NotImplementedError('TODO remove - just a check if everything works fine.') - @property - def end_pos(self): - return self._end_pos - - @end_pos.setter - def end_pos(self, value): - if None in self._end_pos \ - or None not in value and self._end_pos < value: - self._end_pos = value - def __repr__(self): return "<%s: %s@%s-%s>" % (type(self).__name__, self.name, self.start_pos[0], self.end_pos[0]) @@ -397,6 +387,9 @@ class FastParser(use_metaclass(CachedFastParser)): if not self.parsers: self.parsers.append(empty_parser()) + + self.module.end_pos = self.parsers[-1].end_pos + #print(self.parsers[0].module.get_code()) del code diff --git a/jedi/parsing.py b/jedi/parsing.py index 7483567f..a9605174 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -430,7 +430,8 @@ class Parser(object): except (StopIteration, common.MultiLevelStopIteration): # on finish, set end_pos correctly s = self.scope - while s is not None: + while s is not None and (not isinstance(s, pr.Module) + and isinstance(s, pr.SubModule)): s.end_pos = self.end_pos s = s.parent raise