1
0
forked from VimPlug/jedi

Fix more issues in the diff parser.

This commit is contained in:
Dave Halter
2016-09-27 00:29:11 +02:00
parent 09a5f27068
commit 9b85d5517f
3 changed files with 31 additions and 17 deletions

View File

@@ -19,6 +19,7 @@ from io import StringIO
from jedi.parser.token import (tok_name, N_TOKENS, ENDMARKER, STRING, NUMBER, opmap,
NAME, OP, ERRORTOKEN, NEWLINE, INDENT, DEDENT)
from jedi._compatibility import is_py3
from jedi.common import splitlines
cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
@@ -166,6 +167,14 @@ class TokenInfo(namedtuple('Token', ['type', 'string', 'start_pos', 'prefix'])):
else:
return self.type
@property
def end_pos(self):
lines = splitlines(self.string)
if len(lines) > 1:
return self.start_pos[0] + len(lines) - 1, 0
else:
return self.start_pos[0], self.start_pos[1] + len(self.string)
def source_tokens(source, use_exact_op_types=False):
"""Generate tokens from a the source code (string)."""