forked from VimPlug/jedi
usages -> find_references
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ Jedi has a focus on autocompletion and goto functionality. Jedi is fast and is
|
||||
very well tested. It understands Python and stubs on a deep level.
|
||||
|
||||
Jedi has support for different goto functions. It's possible to search for
|
||||
usages and list names in a Python file to get information about them.
|
||||
references and list names in a Python file to get information about them.
|
||||
|
||||
Jedi uses a very simple API to connect with IDE's. There's a reference
|
||||
implementation as a `VIM-Plugin <https://github.com/davidhalter/jedi-vim>`_,
|
||||
|
||||
@@ -333,27 +333,27 @@ class Script(object):
|
||||
"""
|
||||
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.
|
||||
is very useful for refactoring (renaming), or to show all references of
|
||||
a variable.
|
||||
|
||||
:param include_builtins: Default True, checks if a usage is a builtin
|
||||
(e.g. ``sys``) and in that case does not return it.
|
||||
:param include_builtins: Default True, checks if a reference is a
|
||||
builtin (e.g. ``sys``) and in that case does not return it.
|
||||
:rtype: list of :class:`classes.Definition`
|
||||
"""
|
||||
|
||||
def _usages(include_builtins=True):
|
||||
def _references(include_builtins=True):
|
||||
tree_name = self._module_node.get_name_of_position((line, column))
|
||||
if tree_name is None:
|
||||
# Must be syntax
|
||||
return []
|
||||
|
||||
names = usages.usages(self._get_module_context(), tree_name)
|
||||
names = usages.find_references(self._get_module_context(), tree_name)
|
||||
|
||||
definitions = [classes.Definition(self._inference_state, n) for n in names]
|
||||
if not include_builtins:
|
||||
definitions = [d for d in definitions if not d.in_builtin_module()]
|
||||
return helpers.sorted_definitions(definitions)
|
||||
return _usages(**kwargs)
|
||||
return _references(**kwargs)
|
||||
|
||||
def call_signatures(self):
|
||||
# Deprecated, will be removed.
|
||||
|
||||
@@ -74,7 +74,7 @@ def dynamic_param_lookup(function_value, param_index):
|
||||
|
||||
path = function_value.get_root_context().py__file__()
|
||||
if path is not None and is_stdlib_path(path):
|
||||
# We don't want to search for usages in the stdlib. Usually people
|
||||
# We don't want to search for references in the stdlib. Usually people
|
||||
# don't work with it (except if you are a core maintainer, sorry).
|
||||
# This makes everything slower. Just disable it and run the tests,
|
||||
# you will see the slowdown, especially in 3.6.
|
||||
|
||||
@@ -32,7 +32,7 @@ def _find_names(module_context, tree_name):
|
||||
return _dictionarize(_resolve_names(found_names))
|
||||
|
||||
|
||||
def usages(module_context, tree_name):
|
||||
def find_references(module_context, tree_name):
|
||||
search_name = tree_name.value
|
||||
found_names = _find_names(module_context, tree_name)
|
||||
module_contexts = set(d.get_root_context() for d in found_names.values())
|
||||
|
||||
+3
-3
@@ -57,7 +57,7 @@ def rename(script, new_name):
|
||||
:param script: The source Script object.
|
||||
:return: list of changed lines/changed files
|
||||
"""
|
||||
return Refactoring(_rename(script.usages(), new_name))
|
||||
return Refactoring(_rename(script.find_references(), new_name))
|
||||
|
||||
|
||||
def _rename(names, replace_str):
|
||||
@@ -169,8 +169,8 @@ def inline(script):
|
||||
definitions = script.goto()
|
||||
assert len(definitions) == 1
|
||||
stmt = definitions[0]._definition
|
||||
usages = script.usages()
|
||||
inlines = [r for r in usages
|
||||
references = script.find_references()
|
||||
inlines = [r for r in references
|
||||
if not stmt.start_pos <= (r.line, r.column) <= stmt.end_pos]
|
||||
inlines = sorted(inlines, key=lambda x: (x.module_path, x.line, x.column),
|
||||
reverse=True)
|
||||
|
||||
Reference in New Issue
Block a user