forked from VimPlug/jedi
Move the stdlib executions into a plugin
This commit is contained in:
@@ -85,6 +85,18 @@ from jedi.evaluate.syntax_tree import eval_trailer, eval_expr_stmt, \
|
||||
eval_node, check_tuple_assignments
|
||||
|
||||
|
||||
def execute(context, arguments):
|
||||
try:
|
||||
func = context.py__call__
|
||||
except AttributeError:
|
||||
debug.warning("no execution possible %s", context)
|
||||
return NO_CONTEXTS
|
||||
else:
|
||||
context_set = func(arguments)
|
||||
debug.dbg('execute result: %s in %s', context_set, context)
|
||||
return context_set
|
||||
|
||||
|
||||
class Evaluator(object):
|
||||
def __init__(self, project, environment=None, script_path=None):
|
||||
if environment is None:
|
||||
@@ -109,7 +121,8 @@ class Evaluator(object):
|
||||
self.reset_recursion_limitations()
|
||||
self.allow_different_encoding = True
|
||||
from jedi.plugins import plugin_manager
|
||||
self.plugin_callbacks = plugin_manager.get_callbacks(self)
|
||||
plugin_callbacks = plugin_manager.get_callbacks(self)
|
||||
self.execute = plugin_callbacks.decorate('execute', callback=execute)
|
||||
|
||||
@property
|
||||
@evaluator_function_cache()
|
||||
|
||||
@@ -44,26 +44,7 @@ class Context(BaseContext):
|
||||
if self.evaluator.is_analysis:
|
||||
arguments.eval_all()
|
||||
|
||||
debug.dbg('execute: %s %s', self, arguments)
|
||||
from jedi.evaluate import stdlib
|
||||
try:
|
||||
# Some stdlib functions like super(), namedtuple(), etc. have been
|
||||
# hard-coded in Jedi to support them.
|
||||
return stdlib.execute(self.evaluator, self, arguments)
|
||||
except stdlib.NotInStdLib:
|
||||
pass
|
||||
|
||||
def default(arguments):
|
||||
try:
|
||||
func = self.py__call__
|
||||
except AttributeError:
|
||||
debug.warning("no execution possible %s", self)
|
||||
return NO_CONTEXTS
|
||||
else:
|
||||
context_set = func(arguments)
|
||||
debug.dbg('execute result: %s in %s', context_set, self)
|
||||
return context_set
|
||||
return self.evaluator.plugin_callbacks.execute(default, arguments)
|
||||
return self.evaluator.execute(self, arguments)
|
||||
|
||||
def execute_evaluated(self, *value_list):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user