mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 23:04:48 +08:00
Get at least some usages stuff right.
This commit is contained in:
@@ -6,7 +6,7 @@ from jedi.evaluate import imports
|
|||||||
from jedi.evaluate import helpers
|
from jedi.evaluate import helpers
|
||||||
|
|
||||||
|
|
||||||
def usages(evaluator, definitions, mods):
|
def usages(evaluator, definition_names, mods):
|
||||||
"""
|
"""
|
||||||
:param definitions: list of Name
|
:param definitions: list of Name
|
||||||
"""
|
"""
|
||||||
@@ -56,16 +56,25 @@ def usages(evaluator, definitions, mods):
|
|||||||
if any(r in compare_definitions for r in compare_follow_res):
|
if any(r in compare_definitions for r in compare_follow_res):
|
||||||
yield classes.Definition(evaluator, search)
|
yield classes.Definition(evaluator, search)
|
||||||
|
|
||||||
search_name = unicode(list(definitions)[0])
|
search_name = unicode(list(definition_names)[0])
|
||||||
compare_definitions = compare_array(definitions)
|
compare_definitions = compare_array(definition_names)
|
||||||
mods |= set([d.get_parent_until() for d in definitions])
|
mods |= set([d.get_parent_until() for d in definition_names])
|
||||||
names = []
|
definitions = []
|
||||||
for m in imports.get_modules_containing_name(mods, search_name):
|
for m in imports.get_modules_containing_name(mods, search_name):
|
||||||
try:
|
try:
|
||||||
stmts = m.used_names[search_name]
|
check_names = m.used_names[search_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
for stmt in stmts:
|
for name in check_names:
|
||||||
|
|
||||||
|
result = evaluator.goto(name)
|
||||||
|
if [c in compare_definitions for c in compare_array(result)]:
|
||||||
|
definitions.append(classes.Definition(evaluator, name))
|
||||||
|
|
||||||
|
continue # TODO DELETE
|
||||||
|
|
||||||
|
|
||||||
|
stmt = name.get_definition()
|
||||||
if isinstance(stmt, pr.Import):
|
if isinstance(stmt, pr.Import):
|
||||||
count = 0
|
count = 0
|
||||||
imps = []
|
imps = []
|
||||||
@@ -83,7 +92,7 @@ def usages(evaluator, definitions, mods):
|
|||||||
else:
|
else:
|
||||||
for call in helpers.scan_statement_for_calls(stmt, search_name, assignment_details=True):
|
for call in helpers.scan_statement_for_calls(stmt, search_name, assignment_details=True):
|
||||||
names += check_call_for_usage(call)
|
names += check_call_for_usage(call)
|
||||||
return names
|
return definitions
|
||||||
|
|
||||||
|
|
||||||
def usages_add_import_modules(evaluator, definitions):
|
def usages_add_import_modules(evaluator, definitions):
|
||||||
|
|||||||
@@ -1470,7 +1470,8 @@ class Param(Base):
|
|||||||
return self.get_parent_until(IsScope)
|
return self.get_parent_until(IsScope)
|
||||||
|
|
||||||
def get_code(self):
|
def get_code(self):
|
||||||
return self.tfpdef.get_code()
|
df = '' if self.default is None else '=' + self.default.get_code()
|
||||||
|
return self.tfpdef.get_code() + df
|
||||||
|
|
||||||
def __init__old(self):
|
def __init__old(self):
|
||||||
kwargs.pop('names_are_set_vars', None)
|
kwargs.pop('names_are_set_vars', None)
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ Renaming tests. This means search for usages.
|
|||||||
I always leave a little bit of space to add room for additions, because the
|
I always leave a little bit of space to add room for additions, because the
|
||||||
results always contain position informations.
|
results always contain position informations.
|
||||||
"""
|
"""
|
||||||
#< 4 (0,4), (3,0), (5,0)
|
#< 4 (0,4), (3,0), (5,0), (17,0)
|
||||||
def abc(): pass
|
def abc(): pass
|
||||||
|
|
||||||
#< 0 (-3,4), (0,0), (2,0)
|
#< 0 (-3,4), (0,0), (2,0), (14,0)
|
||||||
abc.d.a.bsaasd.abc.d
|
abc.d.a.bsaasd.abc.d
|
||||||
|
|
||||||
abc
|
abc
|
||||||
|
|||||||
Reference in New Issue
Block a user