mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Get some more dict completions working
This commit is contained in:
@@ -179,12 +179,16 @@ class Completion:
|
||||
completion_names += self._get_keyword_completion_names(allowed_transitions)
|
||||
|
||||
nodes = _gather_nodes(stack)
|
||||
if nodes[-1] == '[' and stack[-1].nonterminal == 'trailer':
|
||||
if any(n.nonterminal == 'trailer' and n.nodes[0] == '[' for n in stack):
|
||||
bracket = self._module_node.get_leaf_for_position(self._position, include_prefixes=True)
|
||||
string = ''
|
||||
if bracket.type == 'number':
|
||||
string = bracket.value
|
||||
bracket = bracket.get_previous_leaf()
|
||||
context = self._module_context.create_context(bracket)
|
||||
|
||||
values = infer_call_of_leaf(context, bracket.get_previous_leaf())
|
||||
completion_names += completions_for_dicts(values)
|
||||
completion_names += completions_for_dicts(values, string)
|
||||
|
||||
if any(t in allowed_transitions for t in (PythonTokenTypes.NAME,
|
||||
PythonTokenTypes.INDENT)):
|
||||
|
||||
@@ -273,14 +273,14 @@ def test_file_path_completions(Script, file, code, column, expected):
|
||||
('ints[]', 5, ['1', '50', Ellipsis]),
|
||||
('ints[1]', 5, ['1', '50', Ellipsis]),
|
||||
('ints[1]', 6, ['']),
|
||||
('ints[1', 5, ['1', Ellipsis]),
|
||||
('ints[1', 5, ['1', '50', Ellipsis]),
|
||||
('ints[1', 6, ['']),
|
||||
|
||||
('ints[5]', 5, ['1', Ellipsis]),
|
||||
('ints[5]', 5, ['1', '50', Ellipsis]),
|
||||
('ints[5]', 6, ['0']),
|
||||
('ints[50', 5, ['50', Ellipsis]),
|
||||
('ints[50', 5, ['1', '50', Ellipsis]),
|
||||
('ints[5', 6, ['0']),
|
||||
('ints[50', 6, ['0']),
|
||||
('ints[50', 6, ['']),#TODO ['0']),
|
||||
('ints[50', 7, ['']),
|
||||
|
||||
('strs[', 5, ["'asdf'", "'foo'", "'fbar'", Ellipsis]),
|
||||
|
||||
Reference in New Issue
Block a user