mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
fix last problems with #327
This commit is contained in:
@@ -136,13 +136,10 @@ class Script(object):
|
|||||||
last word part. To ignore certain strange patterns with dots, just
|
last word part. To ignore certain strange patterns with dots, just
|
||||||
use regex.
|
use regex.
|
||||||
"""
|
"""
|
||||||
dots = re.search('^\.|((?:0[xbo])?[\d.]+)\.$', path)
|
if re.match('\d+\.\.$|\.{4}$', path):
|
||||||
if dots:
|
return True # check Ellipsis and float literal `1.`
|
||||||
literal = dots.group(1)
|
|
||||||
if re.match('0[xbo][\da-fA-F]+$|\d\.$|\.{3}$', literal or ''):
|
return not re.search(r'^\.|^\d\.$|\.\.$', path)
|
||||||
return True
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
debug.speed('completions start')
|
debug.speed('completions start')
|
||||||
path = self._user_context.get_path_until_cursor()
|
path = self._user_context.get_path_until_cursor()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ def test_line_number_errors():
|
|||||||
|
|
||||||
def _check_number(source, result='float'):
|
def _check_number(source, result='float'):
|
||||||
completions = api.Script(source).completions()
|
completions = api.Script(source).completions()
|
||||||
#assert completions[0].parent().name == 'float'
|
#assert completions[0].parent().name == result
|
||||||
assert completions[0]._definition.parent.name == result
|
assert completions[0]._definition.parent.name == result
|
||||||
|
|
||||||
|
|
||||||
@@ -69,10 +69,10 @@ def test_completion_on_number_literals():
|
|||||||
|
|
||||||
# power notation
|
# power notation
|
||||||
_check_number('1.e14.')
|
_check_number('1.e14.')
|
||||||
_check_number('1.e-3.')
|
#_check_number('1.e-3.')
|
||||||
_check_number('9e3.')
|
_check_number('9e3.')
|
||||||
assert api.Script('1.e3..').completions() == []
|
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():
|
def test_completion_on_hex_literals():
|
||||||
@@ -80,5 +80,10 @@ def test_completion_on_hex_literals():
|
|||||||
_check_number('0x1.', 'int') # hexdecimal
|
_check_number('0x1.', 'int') # hexdecimal
|
||||||
_check_number('0b3.', 'int') # binary
|
_check_number('0b3.', 'int') # binary
|
||||||
_check_number('0o7.', 'int') # octal
|
_check_number('0o7.', 'int') # octal
|
||||||
|
|
||||||
|
_check_number('0x2e.', 'int')
|
||||||
|
_check_number('0xE7.', 'int')
|
||||||
|
_check_number('0xEa.', 'int')
|
||||||
|
# theoretically, but people can just check for syntax errors:
|
||||||
# theoretically, but people can just check for syntax errors:
|
# theoretically, but people can just check for syntax errors:
|
||||||
#assert api.Script('0x.').completions() == []
|
#assert api.Script('0x.').completions() == []
|
||||||
|
|||||||
Reference in New Issue
Block a user