mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
usages issues.
This commit is contained in:
@@ -478,8 +478,9 @@ class Script(object):
|
|||||||
if isinstance(user_stmt, pr.ExprStmt):
|
if isinstance(user_stmt, pr.ExprStmt):
|
||||||
for name in user_stmt.get_defined_names():
|
for name in user_stmt.get_defined_names():
|
||||||
if name.start_pos <= self._pos <= name.end_pos \
|
if name.start_pos <= self._pos <= name.end_pos \
|
||||||
and len(name.names) == 1:
|
and (not isinstance(name.parent, pr.Call)
|
||||||
return [name.names[0]]
|
or name.parent.next is None):
|
||||||
|
return [name]
|
||||||
|
|
||||||
defs = self._evaluator.goto(stmt, call_path)
|
defs = self._evaluator.goto(stmt, call_path)
|
||||||
definitions = follow_inexistent_imports(defs)
|
definitions = follow_inexistent_imports(defs)
|
||||||
@@ -505,16 +506,6 @@ class Script(object):
|
|||||||
# Without a definition for a name we cannot find references.
|
# Without a definition for a name we cannot find references.
|
||||||
return []
|
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):
|
if not isinstance(user_stmt, pr.Import):
|
||||||
# import case is looked at with add_import_name option
|
# import case is looked at with add_import_name option
|
||||||
definitions = usages.usages_add_import_modules(self._evaluator,
|
definitions = usages.usages_add_import_modules(self._evaluator,
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ def usages(evaluator, definitions, mods):
|
|||||||
while not stmt.parent.is_scope():
|
while not stmt.parent.is_scope():
|
||||||
stmt = stmt.parent
|
stmt = stmt.parent
|
||||||
# New definition, call cannot be a part of stmt
|
# New definition, call cannot be a part of stmt
|
||||||
if len(call.name) == 1 and call.next is None \
|
if call.next is None and call.name in stmt.get_defined_names():
|
||||||
and call.name in stmt.get_defined_names():
|
|
||||||
# Class params are not definitions (like function params). They
|
# Class params are not definitions (like function params). They
|
||||||
# are super classes, that need to be resolved.
|
# are super classes, that need to be resolved.
|
||||||
if not (isinstance(stmt, pr.Param) and isinstance(stmt.parent, pr.Class)):
|
if not (isinstance(stmt, pr.Param) and isinstance(stmt.parent, pr.Class)):
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ class Evaluator(object):
|
|||||||
# name only. Otherwise it's a mixture between a definition and a
|
# 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.
|
# 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) \
|
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.
|
# Named params should get resolved to their param definitions.
|
||||||
if pr.Array.is_type(stmt.parent, pr.Array.TUPLE, pr.Array.NOARRAY) \
|
if pr.Array.is_type(stmt.parent, pr.Array.TUPLE, pr.Array.NOARRAY) \
|
||||||
and stmt.parent.previous:
|
and stmt.parent.previous:
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class TestClass(Super):
|
|||||||
TestClass.base_var
|
TestClass.base_var
|
||||||
|
|
||||||
|
|
||||||
#< 13 (5,13), (0,13)
|
#< 13 (5,13), (0,13), (-24,13)
|
||||||
self.instance_var = 3
|
self.instance_var = 3
|
||||||
|
|
||||||
#< 9 (0,8),
|
#< 9 (0,8),
|
||||||
|
|||||||
Reference in New Issue
Block a user