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