Get rid of all completions usages

This commit is contained in:
Dave Halter
2019-12-20 17:47:37 +01:00
parent 5bf6e7048b
commit 7f8ba17990
4 changed files with 20 additions and 21 deletions

View File

@@ -128,9 +128,9 @@ Autocompletion / Goto / Pydoc
Please check the API for a good explanation. There are the following commands: Please check the API for a good explanation. There are the following commands:
- ``jedi.Script.goto_assignments`` - ``jedi.Script.goto``
- ``jedi.Script.completions`` - ``jedi.Script.complete``
- ``jedi.Script.usages`` - ``jedi.Script.find_references``
The returned objects are very powerful and really all you might need. The returned objects are very powerful and really all you might need.

View File

@@ -29,7 +29,7 @@ API Documentation
The API consists of a few different parts: The API consists of a few different parts:
- The main starting points for completions/goto: :class:`.Script` and :class:`.Interpreter` - The main starting points for complete/goto: :class:`.Script` and :class:`.Interpreter`
- Helpful functions: :func:`.names`, :func:`.preload_module` and - Helpful functions: :func:`.names`, :func:`.preload_module` and
:func:`.set_debug_function` :func:`.set_debug_function`
- :ref:`API Result Classes <api-classes>` - :ref:`API Result Classes <api-classes>`
@@ -76,10 +76,10 @@ Completions:
>>> import jedi >>> import jedi
>>> source = '''import json; json.l''' >>> source = '''import json; json.l'''
>>> script = jedi.Script(source, 1, 19, '') >>> script = jedi.Script(source, path='')
>>> script >>> script
<jedi.api.Script object at 0x2121b10> <jedi.api.Script object at 0x2121b10>
>>> completions = script.completions() >>> completions = script.complete(1, 19)
>>> completions >>> completions
[<Completion: load>, <Completion: loads>] [<Completion: load>, <Completion: loads>]
>>> completions[1] >>> completions[1]
@@ -102,15 +102,15 @@ Definitions / Goto:
... inception = my_list[2] ... inception = my_list[2]
... ...
... inception()''' ... inception()'''
>>> script = jedi.Script(source, 8, 1, '') >>> script = jedi.Script(source, path='')
>>> >>>
>>> script.goto_assignments() >>> script.goto(8, 1)
[<Definition inception=my_list[2]>] [<Definition inception=my_list[2]>]
>>> >>>
>>> script.goto_definitions() >>> script.infer(8, 1)
[<Definition def my_func>] [<Definition def my_func>]
Related names: References:
.. sourcecode:: python .. sourcecode:: python
@@ -120,13 +120,12 @@ Related names:
... x = 4 ... x = 4
... else: ... else:
... del x''' ... del x'''
>>> script = jedi.Script(source, 5, 8, '') >>> script = jedi.Script(source, '')
>>> rns = script.related_names() >>> rns = script.find_references(5, 8)
>>> rns >>> rns
[<RelatedName x@3,4>, <RelatedName x@1,0>] [<Definition full_name='__main__.x', description='x = 3'>,
>>> rns[0].start_pos <Definition full_name='__main__.x', description='x'>]
(3, 4) >>> rns[1].line
>>> rns[0].is_keyword 5
False >>> rns[0].column
>>> rns[0].text 8
'x'

View File

@@ -47,7 +47,7 @@ def run(code, index, infer=False):
if infer: if infer:
result = script.goto_definitions() result = script.goto_definitions()
else: else:
result = script.completions() result = script.complete()
print('Used %ss for the %sth run.' % (time.time() - start, index + 1)) print('Used %ss for the %sth run.' % (time.time() - start, index + 1))
return result return result

View File

@@ -45,7 +45,7 @@ def run():
print('Process Memory before: %skB' % process_memory()) print('Process Memory before: %skB' % process_memory())
# After this the module should be cached. # After this the module should be cached.
# Need to invent a path so that it's really cached. # Need to invent a path so that it's really cached.
jedi.Script(wx_core, path='foobar.py').completions() jedi.Script(wx_core, path='foobar.py').complete()
gc.collect() # make sure that it's all fair and the gc did its job. gc.collect() # make sure that it's all fair and the gc did its job.
print('Process Memory after: %skB' % process_memory()) print('Process Memory after: %skB' % process_memory())