1
0
forked from VimPlug/jedi

fix some end_pos problems

This commit is contained in:
David Halter
2013-04-27 22:47:26 +04:30
parent 792808d835
commit 26ce32ec6b
2 changed files with 6 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ SCOPE_CONTENTS = ['asserts', 'subscopes', 'imports', 'statements', 'returns']
class Module(pr.Simple, pr.Module): class Module(pr.Simple, pr.Module):
def __init__(self, parsers): def __init__(self, parsers):
self._end_pos = None, None self.end_pos = None, None
super(Module, self).__init__(self, (1, 0)) super(Module, self).__init__(self, (1, 0))
self.parsers = parsers self.parsers = parsers
self.reset_caches() self.reset_caches()
@@ -78,16 +78,6 @@ class Module(pr.Simple, pr.Module):
""" ignore """ """ ignore """
raise NotImplementedError('TODO remove - just a check if everything works fine.') 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): def __repr__(self):
return "<%s: %s@%s-%s>" % (type(self).__name__, self.name, return "<%s: %s@%s-%s>" % (type(self).__name__, self.name,
self.start_pos[0], self.end_pos[0]) self.start_pos[0], self.end_pos[0])
@@ -397,6 +387,9 @@ class FastParser(use_metaclass(CachedFastParser)):
if not self.parsers: if not self.parsers:
self.parsers.append(empty_parser()) self.parsers.append(empty_parser())
self.module.end_pos = self.parsers[-1].end_pos
#print(self.parsers[0].module.get_code()) #print(self.parsers[0].module.get_code())
del code del code

View File

@@ -430,7 +430,8 @@ class Parser(object):
except (StopIteration, common.MultiLevelStopIteration): except (StopIteration, common.MultiLevelStopIteration):
# on finish, set end_pos correctly # on finish, set end_pos correctly
s = self.scope 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.end_pos = self.end_pos
s = s.parent s = s.parent
raise raise