forked from VimPlug/jedi
Small instance refactoring, now adding is_generated as a param.
This commit is contained in:
@@ -74,6 +74,7 @@ class NameFinder(object):
|
||||
names = []
|
||||
self.maybe_descriptor = isinstance(self.scope, er.Class)
|
||||
for name_list_scope, name_list in scope_names_generator:
|
||||
print(name_list_scope)
|
||||
break_scopes = []
|
||||
if not isinstance(name_list_scope, compiled.CompiledObject):
|
||||
# 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))
|
||||
|
||||
from jedi.evaluate.param import ExecutedParam
|
||||
from jedi.evaluate.param import ExecutedParam, Arguments
|
||||
if isinstance(cls, pr.Class) and param.position_nr == 0 \
|
||||
and not isinstance(param, ExecutedParam):
|
||||
# This is where we add self - if it has never been
|
||||
@@ -313,9 +314,9 @@ class NameFinder(object):
|
||||
if isinstance(self.scope, er.InstanceElement):
|
||||
res_new.append(self.scope.instance)
|
||||
else:
|
||||
for inst in evaluator.execute(er.Class(evaluator, cls)):
|
||||
inst.is_generated = True
|
||||
res_new.append(inst)
|
||||
inst = er.Instance(evaluator, er.wrap(evaluator, cls),
|
||||
Arguments(evaluator, ()), is_generated=True)
|
||||
res_new.append(inst)
|
||||
return res_new
|
||||
|
||||
# Instances are typically faked, if the instance is not called from
|
||||
|
||||
@@ -84,7 +84,7 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
||||
"""
|
||||
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)
|
||||
if base.name.get_code() in ['list', 'set'] \
|
||||
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)
|
||||
# Generated instances are classes that are just generated by self
|
||||
# (No var_args) used.
|
||||
self.is_generated = False
|
||||
self.is_generated = is_generated
|
||||
|
||||
@property
|
||||
def py__call__(self):
|
||||
|
||||
Reference in New Issue
Block a user