mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Imports completions after a semicolon work now
This commit is contained in:
@@ -179,7 +179,12 @@ class Completion:
|
|||||||
|
|
||||||
nonterminals = [stack_node.nonterminal for stack_node in stack]
|
nonterminals = [stack_node.nonterminal for stack_node in stack]
|
||||||
|
|
||||||
nodes = [node for stack_node in stack for node in stack_node.nodes]
|
nodes = []
|
||||||
|
for stack_node in stack:
|
||||||
|
if stack_node.dfa.from_rule == 'small_stmt':
|
||||||
|
nodes = []
|
||||||
|
else:
|
||||||
|
nodes += stack_node.nodes
|
||||||
|
|
||||||
if nodes and nodes[-1] in ('as', 'def', 'class'):
|
if nodes and nodes[-1] in ('as', 'def', 'class'):
|
||||||
# No completions for ``with x as foo`` and ``import x as foo``.
|
# No completions for ``with x as foo`` and ``import x as foo``.
|
||||||
|
|||||||
@@ -456,3 +456,9 @@ def test_import_needed_modules_by_jedi(Script, environment, tmpdir, name):
|
|||||||
module, = script.goto_definitions()
|
module, = script.goto_definitions()
|
||||||
assert module._evaluator.builtins_module.py__file__() != module_path
|
assert module._evaluator.builtins_module.py__file__() != module_path
|
||||||
assert module._evaluator.typing_module.py__file__() != module_path
|
assert module._evaluator.typing_module.py__file__() != module_path
|
||||||
|
|
||||||
|
|
||||||
|
def test_import_with_semicolon(Script):
|
||||||
|
names = [c.name for c in Script('xzy; from abc import ').completions()]
|
||||||
|
assert 'ABCMeta' in names
|
||||||
|
assert 'abc' not in names
|
||||||
|
|||||||
Reference in New Issue
Block a user