mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 07:14:48 +08:00
Issue with numbers after names in call signatures. It would cause Jedi to stop analysing call signatures. Fixes #510
This commit is contained in:
@@ -185,6 +185,10 @@ class UserContext(object):
|
|||||||
if tok_str in tokenize.ALWAYS_BREAK_TOKENS:
|
if tok_str in tokenize.ALWAYS_BREAK_TOKENS:
|
||||||
break
|
break
|
||||||
elif next_must_be_name:
|
elif next_must_be_name:
|
||||||
|
if tok_type == tokenize.NUMBER:
|
||||||
|
# If there's a number at the end of the string, it will be
|
||||||
|
# tokenized as a number. So add it to the name.
|
||||||
|
tok_type, t, _, _ = next(generator)
|
||||||
if tok_type == tokenize.NAME:
|
if tok_type == tokenize.NAME:
|
||||||
end_pos = start_pos[0], start_pos[1] + len(tok_str)
|
end_pos = start_pos[0], start_pos[1] + len(tok_str)
|
||||||
call, start_pos = self._calc_path_until_cursor(start_pos=end_pos)
|
call, start_pos = self._calc_path_until_cursor(start_pos=end_pos)
|
||||||
|
|||||||
@@ -195,6 +195,20 @@ class TestCallSignatures(TestCase):
|
|||||||
def test_flow_call(self):
|
def test_flow_call(self):
|
||||||
assert not Script('if (1').call_signatures()
|
assert not Script('if (1').call_signatures()
|
||||||
|
|
||||||
|
def test_chained_calls(self):
|
||||||
|
source = dedent('''
|
||||||
|
class B():
|
||||||
|
def test2(self, arg):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class A():
|
||||||
|
def test1(self):
|
||||||
|
return B()
|
||||||
|
|
||||||
|
A().test1().test2(''')
|
||||||
|
|
||||||
|
self._run(source, 'test2', 0)
|
||||||
|
|
||||||
|
|
||||||
class TestParams(TestCase):
|
class TestParams(TestCase):
|
||||||
def params(self, source, line=None, column=None):
|
def params(self, source, line=None, column=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user