1
0
forked from VimPlug/jedi

Refactor Evaluator.wrap to use the types in a more consequent way.

This commit is contained in:
Dave Halter
2016-06-29 21:06:35 +02:00
parent a3b263a599
commit 689284c615
5 changed files with 19 additions and 10 deletions
+11 -8
View File
@@ -109,15 +109,18 @@ class Evaluator(object):
self.execution_recursion_detector = recursion.ExecutionRecursionDetector(self)
def wrap(self, element):
if isinstance(element, tree.Class):
if isinstance(element, (er.Wrapper, er.InstanceElement,
er.ModuleWrapper, er.FunctionExecution, er.Instance, compiled.CompiledObject)) or element is None:
# TODO this is so ugly, please refactor.
return element
if element.type == 'classdef':
return er.Class(self, element)
elif isinstance(element, tree.Function):
if isinstance(element, tree.Lambda):
return er.LambdaWrapper(self, element)
else:
return er.Function(self, element)
elif isinstance(element, (tree.Module)) \
and not isinstance(element, er.ModuleWrapper):
elif element.type == 'funcdef':
return er.Function(self, element)
elif element.type == 'lambda':
return er.LambdaWrapper(self, element)
elif element.type == 'file_input':
return er.ModuleWrapper(self, element)
else:
return element