diff --git a/jedi/api.py b/jedi/api.py index e99d11a3..2fdea535 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -37,7 +37,7 @@ class NotFoundError(Exception): class Script(object): """ - A Script is the base for a completion, goto or whatever you want to do with + A Script is the base for completions, goto or whatever you want to do with |jedi|. :param source: The source code of the current file, separated by newlines. @@ -264,13 +264,13 @@ class Script(object): @api_classes._clear_caches_after_call def goto_definitions(self): """ - Return the definitions of a the path under the cursor. This is not a - goto function! This follows complicated paths and returns the end, not - the first definition. The big difference between :meth:`goto` and - :meth:`definition` is that :meth:`goto` doesn't follow imports and - statements. Multiple objects may be returned, because Python itself is - a dynamic language, which means depending on an option you can have two - different versions of a function. + Return the definitions of a the path under the cursor. goto function! + This follows complicated paths and returns the end, not the first + definition. The big difference between :meth:`goto_assignments` and + :meth:`goto_definitions` is that :meth:`goto_assignments` doesn't + follow imports and statements. Multiple objects may be returned, + because Python itself is a dynamic language, which means depending on + an option you can have two different versions of a function. :rtype: list of :class:`api_classes.Definition` """ @@ -328,10 +328,10 @@ class Script(object): @api_classes._clear_caches_after_call def goto_assignments(self): """ - Return the first definition found by goto. Imports and statements - aren't followed. Multiple objects may be returned, because Python - itself is a dynamic language, which means depending on an option you - can have two different versions of a function. + Return the first definition found. Imports and statements aren't + followed. Multiple objects may be returned, because Python itself is a + dynamic language, which means depending on an option you can have two + different versions of a function. :rtype: list of :class:`api_classes.Definition` """ @@ -340,7 +340,8 @@ class Script(object): def _goto(self, add_import_name=False): """ - Used for goto and usages. + Used for goto_assignments and usages. + :param add_import_name: TODO add description """ def follow_inexistent_imports(defs): diff --git a/jedi/api_classes.py b/jedi/api_classes.py index c1a5f62e..04be77e7 100644 --- a/jedi/api_classes.py +++ b/jedi/api_classes.py @@ -415,8 +415,8 @@ class Completion(BaseDefinition): class Definition(BaseDefinition): """ - *Definition* objects are returned from :meth:`api.Script.goto` or - :meth:`api.Script.definition`. + *Definition* objects are returned from :meth:`api.Script.goto_assignments` + or :meth:`api.Script.goto_definitions`. """ def __init__(self, definition): super(Definition, self).__init__(definition, definition.start_pos) diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 0e0641c2..88d9813f 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -359,7 +359,7 @@ class SubModule(Scope, Module): @property def name(self): - """ This is used for the goto function. """ + """ This is used for the goto functions. """ if self._name is not None: return self._name if self.path is None: diff --git a/test/base.py b/test/base.py index e6822a72..6226a431 100644 --- a/test/base.py +++ b/test/base.py @@ -32,9 +32,9 @@ class TestBase(unittest.TestCase): script = self.get_script(src, pos, path) return script.completions() - def goto(self, src, pos=None): + def goto_assignments(self, src, pos=None): script = self.get_script(src, pos) - return script.goto() + return script.goto_assignments() def function_definition(self, src, pos=None): script = self.get_script(src, pos) diff --git a/test/completion/goto.py b/test/completion/goto.py index 7b777609..fca68ae3 100644 --- a/test/completion/goto.py +++ b/test/completion/goto.py @@ -1,4 +1,4 @@ -# goto command tests are a different in syntax +# goto_assignments command tests are different in syntax definition = 3 #! 0 ['a = definition'] diff --git a/test/completion/renaming.py b/test/completion/renaming.py index 850d8d1b..f6b990fb 100644 --- a/test/completion/renaming.py +++ b/test/completion/renaming.py @@ -1,5 +1,5 @@ """ -Renaming tests. This means search for related names. +Renaming tests. This means search for usages. I always leave a little bit of space to add room for additions, because the results always contain position informations. """ diff --git a/test/completion/thirdparty/jedi_.py b/test/completion/thirdparty/jedi_.py index 87ce6a8e..6870486c 100644 --- a/test/completion/thirdparty/jedi_.py +++ b/test/completion/thirdparty/jedi_.py @@ -10,8 +10,7 @@ el.description scopes, path, dot, like = \ - functions.prepare_goto(source, row, column, - source_path, True) + api._prepare_goto(source, row, column, source_path, True) # has problems with that (sometimes) very deep nesting. #? set() diff --git a/test/run.py b/test/run.py index 8550afda..220c8d99 100755 --- a/test/run.py +++ b/test/run.py @@ -10,9 +10,9 @@ tests. There are different kind of tests: -- completions / definitions ``#?`` -- goto: ``#!`` -- related names: ``#<`` +- completions / goto_definitions ``#?`` +- goto_assignments: ``#!`` +- usages: ``#<`` How to run tests? +++++++++++++++++ @@ -63,8 +63,8 @@ For example:: Because it follows ``a.rea`` and a is an ``int``, which has a ``real`` property. -Definition -++++++++++ +Goto Definitions ++++++++++++++++ Definition tests use the same symbols like completion tests. This is possible because the completion tests are defined with a list:: @@ -72,8 +72,8 @@ possible because the completion tests are defined with a list:: #? int() ab = 3; ab -Goto -++++ +Goto Assignments +++++++++++++++++ Tests look like this:: @@ -87,7 +87,7 @@ the test (otherwise it's just end of line):: #! 2 ['abc=1'] abc -Related Names +Usages +++++++++++++ Tests look like this:: @@ -141,8 +141,8 @@ class IntegrationTestCase(object): def run(self, compare_cb): testers = { TEST_COMPLETIONS: self.run_completion, - TEST_DEFINITIONS: self.run_definition, - TEST_ASSIGNMENTS: self.run_goto, + TEST_DEFINITIONS: self.run_goto_definitions, + TEST_ASSIGNMENTS: self.run_goto_assignments, TEST_USAGES: self.run_usages, } return testers[self.test_type](compare_cb) @@ -154,11 +154,11 @@ class IntegrationTestCase(object): comp_str = set([c.name for c in completions]) return compare_cb(self, comp_str, set(literal_eval(self.correct))) - def run_definition(self, compare_cb): + def run_goto_definitions(self, compare_cb): def definition(correct, correct_start, path): def defs(line_nr, indent): s = jedi.Script(self.source, line_nr, indent, path) - return set(s.definition()) + return set(s.goto_definitions()) should_be = set() number = 0 @@ -183,12 +183,12 @@ class IntegrationTestCase(object): script = self.script() should_str = definition(self.correct, self.start, script.source_path) - result = script.definition() + result = script.goto_definitions() is_str = set(r.desc_with_module for r in result) return compare_cb(self, is_str, should_str) - def run_goto(self, compare_cb): - result = self.script().goto() + def run_goto_assignments(self, compare_cb): + result = self.script().goto_assignments() comp_str = str(sorted(str(r.description) for r in result)) return compare_cb(self, comp_str, self.correct) @@ -242,7 +242,7 @@ def collect_file_tests(lines, lines_to_execute): else: try: r = re.search(r'(?:^|(?<=\s))#([?!<])\s*([^\n]+)', line) - # test_type is ? for completion and ! for goto + # test_type is ? for completion and ! for goto_assignments test_type = r.group(1) correct = r.group(2) start = r.start() diff --git a/test/test_api_classes.py b/test/test_api_classes.py index 6e5bf211..a36551ab 100644 --- a/test/test_api_classes.py +++ b/test/test_api_classes.py @@ -42,7 +42,7 @@ def make_definitions(): source_param = "def f(a): return a" script_param = api.Script(source_param, 1, len(source_param), None) - definitions += script_param.goto() + definitions += script_param.goto_assignments() return definitions diff --git a/test/test_regression.py b/test/test_regression.py index f2af7ae5..0e237d39 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -336,7 +336,8 @@ class TestRegression(TestBase): assert [d.doc for d in defs] def test_goto_following_on_imports(self): - g = self.goto("import multiprocessing.dummy; multiprocessing.dummy") + s = "import multiprocessing.dummy; multiprocessing.dummy" + g = self.goto_assignments(s) assert len(g) == 1 assert g[0].start_pos != (0, 0)