mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Better handling of the stack.
This commit is contained in:
@@ -12,38 +12,6 @@ from jedi.parser.diff import DiffParser
|
||||
from jedi.parser import ParserWithRecovery
|
||||
|
||||
|
||||
def test_add_to_end():
|
||||
"""
|
||||
fast_parser doesn't parse everything again. It just updates with the
|
||||
help of caches, this is an example that didn't work.
|
||||
"""
|
||||
|
||||
a = dedent("""\
|
||||
class Abc():
|
||||
def abc(self):
|
||||
self.x = 3
|
||||
|
||||
class Two(Abc):
|
||||
def g(self):
|
||||
self
|
||||
""") # ^ here is the first completion
|
||||
|
||||
b = " def h(self):\n" \
|
||||
" self."
|
||||
|
||||
def complete(code, line=None, column=None):
|
||||
script = jedi.Script(code, line, column, 'example.py')
|
||||
assert script.completions()
|
||||
_assert_valid_graph(script._get_module())
|
||||
|
||||
complete(a, 7, 12)
|
||||
complete(a + b)
|
||||
|
||||
a = a[:-1] + '.\n'
|
||||
complete(a, 7, 13)
|
||||
complete(a + b)
|
||||
|
||||
|
||||
def _check_error_leaves_nodes(node):
|
||||
if node.type in ('error_leaf', 'error_node'):
|
||||
return True
|
||||
@@ -409,3 +377,37 @@ def test_node_insertion(differ):
|
||||
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, parsers=1, copies=2)
|
||||
|
||||
|
||||
def test_add_to_end():
|
||||
"""
|
||||
fast_parser doesn't parse everything again. It just updates with the
|
||||
help of caches, this is an example that didn't work.
|
||||
"""
|
||||
|
||||
a = dedent("""\
|
||||
class Abc():
|
||||
def abc(self):
|
||||
self.x = 3
|
||||
|
||||
class Two(Abc):
|
||||
def g(self):
|
||||
self
|
||||
""") # ^ here is the first completion
|
||||
|
||||
b = " def h(self):\n" \
|
||||
" self."
|
||||
|
||||
def complete(code, line=None, column=None):
|
||||
script = jedi.Script(code, line, column, 'example.py')
|
||||
assert script.completions()
|
||||
_assert_valid_graph(script._get_module())
|
||||
|
||||
complete(a, 7, 12)
|
||||
complete(a + b)
|
||||
|
||||
a = a[:-1] + '.\n'
|
||||
complete(a, 7, 13)
|
||||
complete(a + b)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user