diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fc918201..eed8cd02 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -23,7 +23,7 @@ Changelog - ``goto_assignments`` deprecated, use ``goto`` instead - ``goto_definitions`` deprecated, use ``infer`` instead - ``call_signatures`` deprecated, use ``find_signatures`` instead - - ``usages`` deprecated, use ``find_references`` instead + - ``usages`` deprecated, use ``get_references`` instead - ``jedi.names`` deprecated, use ``jedi.Script(...).names()`` - ``BaseDefinition.goto_assignments`` renamed to ``BaseDefinition.goto`` - Python 2 support deprecated. For this release it is best effort. Python 2 has diff --git a/README.rst b/README.rst index ef0d804e..6c3ce85b 100644 --- a/README.rst +++ b/README.rst @@ -130,7 +130,7 @@ Please check the API for a good explanation. There are the following commands: - ``jedi.Script.goto`` - ``jedi.Script.complete`` -- ``jedi.Script.find_references`` +- ``jedi.Script.get_references`` The returned objects are very powerful and really all you might need. diff --git a/docs/docs/api.rst b/docs/docs/api.rst index d0073587..111fdf26 100644 --- a/docs/docs/api.rst +++ b/docs/docs/api.rst @@ -119,7 +119,7 @@ References: ... else: ... del x''' >>> script = jedi.Script(source, '') - >>> rns = script.find_references(5, 8) + >>> rns = script.get_references(5, 8) >>> rns [, ] diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index ea840754..5cf02661 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -363,10 +363,10 @@ class Script(object): def usages(self, **kwargs): # Deprecated, will be removed. - return self.find_references(*self._pos, **kwargs) + return self.get_references(*self._pos, **kwargs) @validate_line_column - def find_references(self, line=None, column=None, **kwargs): + def get_references(self, line=None, column=None, **kwargs): """ Return :class:`classes.Definition` objects, which contain all names that point to the definition of the name under the cursor. This diff --git a/jedi/refactoring.py b/jedi/refactoring.py index df125bc6..6b5b4f66 100644 --- a/jedi/refactoring.py +++ b/jedi/refactoring.py @@ -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.find_references(), new_name)) + return Refactoring(_rename(script.get_references(), new_name)) def _rename(names, replace_str): @@ -169,7 +169,7 @@ def inline(script): definitions = script.goto() assert len(definitions) == 1 stmt = definitions[0]._definition - references = script.find_references() + references = script.get_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), diff --git a/sith.py b/sith.py index 64d8a308..24371874 100755 --- a/sith.py +++ b/sith.py @@ -95,7 +95,7 @@ class TestCase(object): args = json.load(f) return cls(*args) - operations = ['complete', 'goto', 'infer', 'find_references', 'find_signatures'] + operations = ['complete', 'goto', 'infer', 'get_references', 'find_signatures'] @classmethod def generate(cls, file_path): diff --git a/test/refactor/rename.py b/test/refactor/rename.py index 8faab24f..c717eb04 100644 --- a/test/refactor/rename.py +++ b/test/refactor/rename.py @@ -1,6 +1,6 @@ """ Test coverage for renaming is mostly being done by testing -`Script.find_references`. +`Script.get_references`. """ # --- simple diff --git a/test/run.py b/test/run.py index ff52f5fe..9fb3e3d8 100755 --- a/test/run.py +++ b/test/run.py @@ -204,7 +204,7 @@ class IntegrationTestCase(BaseTestCase): TEST_COMPLETIONS: self.run_completion, TEST_INFERENCE: self.run_inference, TEST_GOTO: self.run_goto, - TEST_REFERENCES: self.run_find_references, + TEST_REFERENCES: self.run_get_references, } if (self.path.endswith('pytest.py') or self.path.endswith('conftest.py')) \ and environment.executable != os.path.realpath(sys.executable): @@ -261,8 +261,8 @@ class IntegrationTestCase(BaseTestCase): comp_str = str(sorted(str(r.description) for r in result)) return compare_cb(self, comp_str, self.correct) - def run_find_references(self, compare_cb, environment): - result = self.script(environment).find_references(self.line_nr, self.column) + def run_get_references(self, compare_cb, environment): + result = self.script(environment).get_references(self.line_nr, self.column) self.correct = self.correct.strip() compare = sorted( (('stub:' if r.is_stub() else '') diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index 37c64c8c..af7dc3c7 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -68,7 +68,7 @@ def test_line_number_errors(Script): # ok Script(s).find_signatures(1, 0) - Script(s).find_references(1, len(s)) + Script(s).get_references(1, len(s)) def _check_number(Script, source, result='float'): @@ -163,7 +163,7 @@ def test_goto_definition_not_multiple(Script): def test_reference_description(Script): - descs = [u.description for u in Script("foo = ''; foo").find_references()] + descs = [u.description for u in Script("foo = ''; foo").get_references()] assert set(descs) == {"foo = ''", 'foo'} diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index 2711c269..77479e7a 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -52,7 +52,7 @@ def test_basedefinition_type(Script, names): definitions += script.infer(len(lines), len('variable')) script2 = Script(source, path=None) - definitions += script2.find_references(4, len('class C')) + definitions += script2.get_references(4, len('class C')) source_param = "def f(a): return a" script_param = Script(source_param, path=None) diff --git a/test/test_api/test_usages.py b/test/test_api/test_usages.py index ec3d47bd..c14c82ff 100644 --- a/test/test_api/test_usages.py +++ b/test/test_api/test_usages.py @@ -1,13 +1,13 @@ def test_import_references(Script): s = Script("from .. import foo", path="foo.py") - assert [usage.line for usage in s.find_references(line=1, column=18)] == [1] + assert [usage.line for usage in s.get_references(line=1, column=18)] == [1] def test_exclude_builtin_modules(Script): def get(include): from jedi.api.project import Project script = Script(source, _project=Project('', sys_path=[])) - references = script.find_references(column=8, include_builtins=include) + references = script.get_references(column=8, include_builtins=include) return [(d.line, d.column) for d in references] source = '''import sys\nprint(sys.path)''' places = get(include=True)