forked from VimPlug/jedi
dynamic params works now on all internal classes
This commit is contained in:
28
evaluate.py
28
evaluate.py
@@ -149,6 +149,9 @@ class Instance(Executable):
|
||||
self.execute_subscope_by_name('__init__', self.var_args)
|
||||
except KeyError:
|
||||
pass
|
||||
# Generated instances are classes that are just generated by self
|
||||
# (No var_args) used.
|
||||
self.is_generated = False
|
||||
|
||||
@memoize_default()
|
||||
def get_init_execution(self, func):
|
||||
@@ -911,12 +914,22 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
||||
str(token_name))
|
||||
else:
|
||||
# generated objects are used within executions, where
|
||||
if isinstance(r, parsing.Param) and not r.is_generated:
|
||||
res_new += dynamic.search_params(r)
|
||||
if not r.assignment_details:
|
||||
# this means that there are no default params, so
|
||||
# just ignore it.
|
||||
continue
|
||||
if isinstance(r, parsing.Param):
|
||||
func = r.parent()
|
||||
# Instances are typically faked, if the instance is not
|
||||
# called from outside. Here we check it for __init__
|
||||
# functions and return
|
||||
if isinstance(func, InstanceElement) \
|
||||
and func.instance.is_generated \
|
||||
and str(func.name) == '__init__' \
|
||||
and r.position_nr > 0: # 0 would be self
|
||||
r = func.var.params[r.position_nr]
|
||||
if not r.is_generated:
|
||||
res_new += dynamic.search_params(r)
|
||||
if not r.assignment_details:
|
||||
# this means that there are no default params,
|
||||
# so just ignore it.
|
||||
continue
|
||||
|
||||
scopes = follow_statement(r, seek_name=name_str)
|
||||
res_new += remove_statements(scopes)
|
||||
@@ -958,7 +971,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
||||
elif isinstance(par, parsing.Param) \
|
||||
and par.parent() is not None \
|
||||
and isinstance(par.parent().parent(), parsing.Class) \
|
||||
and par.position == 0:
|
||||
and par.position_nr == 0:
|
||||
# This is where self gets added - this happens at another
|
||||
# place, if the var_args are clear. But sometimes the class is
|
||||
# not known. Therefore add a new instance for self. Otherwise
|
||||
@@ -967,6 +980,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
||||
inst = scope.instance
|
||||
else:
|
||||
inst = Instance(Class(par.parent().parent()))
|
||||
inst.is_generated = True
|
||||
result.append(inst)
|
||||
else:
|
||||
result.append(par)
|
||||
|
||||
Reference in New Issue
Block a user