1
0
forked from VimPlug/jedi

Get a few more things right with params.

This commit is contained in:
Dave Halter
2014-10-25 02:25:09 +02:00
parent 9f1336095b
commit 4384e938e9
4 changed files with 11 additions and 5 deletions

View File

@@ -207,7 +207,7 @@ class Evaluator(object):
if isinstance(atom, pr.Name): if isinstance(atom, pr.Name):
# This is the first global lookup. # This is the first global lookup.
stmt = atom.get_parent_until((pr.ExprStmt, pr.ReturnStmt, pr.Scope)) stmt = atom.get_parent_until((pr.ExprStmt, pr.ReturnStmt, pr.Scope))
return self.find_types(stmt.parent, atom, stmt.start_pos, return self.find_types(stmt.get_parent_until(pr.IsScope), atom, stmt.start_pos,
search_global=True) search_global=True)
elif isinstance(atom, pr.Literal): elif isinstance(atom, pr.Literal):
return [compiled.create(self, atom.eval())] return [compiled.create(self, atom.eval())]

View File

@@ -87,6 +87,7 @@ class NameFinder(object):
stmt = name.get_definition() stmt = name.get_definition()
scope = stmt.parent scope = stmt.parent
print(name.parent, stmt, scope)
if scope in break_scopes: if scope in break_scopes:
continue continue

View File

@@ -125,9 +125,6 @@ class ExecutedParam(pr.Param):
instance.var_args = var_args instance.var_args = var_args
return instance return instance
def get_parent_until(self, *args, **kwargs):
return self.parent.get_parent_until(*args, **kwargs)
def _get_calling_var_args(evaluator, var_args): def _get_calling_var_args(evaluator, var_args):
old_var_args = None old_var_args = None

View File

@@ -1225,7 +1225,7 @@ class ArrayStmt(Statement):
""" """
class Param(object): class Param(Base):
""" """
The class which shows definitions of params of classes and functions. The class which shows definitions of params of classes and functions.
But this is not to define function calls. But this is not to define function calls.
@@ -1240,12 +1240,20 @@ class Param(object):
self.default = default self.default = default
self.stars = stars self.stars = stars
@property
def start_pos(self):
return self.tfpdef.start_pos
def get_name(self): def get_name(self):
if is_node(self.tfpdef, 'tfpdef'): if is_node(self.tfpdef, 'tfpdef'):
return self.tfpdef.children[0] return self.tfpdef.children[0]
else: else:
return self.tfpdef return self.tfpdef
@property
def parent_function(self):
return self.get_parent_until(IsScope)
def __init__old(self): def __init__old(self):
kwargs.pop('names_are_set_vars', None) kwargs.pop('names_are_set_vars', None)
super(Param, self).__init__(*args, names_are_set_vars=True, **kwargs) super(Param, self).__init__(*args, names_are_set_vars=True, **kwargs)