diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 75502259..b6f506de 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -491,14 +491,14 @@ class Script(object): def usages(self, additional_module_paths=()): """ - Return :class:`classes.Usage` objects, which contain all + Return :class:`classes.Definition` objects, which contain all names that point to the definition of the name under the cursor. This is very useful for refactoring (renaming), or to show all usages of a variable. .. todo:: Implement additional_module_paths - :rtype: list of :class:`classes.Usage` + :rtype: list of :class:`classes.Definition` """ temp, settings.dynamic_flow_information = \ settings.dynamic_flow_information, False @@ -520,13 +520,13 @@ class Script(object): for d in set(definitions): if isinstance(d, (pr.Module, compiled.CompiledObject)): - names.append(usages.Usage(self._evaluator, d)) + names.append(classes.Definition(self._evaluator, d)) elif isinstance(d, er.Instance): # Instances can be ignored, because they have been created by # ``__getattr__``. pass else: - names.append(usages.Usage(self._evaluator, d.names[-1], d)) + names.append(classes.Definition(self._evaluator, d.names[-1])) settings.dynamic_flow_information = temp return helpers.sorted_definitions(set(names)) diff --git a/jedi/api/usages.py b/jedi/api/usages.py index cfeb7710..0eedf8fa 100644 --- a/jedi/api/usages.py +++ b/jedi/api/usages.py @@ -6,13 +6,6 @@ from jedi.evaluate import imports from jedi.evaluate import helpers -class Usage(classes.Definition): - """TODO: document this""" - def __init__(self, evaluator, name_part, scope=None): - super(Usage, self).__init__(evaluator, name_part) - self._start_pos = name_part.start_pos - - def usages(evaluator, definitions, search_name, mods): def compare_array(definitions): """ `definitions` are being compared by module/start_pos, because @@ -58,8 +51,7 @@ def usages(evaluator, definitions, search_name, mods): compare_follow_res = compare_array(follow_res) # compare to see if they match if any(r in compare_definitions for r in compare_follow_res): - scope = call.parent - yield Usage(evaluator, search, scope) + yield classes.Definition(evaluator, search) if not definitions: return set() @@ -87,7 +79,7 @@ def usages(evaluator, definitions, search_name, mods): direct_resolve=True) f = i.follow(is_goto=True) if set(f) & set(definitions): - names.append(Usage(evaluator, name_part, stmt)) + names.append(classes.Definition(evaluator, name_part)) else: for call in helpers.scan_statement_for_calls(stmt, search_name, assignment_details=True): names += check_call_for_usage(call)