1
0
forked from VimPlug/jedi

start switching to a more python similar approach of naming, start by naming execution stuff py__call__

This commit is contained in:
Dave Halter
2014-07-30 14:06:32 +02:00
parent 196afaacbf
commit ccd304bcb7
2 changed files with 16 additions and 3 deletions

View File

@@ -331,12 +331,11 @@ class Evaluator(object):
return list(obj.execute_function(self, params)) return list(obj.execute_function(self, params))
elif obj.isinstance(er.Class): elif obj.isinstance(er.Class):
# There maybe executions of executions. # There maybe executions of executions.
return [er.Instance(self, obj, params)] return obj.py__call__(params)
else: else:
stmts = [] stmts = []
if obj.isinstance(er.Function): if obj.isinstance(er.Function):
stmts = er.FunctionExecution(self, obj, params) \ return obj.py__call__(params, evaluate_generator)
.get_return_types(evaluate_generator)
else: else:
if hasattr(obj, 'execute_subscope_by_name'): if hasattr(obj, 'execute_subscope_by_name'):
try: try:

View File

@@ -26,6 +26,7 @@ from jedi.evaluate import iterable
from jedi.evaluate import docstrings from jedi.evaluate import docstrings
from jedi.evaluate import helpers from jedi.evaluate import helpers
from jedi.evaluate import param from jedi.evaluate import param
from jedi.evaluate import imports
class Executable(pr.IsScope): class Executable(pr.IsScope):
@@ -246,6 +247,11 @@ class InstanceElement(use_metaclass(CachedMetaClass, pr.Base)):
def is_callable(self): def is_callable(self):
return self.var.is_callable() return self.var.is_callable()
def py__call__(self, params, evaluate_generator=False):
stmts = FunctionExecution(self._evaluator, self, params) \
.get_return_types(evaluate_generator)
return imports.follow_imports(self._evaluator, stmts)
def __repr__(self): def __repr__(self):
return "<%s of %s>" % (type(self).__name__, self.var) return "<%s of %s>" % (type(self).__name__, self.var)
@@ -292,6 +298,9 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
supers += self._evaluator.find_types(compiled.builtin, 'object') supers += self._evaluator.find_types(compiled.builtin, 'object')
return supers return supers
def py__call__(self, params):
return [Instance(self._evaluator, self, params)]
@memoize_default(default=()) @memoize_default(default=())
def instance_names(self): def instance_names(self):
def in_iterable(name, iterable): def in_iterable(name, iterable):
@@ -412,6 +421,11 @@ class Function(use_metaclass(CachedMetaClass, pr.IsScope)):
def is_callable(self): def is_callable(self):
return True return True
def py__call__(self, params, evaluate_generator=False):
stmts = FunctionExecution(self._evaluator, self, params) \
.get_return_types(evaluate_generator)
return imports.follow_imports(self._evaluator, stmts)
def __getattr__(self, name): def __getattr__(self, name):
return getattr(self.base_func, name) return getattr(self.base_func, name)