forked from VimPlug/jedi
Merge branch 'dev' of github.com:davidhalter/jedi into dev
This commit is contained in:
22
jedi/api.py
22
jedi/api.py
@@ -7,7 +7,7 @@ catch :exc:`NotFoundError` which is being raised if your completion is not
|
||||
possible.
|
||||
"""
|
||||
from __future__ import with_statement
|
||||
__all__ = ['Script', 'NotFoundError', 'set_debug_function']
|
||||
__all__ = ['Script', 'NotFoundError', 'set_debug_function', '_quick_complete']
|
||||
|
||||
import re
|
||||
|
||||
@@ -464,3 +464,23 @@ def set_debug_function(func_cb=debug.print_to_stdout, warnings=True,
|
||||
debug.enable_warning = warnings
|
||||
debug.enable_notice = notices
|
||||
debug.enable_speed = speed
|
||||
|
||||
|
||||
def _quick_complete(source):
|
||||
"""
|
||||
Convenience function to complete a source string at the end.
|
||||
|
||||
Example::
|
||||
|
||||
>>> _quick_complete('import json\\njson.l')
|
||||
[<Completion: load>, <Completion: loads>]
|
||||
|
||||
:param source: The source code to be completed.
|
||||
:type source: string
|
||||
:return: Completion objects as returned by :meth:`complete`.
|
||||
:rtype: list of :class:`api_classes.Completion`
|
||||
"""
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user