Some more value -> context renames

This commit is contained in:
Dave Halter
2019-08-21 09:31:23 +02:00
parent 55c08e06ab
commit 02c96b37db
7 changed files with 33 additions and 33 deletions

View File

@@ -217,10 +217,10 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai
execution_context = next(create_func_excs(value))
for name, trailer in _get_possible_nodes(module_context, params[0].string_name):
if value_node.start_pos < name.start_pos < value_node.end_pos:
random_value = execution_context.create_context(name)
random_context = execution_context.create_context(name)
iterator = _check_name_for_execution(
inference_state,
random_value,
random_context,
compare_node,
name,
trailer

View File

@@ -359,8 +359,8 @@ def get_global_filters(inference_state, context, until_position, origin_scope):
>>> scope = next(module_node.iter_funcdefs())
>>> scope
<Function: func@3-5>
>>> value = script._get_module_context().create_context(scope)
>>> filters = list(get_global_filters(value.inference_state, value, (4, 0), None))
>>> context = script._get_module_context().create_context(scope)
>>> filters = list(get_global_filters(context.inference_state, context, (4, 0), None))
First we get the names from the function scope.

View File

@@ -44,7 +44,7 @@ def deep_ast_copy(obj):
return new_obj
def infer_call_of_leaf(value, leaf, cut_own_trailer=False):
def infer_call_of_leaf(context, leaf, cut_own_trailer=False):
"""
Creates a "call" node that consist of all ``trailer`` and ``power``
objects. E.g. if you call it with ``append``::
@@ -66,15 +66,15 @@ def infer_call_of_leaf(value, leaf, cut_own_trailer=False):
trailer = leaf.parent
if trailer.type == 'fstring':
from jedi.inference import compiled
return compiled.get_string_value_set(value.inference_state)
return compiled.get_string_value_set(context.inference_state)
# The leaf may not be the last or first child, because there exist three
# different trailers: `( x )`, `[ x ]` and `.x`. In the first two examples
# we should not match anything more than x.
if trailer.type != 'trailer' or leaf not in (trailer.children[0], trailer.children[-1]):
if trailer.type == 'atom':
return value.infer_node(trailer)
return value.infer_node(leaf)
return context.infer_node(trailer)
return context.infer_node(leaf)
power = trailer.parent
index = power.children.index(trailer)
@@ -99,10 +99,10 @@ def infer_call_of_leaf(value, leaf, cut_own_trailer=False):
base = trailers[0]
trailers = trailers[1:]
values = value.infer_node(base)
values = context.infer_node(base)
from jedi.inference.syntax_tree import infer_trailer
for trailer in trailers:
values = infer_trailer(value, values, trailer)
values = infer_trailer(context, values, trailer)
return values

View File

@@ -772,8 +772,8 @@ class _ArrayInstance(HelperValueMixin):
class Slice(object):
def __init__(self, python_value, start, stop, step):
self._python_value = python_value
def __init__(self, python_context, start, stop, step):
self._python_context = python_context
self._slice_object = None
# All of them are either a Precedence or None.
self._start = start
@@ -782,7 +782,7 @@ class Slice(object):
def __getattr__(self, name):
if self._slice_object is None:
value = compiled.builtin_from_name(self._python_value.inference_state, 'slice')
value = compiled.builtin_from_name(self._python_context.inference_state, 'slice')
self._slice_object, = value.execute_with_values()
return getattr(self._slice_object, name)
@@ -796,7 +796,7 @@ class Slice(object):
if element is None:
return None
result = self._python_value.infer_node(element)
result = self._python_context.infer_node(element)
if len(result) != 1:
# For simplicity, we want slices to be clear defined with just
# one type. Otherwise we will return an empty slice object.