1
0
forked from VimPlug/jedi

line_offset to offset in Parser, which is important for exact positioning

This commit is contained in:
David Halter
2013-02-18 23:14:56 +04:30
parent b2aa8b8024
commit c3fe5d04dd
7 changed files with 20 additions and 25 deletions

View File

@@ -56,10 +56,10 @@ class PushBackIterator(object):
class NoErrorTokenizer(object):
def __init__(self, readline, line_offset=0, stop_on_scope=False):
def __init__(self, readline, offset=(0, 0), stop_on_scope=False):
self.readline = readline
self.gen = PushBackIterator(tokenize.generate_tokens(readline))
self.line_offset = line_offset
self.offset = offset
self.stop_on_scope = stop_on_scope
self.first_scope = False
self.closed = False
@@ -90,7 +90,8 @@ class NoErrorTokenizer(object):
debug.warning('indentation error on line %s, ignoring it' %
self.current[2][0])
# add the starting line of the last position
self.line_offset += self.current[2][0]
self.offset = (self.offset[0] + self.current[2][0],
self.current[2][1])
self.gen = PushBackIterator(tokenize.generate_tokens(
self.readline))
return self.__next__()
@@ -106,8 +107,8 @@ class NoErrorTokenizer(object):
elif c[1] != '@':
self.first_scope = True
c[2] = self.line_offset + c[2][0], c[2][1]
c[3] = self.line_offset + c[3][0], c[3][1]
c[2] = self.offset[0] + c[2][0], self.offset[1] + c[2][1]
c[3] = self.offset[0] + c[3][0], self.offset[1] + c[3][1]
return c