mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-16 04:51:58 +08:00
Context -> Value
This commit is contained in:
@@ -36,8 +36,8 @@ from jedi.inference.helpers import get_module_names, infer_call_of_leaf
|
||||
from jedi.inference.sys_path import transform_path_to_dotted
|
||||
from jedi.inference.names import TreeNameDefinition, ParamName
|
||||
from jedi.inference.syntax_tree import tree_name_to_values
|
||||
from jedi.inference.value import ModuleContext
|
||||
from jedi.inference.base_value import ContextSet
|
||||
from jedi.inference.value import ModuleValue
|
||||
from jedi.inference.base_value import ValueSet
|
||||
from jedi.inference.value.iterable import unpack_tuple_to_dict
|
||||
from jedi.inference.gradual.conversion import convert_names, convert_values
|
||||
from jedi.inference.gradual.utils import load_proper_stub_module
|
||||
@@ -181,7 +181,7 @@ class Script(object):
|
||||
if names is None:
|
||||
names = ('__main__',)
|
||||
|
||||
module = ModuleContext(
|
||||
module = ModuleValue(
|
||||
self._infer_state, self._module_node, file_io,
|
||||
string_names=names,
|
||||
code_lines=self._code_lines,
|
||||
@@ -189,7 +189,7 @@ class Script(object):
|
||||
)
|
||||
if names[0] not in ('builtins', '__builtin__', 'typing'):
|
||||
# These modules are essential for Jedi, so don't overwrite them.
|
||||
self._infer_state.module_cache.add(names, ContextSet([module]))
|
||||
self._infer_state.module_cache.add(names, ValueSet([module]))
|
||||
return module
|
||||
|
||||
def __repr__(self):
|
||||
@@ -470,7 +470,7 @@ class Interpreter(Script):
|
||||
self._infer_state.allow_descriptor_getattr = self._allow_descriptor_getattr_default
|
||||
|
||||
def _get_module(self):
|
||||
return interpreter.MixedModuleContext(
|
||||
return interpreter.MixedModuleValue(
|
||||
self._infer_state,
|
||||
self._module_node,
|
||||
self.namespaces,
|
||||
|
||||
@@ -14,10 +14,10 @@ from jedi.cache import memoize_method
|
||||
from jedi.inference import imports
|
||||
from jedi.inference import compiled
|
||||
from jedi.inference.imports import ImportName
|
||||
from jedi.inference.value import FunctionExecutionContext
|
||||
from jedi.inference.gradual.typeshed import StubModuleContext
|
||||
from jedi.inference.value import FunctionExecutionValue
|
||||
from jedi.inference.gradual.typeshed import StubModuleValue
|
||||
from jedi.inference.gradual.conversion import convert_names, convert_values
|
||||
from jedi.inference.base_value import ContextSet
|
||||
from jedi.inference.base_value import ValueSet
|
||||
from jedi.api.keywords import KeywordName
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ class BaseDefinition(object):
|
||||
|
||||
def in_builtin_module(self):
|
||||
"""Whether this is a builtin module."""
|
||||
if isinstance(self._get_module(), StubModuleContext):
|
||||
if isinstance(self._get_module(), StubModuleValue):
|
||||
return any(isinstance(value, compiled.CompiledObject)
|
||||
for value in self._get_module().non_stub_value_set)
|
||||
return isinstance(self._get_module(), compiled.CompiledObject)
|
||||
@@ -324,7 +324,7 @@ class BaseDefinition(object):
|
||||
# results of Python objects instead of stubs.
|
||||
names = convert_names([self._name], prefer_stubs=True)
|
||||
values = convert_values(
|
||||
ContextSet.from_sets(n.infer() for n in names),
|
||||
ValueSet.from_sets(n.infer() for n in names),
|
||||
only_stubs=only_stubs,
|
||||
prefer_stubs=prefer_stubs,
|
||||
)
|
||||
@@ -364,7 +364,7 @@ class BaseDefinition(object):
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
if isinstance(value, FunctionExecutionContext):
|
||||
if isinstance(value, FunctionExecutionValue):
|
||||
value = value.function_value
|
||||
return Definition(self._infer_state, value.name)
|
||||
|
||||
@@ -755,7 +755,7 @@ class _Help(object):
|
||||
if not raw:
|
||||
signature_text = _format_signatures(value)
|
||||
if not doc and value.is_stub():
|
||||
for c in convert_values(ContextSet({value}), ignore_compiled=False):
|
||||
for c in convert_values(ValueSet({value}), ignore_compiled=False):
|
||||
doc = c.py__doc__()
|
||||
if doc:
|
||||
break
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
TODO Some parts of this module are still not well documented.
|
||||
"""
|
||||
|
||||
from jedi.inference.value import ModuleContext
|
||||
from jedi.inference.value import ModuleValue
|
||||
from jedi.inference import compiled
|
||||
from jedi.inference.compiled import mixed
|
||||
from jedi.inference.compiled.access import create_access_path
|
||||
from jedi.inference.base_value import ContextWrapper
|
||||
from jedi.inference.base_value import ValueWrapper
|
||||
|
||||
|
||||
def _create(infer_state, obj):
|
||||
@@ -20,17 +20,17 @@ class NamespaceObject(object):
|
||||
self.__dict__ = dct
|
||||
|
||||
|
||||
class MixedModuleContext(ContextWrapper):
|
||||
class MixedModuleValue(ValueWrapper):
|
||||
type = 'mixed_module'
|
||||
|
||||
def __init__(self, infer_state, tree_module, namespaces, file_io, code_lines):
|
||||
module_value = ModuleContext(
|
||||
module_value = ModuleValue(
|
||||
infer_state, tree_module,
|
||||
file_io=file_io,
|
||||
string_names=('__main__',),
|
||||
code_lines=code_lines
|
||||
)
|
||||
super(MixedModuleContext, self).__init__(module_value)
|
||||
super(MixedModuleValue, self).__init__(module_value)
|
||||
self._namespace_objects = [NamespaceObject(n) for n in namespaces]
|
||||
|
||||
def get_filters(self, *args, **kwargs):
|
||||
|
||||
@@ -44,7 +44,7 @@ class Keyword(object):
|
||||
|
||||
def get_signatures(self):
|
||||
# TODO this makes no sense, I think Keyword should somehow merge with
|
||||
# Context to make it easier for the api/classes.py to deal with all
|
||||
# Value to make it easier for the api/classes.py to deal with all
|
||||
# of it.
|
||||
return []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user