forked from VimPlug/jedi
Implement Script.complete_search instead of the complete param and return Completion objects
This commit is contained in:
@@ -344,16 +344,14 @@ class Script(object):
|
||||
|
||||
:param all_scopes: If True lists the symbols of all scopes instead of
|
||||
only the module.
|
||||
:param definitions: If True lists the names that have been defined by a
|
||||
class, function or a statement (``a = b`` returns ``a``).
|
||||
:param references: If True lists all the names that are not listed by
|
||||
``definitions=True``. E.g. ``a = b`` returns ``b``.
|
||||
"""
|
||||
return self._search(string, **kwargs) # Python 2 ...
|
||||
|
||||
def _search(self, string, all_scopes=False):
|
||||
return self._search_func(string, all_scopes=all_scopes)
|
||||
|
||||
@to_list
|
||||
def _search(self, string, complete=False, all_scopes=False,
|
||||
fuzzy=False):
|
||||
def _search_func(self, string, all_scopes=False, complete=False, fuzzy=False):
|
||||
names = self._names(all_scopes=all_scopes)
|
||||
wanted_type, wanted_names = helpers.split_search_string(string)
|
||||
return search_in_module(
|
||||
@@ -366,6 +364,9 @@ class Script(object):
|
||||
fuzzy=fuzzy,
|
||||
)
|
||||
|
||||
def complete_search(self, string, **kwargs):
|
||||
return self._search_func(string, complete=True, **kwargs)
|
||||
|
||||
@validate_line_column
|
||||
def help(self, line=None, column=None):
|
||||
"""
|
||||
|
||||
@@ -604,6 +604,14 @@ def search_in_module(inference_state, module_context, names, wanted_names,
|
||||
if convert:
|
||||
names = convert_names(names)
|
||||
for n2 in names:
|
||||
def_ = classes.Definition(inference_state, n2)
|
||||
if complete:
|
||||
def_ = classes.Completion(
|
||||
inference_state, n2,
|
||||
stack=None,
|
||||
like_name_length=len(last_name),
|
||||
is_fuzzy=fuzzy,
|
||||
)
|
||||
else:
|
||||
def_ = classes.Definition(inference_state, n2)
|
||||
if not wanted_type or wanted_type == def_.type:
|
||||
yield def_
|
||||
|
||||
Reference in New Issue
Block a user