diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 3f8f4c60..2f2194a0 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -478,8 +478,9 @@ class Script(object): if isinstance(user_stmt, pr.ExprStmt): for name in user_stmt.get_defined_names(): if name.start_pos <= self._pos <= name.end_pos \ - and len(name.names) == 1: - return [name.names[0]] + and (not isinstance(name.parent, pr.Call) + or name.parent.next is None): + return [name] defs = self._evaluator.goto(stmt, call_path) definitions = follow_inexistent_imports(defs) @@ -505,16 +506,6 @@ class Script(object): # Without a definition for a name we cannot find references. return [] - # Once Script._goto works correct, we can probably remove this - # branch. - if isinstance(user_stmt, pr.ExprStmt): - c = user_stmt.expression_list()[0] - if not isinstance(c, unicode) and self._pos < c.start_pos: - # The lookup might be before `=` - definitions = [v.names[-1] for v in user_stmt.get_defined_names() - if unicode(v.names[-1]) == - list(definitions)[0].get_code()] - if not isinstance(user_stmt, pr.Import): # import case is looked at with add_import_name option definitions = usages.usages_add_import_modules(self._evaluator, diff --git a/jedi/api/usages.py b/jedi/api/usages.py index dc771254..deff43dc 100644 --- a/jedi/api/usages.py +++ b/jedi/api/usages.py @@ -25,8 +25,7 @@ def usages(evaluator, definitions, mods): while not stmt.parent.is_scope(): stmt = stmt.parent # New definition, call cannot be a part of stmt - if len(call.name) == 1 and call.next is None \ - and call.name in stmt.get_defined_names(): + if call.next is None and call.name in stmt.get_defined_names(): # Class params are not definitions (like function params). They # are super classes, that need to be resolved. if not (isinstance(stmt, pr.Param) and isinstance(stmt.parent, pr.Class)): diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index c89c4ba6..7c6366bf 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -337,7 +337,7 @@ class Evaluator(object): # name only. Otherwise it's a mixture between a definition and a # reference. In this case it's just a definition. So we stay on it. if len(call_path) == 1 and isinstance(call_path[0], pr.NamePart) \ - and call_path[0] in [d.names[-1] for d in stmt.get_defined_names()]: + and call_path[0] in stmt.get_defined_names(): # Named params should get resolved to their param definitions. if pr.Array.is_type(stmt.parent, pr.Array.TUPLE, pr.Array.NOARRAY) \ and stmt.parent.previous: diff --git a/test/completion/usages.py b/test/completion/usages.py index 447fa87c..e7b762d3 100644 --- a/test/completion/usages.py +++ b/test/completion/usages.py @@ -185,7 +185,7 @@ class TestClass(Super): TestClass.base_var - #< 13 (5,13), (0,13) + #< 13 (5,13), (0,13), (-24,13) self.instance_var = 3 #< 9 (0,8),