1
0
forked from VimPlug/jedi

Small instance refactoring, now adding is_generated as a param.

This commit is contained in:
Dave Halter
2014-10-28 11:33:28 +01:00
parent 19e083cbfb
commit b550f67bce
2 changed files with 7 additions and 6 deletions

View File

@@ -74,6 +74,7 @@ class NameFinder(object):
names = [] names = []
self.maybe_descriptor = isinstance(self.scope, er.Class) self.maybe_descriptor = isinstance(self.scope, er.Class)
for name_list_scope, name_list in scope_names_generator: for name_list_scope, name_list in scope_names_generator:
print(name_list_scope)
break_scopes = [] break_scopes = []
if not isinstance(name_list_scope, compiled.CompiledObject): if not isinstance(name_list_scope, compiled.CompiledObject):
# Here is the position stuff happening (sorting of variables). # Here is the position stuff happening (sorting of variables).
@@ -305,7 +306,7 @@ class NameFinder(object):
cls = func.parent.get_parent_until((pr.Class, pr.Function)) cls = func.parent.get_parent_until((pr.Class, pr.Function))
from jedi.evaluate.param import ExecutedParam from jedi.evaluate.param import ExecutedParam, Arguments
if isinstance(cls, pr.Class) and param.position_nr == 0 \ if isinstance(cls, pr.Class) and param.position_nr == 0 \
and not isinstance(param, ExecutedParam): and not isinstance(param, ExecutedParam):
# This is where we add self - if it has never been # This is where we add self - if it has never been
@@ -313,9 +314,9 @@ class NameFinder(object):
if isinstance(self.scope, er.InstanceElement): if isinstance(self.scope, er.InstanceElement):
res_new.append(self.scope.instance) res_new.append(self.scope.instance)
else: else:
for inst in evaluator.execute(er.Class(evaluator, cls)): inst = er.Instance(evaluator, er.wrap(evaluator, cls),
inst.is_generated = True Arguments(evaluator, ()), is_generated=True)
res_new.append(inst) res_new.append(inst)
return res_new return res_new
# Instances are typically faked, if the instance is not called from # Instances are typically faked, if the instance is not called from

View File

@@ -84,7 +84,7 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
""" """
This class is used to evaluate instances. This class is used to evaluate instances.
""" """
def __init__(self, evaluator, base, var_args=()): def __init__(self, evaluator, base, var_args, is_generated=False):
super(Instance, self).__init__(evaluator, base, var_args) super(Instance, self).__init__(evaluator, base, var_args)
if base.name.get_code() in ['list', 'set'] \ if base.name.get_code() in ['list', 'set'] \
and compiled.builtin == base.get_parent_until(): and compiled.builtin == base.get_parent_until():
@@ -97,7 +97,7 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
self.execute_subscope_by_name('__init__', self.var_args) self.execute_subscope_by_name('__init__', self.var_args)
# Generated instances are classes that are just generated by self # Generated instances are classes that are just generated by self
# (No var_args) used. # (No var_args) used.
self.is_generated = False self.is_generated = is_generated
@property @property
def py__call__(self): def py__call__(self):