1
0
forked from VimPlug/jedi

backwards tokenizer can now handle 10e-5 and so on literals

This commit is contained in:
Dave Halter
2014-04-07 15:45:11 +02:00
parent 0dd3936c5c
commit ea62ad6a50
2 changed files with 12 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ from jedi._compatibility import u
from jedi.parser.fast import FastParser
from jedi.parser import representation
from jedi import debug
from jedi.common import PushBackIterator
class UserContext(object):
@@ -62,7 +63,7 @@ class UserContext(object):
open_brackets = ['(', '[', '{']
close_brackets = [')', ']', '}']
gen = tokenize.generate_tokens(fetch_line)
gen = PushBackIterator(tokenize.generate_tokens(fetch_line))
string = u('')
level = 0
force_point = False
@@ -102,6 +103,13 @@ class UserContext(object):
force_point = True
elif tok_type == tokenize.NUMBER:
pass
else:
if tok_str == '-':
next_tok = next(gen)
if next_tok.string == 'e':
gen.push_back(next_tok)
else:
break
else:
break

View File

@@ -68,10 +68,10 @@ def test_completion_on_number_literals():
# power notation
_check_number('1.e14.')
#_check_number('1.e-3.')
_check_number('1.e-3.')
_check_number('9e3.')
assert api.Script('1.e3..').completions() == []
#assert api.Script('1.e-13..').completions() == []
assert api.Script('1.e-13..').completions() == []
def test_completion_on_hex_literals():