1
0
forked from VimPlug/jedi

context -> value

This commit is contained in:
Dave Halter
2019-08-15 01:23:06 +02:00
parent 9e23f4d67b
commit ad4f546aca
68 changed files with 1931 additions and 1931 deletions

View File

@@ -35,11 +35,11 @@ from jedi.inference.arguments import try_iter_content
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_contexts
from jedi.inference.context import ModuleContext
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.context.iterable import unpack_tuple_to_dict
from jedi.inference.gradual.conversion import convert_names, convert_contexts
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
# Jedi uses lots and lots of recursion. By setting this a little bit higher, we
@@ -239,16 +239,16 @@ class Script(object):
if leaf is None:
return []
context = self._infer_state.create_context(self._get_module(), leaf)
value = self._infer_state.create_value(self._get_module(), leaf)
contexts = helpers.infer_goto_definition(self._infer_state, context, leaf)
contexts = convert_contexts(
contexts,
values = helpers.infer_goto_definition(self._infer_state, value, leaf)
values = convert_values(
values,
only_stubs=only_stubs,
prefer_stubs=prefer_stubs,
)
defs = [classes.Definition(self._infer_state, c.name) for c in contexts]
defs = [classes.Definition(self._infer_state, c.name) for c in values]
# The additional set here allows the definitions to become unique in an
# API sense. In the internals we want to separate more things than in
# the API.
@@ -299,8 +299,8 @@ class Script(object):
# Without a name we really just want to jump to the result e.g.
# executed by `foo()`, if we the cursor is after `)`.
return self.goto_definitions(only_stubs=only_stubs, prefer_stubs=prefer_stubs)
context = self._infer_state.create_context(self._get_module(), tree_name)
names = list(self._infer_state.goto(context, tree_name))
value = self._infer_state.create_value(self._get_module(), tree_name)
names = list(self._infer_state.goto(value, tree_name))
if follow_imports:
names = filter_follow_imports(names, lambda name: name.is_import())
@@ -368,21 +368,21 @@ class Script(object):
if call_details is None:
return []
context = self._infer_state.create_context(
value = self._infer_state.create_value(
self._get_module(),
call_details.bracket_leaf
)
definitions = helpers.cache_call_signatures(
self._infer_state,
context,
value,
call_details.bracket_leaf,
self._code_lines,
self._pos
)
debug.speed('func_call followed')
# TODO here we use stubs instead of the actual contexts. We should use
# the signatures from stubs, but the actual contexts, probably?!
# TODO here we use stubs instead of the actual values. We should use
# the signatures from stubs, but the actual values, probably?!
return [classes.CallSignature(self._infer_state, signature, call_details)
for signature in definitions.get_signatures()]
@@ -392,26 +392,26 @@ class Script(object):
module = self._get_module()
try:
for node in get_executable_nodes(self._module_node):
context = module.create_context(node)
value = module.create_value(node)
if node.type in ('funcdef', 'classdef'):
# Resolve the decorators.
tree_name_to_contexts(self._infer_state, context, node.children[1])
tree_name_to_values(self._infer_state, value, 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(context, n)
imports.infer_import(value, n)
elif node.type == 'expr_stmt':
types = context.infer_node(node)
types = value.infer_node(node)
for testlist in node.children[:-1:2]:
# Iterate tuples.
unpack_tuple_to_dict(context, types, testlist)
unpack_tuple_to_dict(value, types, testlist)
else:
if node.type == 'name':
defs = self._infer_state.goto_definitions(context, node)
defs = self._infer_state.goto_definitions(value, node)
else:
defs = infer_call_of_leaf(context, node)
defs = infer_call_of_leaf(value, node)
try_iter_content(defs)
self._infer_state.reset_recursion_limitations()
@@ -505,13 +505,13 @@ def names(source=None, path=None, encoding='utf-8', all_scopes=False,
else:
cls = TreeNameDefinition
return cls(
module_context.create_context(name),
module_value.create_value(name),
name
)
# Set line/column to a random position, because they don't matter.
script = Script(source, line=1, column=0, path=path, encoding=encoding, environment=environment)
module_context = script._get_module()
module_value = script._get_module()
defs = [
classes.Definition(
script._infer_state,

View File

@@ -14,9 +14,9 @@ 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.context import FunctionExecutionContext
from jedi.inference.value import FunctionExecutionContext
from jedi.inference.gradual.typeshed import StubModuleContext
from jedi.inference.gradual.conversion import convert_names, convert_contexts
from jedi.inference.gradual.conversion import convert_names, convert_values
from jedi.inference.base_value import ContextSet
from jedi.api.keywords import KeywordName
@@ -25,20 +25,20 @@ def _sort_names_by_start_pos(names):
return sorted(names, key=lambda s: s.start_pos or (0, 0))
def defined_names(infer_state, context):
def defined_names(infer_state, value):
"""
List sub-definitions (e.g., methods in class).
:type scope: Scope
:rtype: list of Definition
"""
filter = next(context.get_filters(search_global=True))
filter = next(value.get_filters(search_global=True))
names = [name for name in filter.values()]
return [Definition(infer_state, n) for n in _sort_names_by_start_pos(names)]
def _contexts_to_definitions(contexts):
return [Definition(c.infer_state, c.name) for c in contexts]
def _values_to_definitions(values):
return [Definition(c.infer_state, c.name) for c in values]
class BaseDefinition(object):
@@ -75,7 +75,7 @@ class BaseDefinition(object):
# This can take a while to complete, because in the worst case of
# imports (consider `import a` completions), we need to load all
# modules starting with a first.
return self._name.get_root_context()
return self._name.get_root_value()
@property
def module_path(self):
@@ -167,8 +167,8 @@ class BaseDefinition(object):
resolve = True
if isinstance(self._name, imports.SubModuleName) or resolve:
for context in self._name.infer():
return context.api_type
for value in self._name.infer():
return value.api_type
return self._name.api_type
@property
@@ -188,8 +188,8 @@ class BaseDefinition(object):
def in_builtin_module(self):
"""Whether this is a builtin module."""
if isinstance(self._get_module(), StubModuleContext):
return any(isinstance(context, compiled.CompiledObject)
for context in self._get_module().non_stub_context_set)
return any(isinstance(value, compiled.CompiledObject)
for value in self._get_module().non_stub_value_set)
return isinstance(self._get_module(), compiled.CompiledObject)
@property
@@ -270,7 +270,7 @@ class BaseDefinition(object):
be ``<module 'posixpath' ...>```. However most users find the latter
more practical.
"""
if not self._name.is_context_name:
if not self._name.is_value_name:
return None
names = self._name.get_qualified_names(include_module_names=True)
@@ -286,10 +286,10 @@ class BaseDefinition(object):
return '.'.join(names)
def is_stub(self):
if not self._name.is_context_name:
if not self._name.is_value_name:
return False
return self._name.get_root_context().is_stub()
return self._name.get_root_value().is_stub()
def goto_assignments(self, **kwargs): # Python 2...
with debug.increase_indent_cm('goto for %s' % self._name):
@@ -298,7 +298,7 @@ class BaseDefinition(object):
def _goto_assignments(self, only_stubs=False, prefer_stubs=False):
assert not (only_stubs and prefer_stubs)
if not self._name.is_context_name:
if not self._name.is_value_name:
return []
names = convert_names(
@@ -316,19 +316,19 @@ class BaseDefinition(object):
def _infer(self, only_stubs=False, prefer_stubs=False):
assert not (only_stubs and prefer_stubs)
if not self._name.is_context_name:
if not self._name.is_value_name:
return []
# First we need to make sure that we have stub names (if possible) that
# we can follow. If we don't do that, we can end up with the inferred
# results of Python objects instead of stubs.
names = convert_names([self._name], prefer_stubs=True)
contexts = convert_contexts(
values = convert_values(
ContextSet.from_sets(n.infer() for n in names),
only_stubs=only_stubs,
prefer_stubs=prefer_stubs,
)
resulting_names = [c.name for c in contexts]
resulting_names = [c.name for c in values]
return [self if n == self._name else Definition(self._infer_state, n)
for n in resulting_names]
@@ -343,8 +343,8 @@ class BaseDefinition(object):
"""
# Only return the first one. There might be multiple one, especially
# with overloading.
for context in self._name.infer():
for signature in context.get_signatures():
for value in self._name.infer():
for signature in value.get_signatures():
return [
Definition(self._infer_state, n)
for n in signature.get_param_names(resolve_stars=True)
@@ -357,16 +357,16 @@ class BaseDefinition(object):
raise AttributeError('There are no params defined on this.')
def parent(self):
if not self._name.is_context_name:
if not self._name.is_value_name:
return None
context = self._name.parent_context
if context is None:
value = self._name.parent_value
if value is None:
return None
if isinstance(context, FunctionExecutionContext):
context = context.function_context
return Definition(self._infer_state, context.name)
if isinstance(value, FunctionExecutionContext):
value = value.function_value
return Definition(self._infer_state, value.name)
def __repr__(self):
return "<%s %sname=%r, description=%r>" % (
@@ -386,10 +386,10 @@ class BaseDefinition(object):
:return str: Returns the line(s) of code or an empty string if it's a
builtin.
"""
if not self._name.is_context_name or self.in_builtin_module():
if not self._name.is_value_name or self.in_builtin_module():
return ''
lines = self._name.get_root_context().code_lines
lines = self._name.get_root_value().code_lines
index = self._name.start_pos[0] - 1
start_index = max(index - before, 0)
@@ -399,7 +399,7 @@ class BaseDefinition(object):
return [Signature(self._infer_state, s) for s in self._name.infer().get_signatures()]
def execute(self):
return _contexts_to_definitions(self._name.infer().execute_with_values())
return _values_to_definitions(self._name.infer().execute_with_values())
class Completion(BaseDefinition):
@@ -680,7 +680,7 @@ class ParamDefinition(Definition):
"""
:return list of Definition:
"""
return _contexts_to_definitions(self._name.infer_default())
return _values_to_definitions(self._name.infer_default())
def infer_annotation(self, **kwargs):
"""
@@ -689,7 +689,7 @@ class ParamDefinition(Definition):
:param execute_annotation: If False, the values are not executed and
you get classes instead of instances.
"""
return _contexts_to_definitions(self._name.infer_annotation(**kwargs))
return _values_to_definitions(self._name.infer_annotation(**kwargs))
def to_string(self):
return self._name.to_string()
@@ -709,10 +709,10 @@ class ParamDefinition(Definition):
return self._name.get_kind()
def _format_signatures(context):
def _format_signatures(value):
return '\n'.join(
signature.to_string()
for signature in context.get_signatures()
for signature in value.get_signatures()
)
@@ -725,7 +725,7 @@ class _Help(object):
self._name = definition
@memoize_method
def _get_contexts(self, fast):
def _get_values(self, fast):
if isinstance(self._name, ImportName) and fast:
return {}
@@ -742,20 +742,20 @@ class _Help(object):
"""
full_doc = ''
# Using the first docstring that we see.
for context in self._get_contexts(fast=fast):
for value in self._get_values(fast=fast):
if full_doc:
# In case we have multiple contexts, just return all of them
# In case we have multiple values, just return all of them
# separated by a few dashes.
full_doc += '\n' + '-' * 30 + '\n'
doc = context.py__doc__()
doc = value.py__doc__()
signature_text = ''
if self._name.is_context_name:
if self._name.is_value_name:
if not raw:
signature_text = _format_signatures(context)
if not doc and context.is_stub():
for c in convert_contexts(ContextSet({context}), ignore_compiled=False):
signature_text = _format_signatures(value)
if not doc and value.is_stub():
for c in convert_values(ContextSet({value}), ignore_compiled=False):
doc = c.py__doc__()
if doc:
break

View File

@@ -14,7 +14,7 @@ from jedi.api.file_name import file_name_completions
from jedi.inference import imports
from jedi.inference.helpers import infer_call_of_leaf, parse_dotted_names
from jedi.inference.filters import get_global_filters
from jedi.inference.gradual.conversion import convert_contexts
from jedi.inference.gradual.conversion import convert_values
from jedi.parser_utils import get_statement_of_position, cut_value_at_position
@@ -52,11 +52,11 @@ def filter_names(infer_state, completion_names, stack, like_name):
yield new
def get_user_scope(module_context, position):
def get_user_scope(module_value, position):
"""
Returns the scope in which the user resides. This includes flows.
"""
user_stmt = get_statement_of_position(module_context.tree_node, position)
user_stmt = get_statement_of_position(module_value.tree_node, position)
if user_stmt is None:
def scan(scope):
for s in scope.children:
@@ -68,12 +68,12 @@ def get_user_scope(module_context, position):
return scan(s)
return None
scanned_node = scan(module_context.tree_node)
scanned_node = scan(module_value.tree_node)
if scanned_node:
return module_context.create_context(scanned_node, node_is_context=True)
return module_context
return module_value.create_value(scanned_node, node_is_value=True)
return module_value
else:
return module_context.create_context(user_stmt)
return module_value.create_value(user_stmt)
def get_flow_scope_node(module_node, position):
@@ -87,7 +87,7 @@ def get_flow_scope_node(module_node, position):
class Completion:
def __init__(self, infer_state, module, code_lines, position, call_signatures_callback):
self._infer_state = infer_state
self._module_context = module
self._module_value = module
self._module_node = module.tree_node
self._code_lines = code_lines
@@ -104,14 +104,14 @@ class Completion:
string, start_leaf = _extract_string_while_in_string(leaf, self._position)
if string is not None:
completions = list(file_name_completions(
self._infer_state, self._module_context, start_leaf, string,
self._infer_state, self._module_value, start_leaf, string,
self._like_name, self._call_signatures_callback,
self._code_lines, self._original_position
))
if completions:
return completions
completion_names = self._get_context_completions(leaf)
completion_names = self._get_value_completions(leaf)
completions = filter_names(self._infer_state, completion_names,
self.stack, self._like_name)
@@ -120,9 +120,9 @@ class Completion:
x.name.startswith('_'),
x.name.lower()))
def _get_context_completions(self, leaf):
def _get_value_completions(self, leaf):
"""
Analyzes the context that a completion is made in and decides what to
Analyzes the value that a completion is made in and decides what to
return.
Technically this works by generating a parser stack and analysing the
@@ -149,7 +149,7 @@ class Completion:
# completions since this probably just confuses the user.
return []
# If we don't have a context, just use global completion.
# If we don't have a value, just use global completion.
return self._global_completions()
allowed_transitions = \
@@ -208,7 +208,7 @@ class Completion:
if nodes and nodes[-1] in ('as', 'def', 'class'):
# No completions for ``with x as foo`` and ``import x as foo``.
# Also true for defining names as a class or function.
return list(self._get_class_context_completions(is_function=True))
return list(self._get_class_value_completions(is_function=True))
elif "import_stmt" in nonterminals:
level, names = parse_dotted_names(nodes, "import_from" in nonterminals)
@@ -223,7 +223,7 @@ class Completion:
completion_names += self._trailer_completions(dot.get_previous_leaf())
else:
completion_names += self._global_completions()
completion_names += self._get_class_context_completions(is_function=False)
completion_names += self._get_class_value_completions(is_function=False)
if 'trailer' in nonterminals:
call_signatures = self._call_signatures_callback()
@@ -237,12 +237,12 @@ class Completion:
yield keywords.KeywordName(self._infer_state, k)
def _global_completions(self):
context = get_user_scope(self._module_context, self._position)
debug.dbg('global completion scope: %s', context)
value = get_user_scope(self._module_value, self._position)
debug.dbg('global completion scope: %s', value)
flow_scope_node = get_flow_scope_node(self._module_node, self._position)
filters = get_global_filters(
self._infer_state,
context,
value,
self._position,
origin_scope=flow_scope_node
)
@@ -252,34 +252,34 @@ class Completion:
return completion_names
def _trailer_completions(self, previous_leaf):
user_context = get_user_scope(self._module_context, self._position)
inferred_context = self._infer_state.create_context(
self._module_context, previous_leaf
user_value = get_user_scope(self._module_value, self._position)
inferred_value = self._infer_state.create_value(
self._module_value, previous_leaf
)
contexts = infer_call_of_leaf(inferred_context, previous_leaf)
values = infer_call_of_leaf(inferred_value, previous_leaf)
completion_names = []
debug.dbg('trailer completion contexts: %s', contexts, color='MAGENTA')
for context in contexts:
for filter in context.get_filters(
debug.dbg('trailer completion values: %s', values, color='MAGENTA')
for value in values:
for filter in value.get_filters(
search_global=False,
origin_scope=user_context.tree_node):
origin_scope=user_value.tree_node):
completion_names += filter.values()
python_contexts = convert_contexts(contexts)
for c in python_contexts:
if c not in contexts:
python_values = convert_values(values)
for c in python_values:
if c not in values:
for filter in c.get_filters(
search_global=False,
origin_scope=user_context.tree_node):
origin_scope=user_value.tree_node):
completion_names += filter.values()
return completion_names
def _get_importer_names(self, names, level=0, only_modules=True):
names = [n.value for n in names]
i = imports.Importer(self._infer_state, names, self._module_context, level)
i = imports.Importer(self._infer_state, names, self._module_value, level)
return i.completion_names(self._infer_state, only_modules=only_modules)
def _get_class_context_completions(self, is_function=True):
def _get_class_value_completions(self, is_function=True):
"""
Autocomplete inherited methods when overriding in child class.
"""
@@ -287,9 +287,9 @@ class Completion:
cls = tree.search_ancestor(leaf, 'classdef')
if isinstance(cls, (tree.Class, tree.Function)):
# Complete the methods that are defined in the super classes.
random_context = self._module_context.create_context(
random_value = self._module_value.create_value(
cls,
node_is_context=True
node_is_value=True
)
else:
return
@@ -297,7 +297,7 @@ class Completion:
if cls.start_pos[1] >= leaf.start_pos[1]:
return
filters = random_context.get_filters(search_global=False, is_instance=True)
filters = random_value.get_filters(search_global=False, is_instance=True)
# The first dict is the dictionary of class itself.
next(filters)
for filter in filters:

View File

@@ -7,12 +7,12 @@ from jedi.inference.helpers import get_str_or_none
from jedi.parser_utils import get_string_quote
def file_name_completions(infer_state, module_context, start_leaf, string,
def file_name_completions(infer_state, module_value, start_leaf, string,
like_name, call_signatures_callback, code_lines, position):
# First we want to find out what can actually be changed as a name.
like_name_length = len(os.path.basename(string) + like_name)
addition = _get_string_additions(module_context, start_leaf)
addition = _get_string_additions(module_value, start_leaf)
if addition is None:
return
string = addition + string
@@ -25,7 +25,7 @@ def file_name_completions(infer_state, module_context, start_leaf, string,
sigs = call_signatures_callback()
is_in_os_path_join = sigs and all(s.full_name == 'os.path.join' for s in sigs)
if is_in_os_path_join:
to_be_added = _add_os_path_join(module_context, start_leaf, sigs[0].bracket_start)
to_be_added = _add_os_path_join(module_value, start_leaf, sigs[0].bracket_start)
if to_be_added is None:
is_in_os_path_join = False
else:
@@ -60,7 +60,7 @@ def file_name_completions(infer_state, module_context, start_leaf, string,
)
def _get_string_additions(module_context, start_leaf):
def _get_string_additions(module_value, start_leaf):
def iterate_nodes():
node = addition.parent
was_addition = True
@@ -77,18 +77,18 @@ def _get_string_additions(module_context, start_leaf):
addition = start_leaf.get_previous_leaf()
if addition != '+':
return ''
context = module_context.create_context(start_leaf)
return _add_strings(context, reversed(list(iterate_nodes())))
value = module_value.create_value(start_leaf)
return _add_strings(value, reversed(list(iterate_nodes())))
def _add_strings(context, nodes, add_slash=False):
def _add_strings(value, nodes, add_slash=False):
string = ''
first = True
for child_node in nodes:
contexts = context.infer_node(child_node)
if len(contexts) != 1:
values = value.infer_node(child_node)
if len(values) != 1:
return None
c, = contexts
c, = values
s = get_str_or_none(c)
if s is None:
return None
@@ -101,25 +101,25 @@ def _add_strings(context, nodes, add_slash=False):
class FileName(AbstractArbitraryName):
api_type = u'path'
is_context_name = False
is_value_name = False
def _add_os_path_join(module_context, start_leaf, bracket_start):
def _add_os_path_join(module_value, start_leaf, bracket_start):
def check(maybe_bracket, nodes):
if maybe_bracket.start_pos != bracket_start:
return None
if not nodes:
return ''
context = module_context.create_context(nodes[0])
return _add_strings(context, nodes, add_slash=True) or ''
value = module_value.create_value(nodes[0])
return _add_strings(value, nodes, add_slash=True) or ''
if start_leaf.type == 'error_leaf':
# Unfinished string literal, like `join('`
context_node = start_leaf.parent
index = context_node.children.index(start_leaf)
value_node = start_leaf.parent
index = value_node.children.index(start_leaf)
if index > 0:
error_node = context_node.children[index - 1]
error_node = value_node.children[index - 1]
if error_node.type == 'error_node' and len(error_node.children) >= 2:
index = -2
if error_node.children[-1].type == 'arglist':

View File

@@ -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(),
)

View File

@@ -2,7 +2,7 @@
TODO Some parts of this module are still not well documented.
"""
from jedi.inference.context import ModuleContext
from jedi.inference.value import ModuleContext
from jedi.inference import compiled
from jedi.inference.compiled import mixed
from jedi.inference.compiled.access import create_access_path
@@ -24,24 +24,24 @@ class MixedModuleContext(ContextWrapper):
type = 'mixed_module'
def __init__(self, infer_state, tree_module, namespaces, file_io, code_lines):
module_context = ModuleContext(
module_value = ModuleContext(
infer_state, tree_module,
file_io=file_io,
string_names=('__main__',),
code_lines=code_lines
)
super(MixedModuleContext, self).__init__(module_context)
super(MixedModuleContext, self).__init__(module_value)
self._namespace_objects = [NamespaceObject(n) for n in namespaces]
def get_filters(self, *args, **kwargs):
for filter in self._wrapped_context.get_filters(*args, **kwargs):
for filter in self._wrapped_value.get_filters(*args, **kwargs):
yield filter
for namespace_obj in self._namespace_objects:
compiled_object = _create(self.infer_state, namespace_obj)
mixed_object = mixed.MixedObject(
compiled_object=compiled_object,
tree_context=self._wrapped_context
tree_value=self._wrapped_value
)
for filter in mixed_object.get_filters(*args, **kwargs):
yield filter