forked from VimPlug/jedi
context -> value
This commit is contained in:
@@ -12,7 +12,7 @@ from jedi._compatibility import u, Parameter
|
||||
from jedi.inference.base_value import NO_CONTEXTS
|
||||
from jedi.inference.syntax_tree import infer_atom
|
||||
from jedi.inference.helpers import infer_call_of_leaf
|
||||
from jedi.inference.compiled import get_string_context_set
|
||||
from jedi.inference.compiled import get_string_value_set
|
||||
from jedi.cache import call_signature_time_cache
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ def _get_code_for_stack(code_lines, leaf, position):
|
||||
if is_after_newline:
|
||||
if user_stmt.start_pos[1] > position[1]:
|
||||
# This means that it's actually a dedent and that means that we
|
||||
# start without context (part of a suite).
|
||||
# start without value (part of a suite).
|
||||
return u('')
|
||||
|
||||
# This is basically getting the relevant lines.
|
||||
@@ -136,25 +136,25 @@ def get_stack_at_position(grammar, code_lines, leaf, pos):
|
||||
)
|
||||
|
||||
|
||||
def infer_goto_definition(infer_state, context, leaf):
|
||||
def infer_goto_definition(infer_state, value, leaf):
|
||||
if leaf.type == 'name':
|
||||
# In case of a name we can just use goto_definition which does all the
|
||||
# magic itself.
|
||||
return infer_state.goto_definitions(context, leaf)
|
||||
return infer_state.goto_definitions(value, leaf)
|
||||
|
||||
parent = leaf.parent
|
||||
definitions = NO_CONTEXTS
|
||||
if parent.type == 'atom':
|
||||
# e.g. `(a + b)`
|
||||
definitions = context.infer_node(leaf.parent)
|
||||
definitions = value.infer_node(leaf.parent)
|
||||
elif parent.type == 'trailer':
|
||||
# e.g. `a()`
|
||||
definitions = infer_call_of_leaf(context, leaf)
|
||||
definitions = infer_call_of_leaf(value, leaf)
|
||||
elif isinstance(leaf, tree.Literal):
|
||||
# e.g. `"foo"` or `1.0`
|
||||
return infer_atom(context, leaf)
|
||||
return infer_atom(value, leaf)
|
||||
elif leaf.type in ('fstring_string', 'fstring_start', 'fstring_end'):
|
||||
return get_string_context_set(infer_state)
|
||||
return get_string_value_set(infer_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(infer_state, context, bracket_leaf, code_lines, user_pos):
|
||||
def cache_call_signatures(infer_state, value, 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(infer_state, context, bracket_leaf, code_lines, user_p
|
||||
whole = ''.join(other_lines + [before_cursor])
|
||||
before_bracket = re.match(r'.*\(', whole, re.DOTALL)
|
||||
|
||||
module_path = context.get_root_context().py__file__()
|
||||
module_path = value.get_root_value().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(
|
||||
infer_state,
|
||||
context,
|
||||
value,
|
||||
bracket_leaf.get_previous_leaf(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user