mirror of
https://github.com/davidhalter/jedi.git
synced 2026-11-24 16:48:06 +08:00
split param stuff from remove_statements - which is now finally a simple method
This commit is contained in:
1 parent
66ec389f5c
commit
35640abd82
1 file changed
+28
-23
+28
-23
@@ -161,14 +161,13 @@ class NameFinder(object):
|
||||
elif typ.isinstance(pr.Statement):
|
||||
types += self._remove_statements(typ, resolve_decorator)
|
||||
else:
|
||||
r = typ
|
||||
if isinstance(r, pr.Class):
|
||||
r = er.Class(self._evaluator, r)
|
||||
elif isinstance(r, pr.Function):
|
||||
r = er.Function(self._evaluator, r)
|
||||
if r.isinstance(er.Function) and resolve_decorator:
|
||||
r = r.get_decorated_func()
|
||||
types.append(r)
|
||||
if isinstance(typ, pr.Class):
|
||||
typ = er.Class(self._evaluator, typ)
|
||||
elif isinstance(typ, pr.Function):
|
||||
typ = er.Function(self._evaluator, typ)
|
||||
if typ.isinstance(er.Function) and resolve_decorator:
|
||||
typ = typ.get_decorated_func()
|
||||
types.append(typ)
|
||||
return types
|
||||
|
||||
def _remove_statements(self, r, resolve_decorator=False):
|
||||
@@ -190,12 +189,31 @@ class NameFinder(object):
|
||||
if r.is_global():
|
||||
for token_name in r.token_list[1:]:
|
||||
if isinstance(token_name, pr.Name):
|
||||
add = evaluator.find_types(r.parent, str(token_name))
|
||||
return evaluator.find_types(r.parent, str(token_name))
|
||||
else:
|
||||
# generated objects are used within executions, but these
|
||||
# objects are in functions, and we have to dynamically
|
||||
# execute first.
|
||||
if isinstance(r, pr.Param):
|
||||
return self._eval_param(r)
|
||||
# Remove the statement docstr stuff for now, that has to be
|
||||
# implemented with the evaluator class.
|
||||
#if r.docstr:
|
||||
#res_new.append(r)
|
||||
|
||||
add += evaluator.eval_statement(r, seek_name=self.name_str)
|
||||
|
||||
if check_instance is not None:
|
||||
# class renames
|
||||
add = [er.InstanceElement(evaluator, check_instance, a, True)
|
||||
if isinstance(a, (er.Function, pr.Function))
|
||||
else a for a in add]
|
||||
|
||||
return res_new + add
|
||||
|
||||
def _eval_param(self, r):
|
||||
evaluator = self._evaluator
|
||||
res_new = []
|
||||
func = r.parent
|
||||
|
||||
exc = pr.Class, pr.Function
|
||||
@@ -243,20 +261,7 @@ class NameFinder(object):
|
||||
# this means that there are no default params,
|
||||
# so just ignore it.
|
||||
return res_new
|
||||
# Remove the statement docstr stuff for now, that has to be
|
||||
# implemented with the evaluator class.
|
||||
#if r.docstr:
|
||||
#res_new.append(r)
|
||||
|
||||
add += evaluator.eval_statement(r, seek_name=self.name_str)
|
||||
|
||||
if check_instance is not None:
|
||||
# class renames
|
||||
add = [er.InstanceElement(evaluator, check_instance, a, True)
|
||||
if isinstance(a, (er.Function, pr.Function))
|
||||
else a for a in add]
|
||||
|
||||
return res_new + add
|
||||
return set(res_new) | evaluator.eval_statement(r, seek_name=self.name_str)
|
||||
|
||||
def _handle_for_loops(self, loop):
|
||||
# Take the first statement (for has always only
|
||||
|
||||
Reference in new issue
Block a user