diff --git a/jedi/__init__.py b/jedi/__init__.py index 397aa9f4..ee18c817 100644 --- a/jedi/__init__.py +++ b/jedi/__init__.py @@ -22,7 +22,7 @@ example for the autocompletion feature: >>> script = jedi.Script(source, 3, len('datetime.da'), 'example.py') >>> script ->>> completions = script.complete() +>>> completions = script.completions() >>> completions #doctest: +ELLIPSIS [, , ...] >>> print(completions[0].complete) diff --git a/jedi/api.py b/jedi/api.py index 5a25baba..db8af43b 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -83,7 +83,7 @@ class Script(object): :return: Completion objects, sorted by name and __ comes last. :rtype: list of :class:`api_classes.Completion` """ - debug.speed('complete start') + debug.speed('completions start') path = self._module.get_path_until_cursor() if re.search('^\.|\.\.$', path): return [] @@ -161,14 +161,14 @@ class Script(object): comp_dct[k] = new comps.append(new) - debug.speed('complete end') + debug.speed('completions end') return sorted(comps, key=lambda x: (x.word.startswith('__'), x.word.startswith('_'), x.word.lower())) def _prepare_goto(self, goto_path, is_like_search=False): - """ Base for complete, goto and definition. Basically it returns + """ Base for completions, goto and definition. Basically it returns the resolved scopes under cursor. """ debug.dbg('start: %s in %s' % (goto_path, self._parser.user_scope)) @@ -551,4 +551,4 @@ def _quick_complete(source): lines = re.sub(r'[\n\r\s]*$', '', source).splitlines() pos = len(lines), len(lines[-1]) script = Script(source, pos[0], pos[1], '') - return script.complete() + return script.completions() diff --git a/jedi/api_classes.py b/jedi/api_classes.py index 3710680c..4e166f66 100644 --- a/jedi/api_classes.py +++ b/jedi/api_classes.py @@ -304,7 +304,7 @@ class BaseDefinition(object): class Completion(BaseDefinition): """ - `Completion` objects are returned from :meth:`api.Script.complete`. They + `Completion` objects are returned from :meth:`api.Script.completions`. They provide additional information about a completion. """ def __init__(self, name, needs_dot, like_name_length, base): diff --git a/test/base.py b/test/base.py index 56cfec3c..e6822a72 100644 --- a/test/base.py +++ b/test/base.py @@ -28,9 +28,9 @@ class TestBase(unittest.TestCase): script = self.get_script(src, pos) return script.definition() - def complete(self, src, pos=None, path=None): + def completions(self, src, pos=None, path=None): script = self.get_script(src, pos, path) - return script.complete() + return script.completions() def goto(self, src, pos=None): script = self.get_script(src, pos) diff --git a/test/completion/thirdparty/jedi_.py b/test/completion/thirdparty/jedi_.py index edb1a908..87ce6a8e 100644 --- a/test/completion/thirdparty/jedi_.py +++ b/test/completion/thirdparty/jedi_.py @@ -1,7 +1,7 @@ from jedi import functions, evaluate, parsing -el = functions.complete()[0] +el = functions.completions()[0] #? ['description'] el.description diff --git a/test/run.py b/test/run.py index 25eeccde..5d107cb7 100755 --- a/test/run.py +++ b/test/run.py @@ -10,7 +10,7 @@ tests. There are different kind of tests: -- complete / definitions ``#?`` +- completions / definitions ``#?`` - goto: ``#!`` - related names: ``#<`` @@ -25,7 +25,7 @@ multiple Python versions. .. _tox: http://testrun.org/tox Integration test cases are located in ``test/completion`` directory -and each test cases are indicated by the comment ``#?`` (complete / +and each test cases are indicated by the comment ``#?`` (completions / definitions), ``#!`` (assignments) and ``#<`` (usages). There is also support for third party libraries. In a normal test run they are not being executed, you have to provide a ``--thirdparty`` option. @@ -148,8 +148,8 @@ class IntegrationTestCase(object): return testers[self.test_type](compare_cb) def run_completion(self, compare_cb): - completions = self.script().complete() - #import cProfile; cProfile.run('script.complete()') + completions = self.script().completions() + #import cProfile; cProfile.run('script.completions()') comp_str = set([c.word for c in completions]) return compare_cb(self, comp_str, set(literal_eval(self.correct))) diff --git a/test/test_regression.py b/test/test_regression.py index 2484f48f..4faefd16 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -32,9 +32,9 @@ class TestRegression(TestBase): cache = api.cache cache.star_import_cache = {} # first empty... # path needs to be not-None (otherwise caching effects are not visible) - jedi.Script('', 1, 0, '').complete() + jedi.Script('', 1, 0, '').completions() time.sleep(2 * new) - jedi.Script('', 1, 0, '').complete() + jedi.Script('', 1, 0, '').completions() # reset values jedi.settings.star_import_cache_validity = old @@ -121,11 +121,11 @@ class TestRegression(TestBase): assert self.definition("", (1, 0)) == [] def test_complete_at_zero(self): - s = self.complete("str", (1, 3)) + s = self.completions("str", (1, 3)) assert len(s) == 1 assert list(s)[0].word == 'str' - s = self.complete("", (1, 0)) + s = self.completions("", (1, 0)) assert len(s) > 0 def test_definition_on_import(self): @@ -135,16 +135,16 @@ class TestRegression(TestBase): @cwd_at('jedi') def test_complete_on_empty_import(self): # should just list the files in the directory - assert 10 < len(self.complete("from .", path='')) < 30 - assert 10 < len(self.complete("from . import", (1, 5), '')) < 30 - assert 10 < len(self.complete("from . import classes", + assert 10 < len(self.completions("from .", path='')) < 30 + assert 10 < len(self.completions("from . import", (1, 5), '')) < 30 + assert 10 < len(self.completions("from . import classes", (1, 5), '')) < 30 - assert len(self.complete("import")) == 0 - assert len(self.complete("import import", path='')) > 0 + assert len(self.completions("import")) == 0 + assert len(self.completions("import import", path='')) > 0 # 111 - assert self.complete("from datetime import")[0].word == 'import' - assert self.complete("from datetime import ") + assert self.completions("from datetime import")[0].word == 'import' + assert self.completions("from datetime import ") def assert_call_def(self, call_def, name, index): self.assertEqual( @@ -276,18 +276,18 @@ class TestRegression(TestBase): def test_unicode_script(self): """ normally no unicode objects are being used. (<=2.7) """ s = unicode("import datetime; datetime.timedelta") - completions = self.complete(s) + completions = self.completions(s) assert len(completions) assert type(completions[0].description) is unicode s = utf8("author='öä'; author") - completions = self.complete(s) + completions = self.completions(s) x = completions[0].description assert type(x) is unicode s = utf8("#-*- coding: iso-8859-1 -*-\nauthor='öä'; author") s = s.encode('latin-1') - completions = self.complete(s) + completions = self.completions(s) assert type(completions[0].description) is unicode def test_multibyte_script(self): @@ -299,27 +299,27 @@ class TestRegression(TestBase): except NameError: pass # python 3 has no unicode method else: - assert len(self.complete(s, (1, len(code)))) + assert len(self.completions(s, (1, len(code)))) def test_unicode_attribute(self): """ github jedi-vim issue #94 """ s1 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n' ' name = "e"\n\nPerson().name.') - completions1 = self.complete(s1) + completions1 = self.completions(s1) assert 'strip' in [c.word for c in completions1] s2 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n' ' name = "é"\n\nPerson().name.') - completions2 = self.complete(s2) + completions2 = self.completions(s2) assert 'strip' in [c.word for c in completions2] def test_os_nowait(self): """ github issue #45 """ - s = self.complete("import os; os.P_") + s = self.completions("import os; os.P_") assert 'P_NOWAIT' in [i.word for i in s] def test_follow_definition(self): """ github issue #45 """ - c = self.complete("from datetime import timedelta; timedelta") + c = self.completions("from datetime import timedelta; timedelta") # type can also point to import, but there will be additional # attributes objs = itertools.chain.from_iterable(r.follow_definition() for r in c) @@ -344,7 +344,7 @@ class TestRegression(TestBase): """At some point, points were inserted into the completions, this caused problems, sometimes. """ - c = self.complete("if IndentationErr") + c = self.completions("if IndentationErr") assert c[0].word == 'IndentationError' self.assertEqual(c[0].complete, 'or') @@ -356,7 +356,7 @@ class TestRegression(TestBase): ''' arg.""" - words = [c.word for c in self.complete(s)] + words = [c.word for c in self.completions(s)] assert 'join' in words def test_docstrings_type_dotted_import(self): @@ -366,7 +366,7 @@ class TestRegression(TestBase): :type arg: threading.Thread ''' arg.""" - words = [c.word for c in self.complete(s)] + words = [c.word for c in self.completions(s)] assert 'start' in words def test_no_statement_parent(self): @@ -415,7 +415,7 @@ class TestDocstring(TestBase): class TestFeature(TestBase): def test_full_name(self): """ feature request #61""" - assert self.complete('import os; os.path.join')[0].full_name \ + assert self.completions('import os; os.path.join')[0].full_name \ == 'os.path.join' def test_keyword_full_name_should_be_none(self): @@ -427,7 +427,7 @@ class TestFeature(TestBase): assert d.full_name is None def test_full_name_builtin(self): - self.assertEqual(self.complete('type')[0].full_name, 'type') + self.assertEqual(self.completions('type')[0].full_name, 'type') def test_full_name_tuple_mapping(self): s = """ @@ -451,7 +451,7 @@ class TestFeature(TestBase): quick_completions = api._quick_complete(source) # Run real completion script = jedi.Script(source, pos[0], pos[1], '') - real_completions = script.complete() + real_completions = script.completions() # Compare results quick_values = [(c.full_name, c.line, c.column) for c in quick_completions] real_values = [(c.full_name, c.line, c.column) for c in real_completions] @@ -535,7 +535,7 @@ class TestSpeed(TestBase): @_check_speed(0.2) def test_os_path_join(self): s = "from posixpath import join; join('', '')." - assert len(self.complete(s)) > 10 # is a str completion + assert len(self.completions(s)) > 10 # is a str completion @_check_speed(0.1) def test_scipy_speed(self):