mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Usages are pretty solid now except for parser issues.
This commit is contained in:
@@ -445,6 +445,13 @@ class Script(object):
|
||||
if stmt is None:
|
||||
return []
|
||||
|
||||
if user_stmt is None:
|
||||
last_name = None
|
||||
else:
|
||||
# Try to use the parser if possible.
|
||||
last_name = user_stmt.name_for_position(self._pos)
|
||||
|
||||
if last_name is None:
|
||||
last_name = stmt
|
||||
while not isinstance(last_name, pr.Name):
|
||||
last_name = last_name.children[-1]
|
||||
|
||||
@@ -68,7 +68,7 @@ def usages(evaluator, definition_names, mods):
|
||||
for name in check_names:
|
||||
|
||||
result = evaluator.goto(name)
|
||||
if [c in compare_definitions for c in compare_array(result)]:
|
||||
if [c for c in compare_array(result) if c in compare_definitions]:
|
||||
definitions.append(classes.Definition(evaluator, name))
|
||||
|
||||
continue # TODO DELETE
|
||||
|
||||
@@ -446,6 +446,8 @@ class Evaluator(object):
|
||||
stmt = name.parent
|
||||
if isinstance(stmt, pr.ExprStmt) and name in stmt.get_defined_names():
|
||||
return [name]
|
||||
elif isinstance(stmt, (pr.Param, pr.Function, pr.Class)) and stmt.name is name:
|
||||
return [name]
|
||||
|
||||
scope = name.get_parent_scope()
|
||||
if pr.is_node(name.parent, 'trailer'):
|
||||
|
||||
@@ -1456,6 +1456,11 @@ class Param(Base):
|
||||
return self.tfpdef.start_pos
|
||||
|
||||
def get_name(self):
|
||||
# TODO remove!
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
if is_node(self.tfpdef, 'tfpdef'):
|
||||
return self.tfpdef.children[0]
|
||||
else:
|
||||
|
||||
@@ -13,16 +13,18 @@ abc
|
||||
# unicode chars shouldn't be a problem.
|
||||
x['smörbröd'].abc
|
||||
|
||||
# With the new parser these statements are not recognized as stateents, because
|
||||
# they are not valid Python.
|
||||
if 1:
|
||||
abc =
|
||||
else:
|
||||
(abc) =
|
||||
|
||||
abc =
|
||||
|
||||
#< (-3,0), (0,0)
|
||||
#< (-17,4), (-14,0), (-12,0), (0,0)
|
||||
abc
|
||||
|
||||
abc = 5
|
||||
|
||||
|
||||
Abc = 3
|
||||
|
||||
@@ -48,11 +50,11 @@ Abc.d.Abc
|
||||
|
||||
|
||||
#< 4 (0,4), (4,1)
|
||||
def blub():
|
||||
def blubi():
|
||||
|
||||
|
||||
#< (-4,4), (0,1)
|
||||
@blub
|
||||
@blubi
|
||||
def a(): pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user