usages issues.

This commit is contained in:
Dave Halter
2014-09-25 00:14:43 +02:00
parent 9ecf3774a0
commit 59225ceaa3
4 changed files with 6 additions and 16 deletions

View File

@@ -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,

View File

@@ -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)):

View File

@@ -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:

View File

@@ -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),