mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-10 15:31:28 +08:00
Try to change the module cache
This commit is contained in:
@@ -36,6 +36,7 @@ from jedi.evaluate.sys_path import dotted_path_in_sys_path
|
||||
from jedi.evaluate.filters import TreeNameDefinition, ParamName
|
||||
from jedi.evaluate.syntax_tree import tree_name_to_contexts
|
||||
from jedi.evaluate.context import ModuleContext
|
||||
from jedi.evaluate.base_context import ContextSet
|
||||
from jedi.evaluate.context.iterable import unpack_tuple_to_dict
|
||||
|
||||
# Jedi uses lots and lots of recursion. By setting this a little bit higher, we
|
||||
@@ -143,17 +144,18 @@ class Script(object):
|
||||
debug.reset_time()
|
||||
|
||||
def _get_module(self):
|
||||
name = '__main__'
|
||||
names = ('__main__',)
|
||||
if self.path is not None:
|
||||
import_names = dotted_path_in_sys_path(self._evaluator.get_sys_path(), self.path)
|
||||
if import_names is not None:
|
||||
name = '.'.join(import_names)
|
||||
names = import_names
|
||||
|
||||
module = ModuleContext(
|
||||
self._evaluator, self._module_node, self.path,
|
||||
code_lines=self._code_lines
|
||||
string_names=names,
|
||||
code_lines=self._code_lines,
|
||||
)
|
||||
imports.add_module_to_cache(self._evaluator, name, module)
|
||||
self._evaluator.module_cache.add(names, ContextSet(module))
|
||||
return module
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -27,6 +27,7 @@ class MixedModuleContext(Context):
|
||||
self.evaluator = evaluator
|
||||
self._namespaces = namespaces
|
||||
|
||||
raise NotImplementedError("module names")
|
||||
self._namespace_objects = [NamespaceObject(n) for n in namespaces]
|
||||
self._module_context = ModuleContext(
|
||||
evaluator, tree_module,
|
||||
|
||||
Reference in New Issue
Block a user