forked from VimPlug/jedi
Some more value -> context renames
This commit is contained in:
@@ -371,13 +371,13 @@ class Script(object):
|
||||
if call_details is None:
|
||||
return []
|
||||
|
||||
value = self._inference_state.create_context(
|
||||
context = self._inference_state.create_context(
|
||||
self._get_module_context(),
|
||||
call_details.bracket_leaf
|
||||
)
|
||||
definitions = helpers.cache_call_signatures(
|
||||
self._inference_state,
|
||||
value,
|
||||
context,
|
||||
call_details.bracket_leaf,
|
||||
self._code_lines,
|
||||
self._pos
|
||||
@@ -395,26 +395,26 @@ class Script(object):
|
||||
module = self._get_module_context()
|
||||
try:
|
||||
for node in get_executable_nodes(self._module_node):
|
||||
value = module.create_context(node)
|
||||
context = module.create_context(node)
|
||||
if node.type in ('funcdef', 'classdef'):
|
||||
# Resolve the decorators.
|
||||
tree_name_to_values(self._inference_state, value, node.children[1])
|
||||
tree_name_to_values(self._inference_state, context, node.children[1])
|
||||
elif isinstance(node, tree.Import):
|
||||
import_names = set(node.get_defined_names())
|
||||
if node.is_nested():
|
||||
import_names |= set(path[-1] for path in node.get_paths())
|
||||
for n in import_names:
|
||||
imports.infer_import(value, n)
|
||||
imports.infer_import(context, n)
|
||||
elif node.type == 'expr_stmt':
|
||||
types = value.infer_node(node)
|
||||
types = context.infer_node(node)
|
||||
for testlist in node.children[:-1:2]:
|
||||
# Iterate tuples.
|
||||
unpack_tuple_to_dict(value, types, testlist)
|
||||
unpack_tuple_to_dict(context, types, testlist)
|
||||
else:
|
||||
if node.type == 'name':
|
||||
defs = self._inference_state.goto_definitions(value, node)
|
||||
defs = self._inference_state.goto_definitions(context, node)
|
||||
else:
|
||||
defs = infer_call_of_leaf(value, node)
|
||||
defs = infer_call_of_leaf(context, node)
|
||||
try_iter_content(defs)
|
||||
self._inference_state.reset_recursion_limitations()
|
||||
|
||||
|
||||
@@ -254,10 +254,10 @@ class Completion:
|
||||
|
||||
def _trailer_completions(self, previous_leaf):
|
||||
user_value = get_user_context(self._module_context, self._position)
|
||||
inferred_value = self._inference_state.create_context(
|
||||
inferred_context = self._inference_state.create_context(
|
||||
self._module_context, previous_leaf
|
||||
)
|
||||
values = infer_call_of_leaf(inferred_value, previous_leaf)
|
||||
values = infer_call_of_leaf(inferred_context, previous_leaf)
|
||||
completion_names = []
|
||||
debug.dbg('trailer completion values: %s', values, color='MAGENTA')
|
||||
for value in values:
|
||||
|
||||
@@ -136,23 +136,23 @@ def get_stack_at_position(grammar, code_lines, leaf, pos):
|
||||
)
|
||||
|
||||
|
||||
def infer_goto_definition(inference_state, value, leaf):
|
||||
def infer_goto_definition(inference_state, context, leaf):
|
||||
if leaf.type == 'name':
|
||||
# In case of a name we can just use goto_definition which does all the
|
||||
# magic itself.
|
||||
return inference_state.goto_definitions(value, leaf)
|
||||
return inference_state.goto_definitions(context, leaf)
|
||||
|
||||
parent = leaf.parent
|
||||
definitions = NO_VALUES
|
||||
if parent.type == 'atom':
|
||||
# e.g. `(a + b)`
|
||||
definitions = value.infer_node(leaf.parent)
|
||||
definitions = context.infer_node(leaf.parent)
|
||||
elif parent.type == 'trailer':
|
||||
# e.g. `a()`
|
||||
definitions = infer_call_of_leaf(value, leaf)
|
||||
definitions = infer_call_of_leaf(context, leaf)
|
||||
elif isinstance(leaf, tree.Literal):
|
||||
# e.g. `"foo"` or `1.0`
|
||||
return infer_atom(value, leaf)
|
||||
return infer_atom(context, leaf)
|
||||
elif leaf.type in ('fstring_string', 'fstring_start', 'fstring_end'):
|
||||
return get_string_value_set(inference_state)
|
||||
return definitions
|
||||
@@ -376,7 +376,7 @@ def get_call_signature_details(module, position):
|
||||
|
||||
|
||||
@call_signature_time_cache("call_signatures_validity")
|
||||
def cache_call_signatures(inference_state, value, bracket_leaf, code_lines, user_pos):
|
||||
def cache_call_signatures(inference_state, context, bracket_leaf, code_lines, user_pos):
|
||||
"""This function calculates the cache key."""
|
||||
line_index = user_pos[0] - 1
|
||||
|
||||
@@ -385,13 +385,13 @@ def cache_call_signatures(inference_state, value, bracket_leaf, code_lines, user
|
||||
whole = ''.join(other_lines + [before_cursor])
|
||||
before_bracket = re.match(r'.*\(', whole, re.DOTALL)
|
||||
|
||||
module_path = value.get_root_context().py__file__()
|
||||
module_path = context.get_root_context().py__file__()
|
||||
if module_path is None:
|
||||
yield None # Don't cache!
|
||||
else:
|
||||
yield (module_path, before_bracket, bracket_leaf.start_pos)
|
||||
yield infer_goto_definition(
|
||||
inference_state,
|
||||
value,
|
||||
context,
|
||||
bracket_leaf.get_previous_leaf(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user