Add the ability to define custom completers to the parsed_cmd template. (#109062)
If your arguments or option values are of a type that naturally uses one of our common completion mechanisms, you will get completion for free. But if you have your own custom values or if you want to do fancy things like have `break set -s foo.dylib -n ba<TAB>` only complete on symbols in foo.dylib, you can use this new mechanism to achieve that.
This commit is contained in:
@@ -2720,6 +2720,46 @@ ScriptInterpreterPythonImpl::GetRepeatCommandForScriptedCommand(
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
StructuredData::DictionarySP
|
||||
ScriptInterpreterPythonImpl::HandleArgumentCompletionForScriptedCommand(
|
||||
StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args,
|
||||
size_t args_pos, size_t char_in_arg) {
|
||||
StructuredData::DictionarySP completion_dict_sp;
|
||||
if (!impl_obj_sp || !impl_obj_sp->IsValid())
|
||||
return completion_dict_sp;
|
||||
|
||||
{
|
||||
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
|
||||
Locker::FreeLock);
|
||||
|
||||
completion_dict_sp =
|
||||
SWIGBridge::LLDBSwigPythonHandleArgumentCompletionForScriptedCommand(
|
||||
static_cast<PyObject *>(impl_obj_sp->GetValue()), args, args_pos,
|
||||
char_in_arg);
|
||||
}
|
||||
return completion_dict_sp;
|
||||
}
|
||||
|
||||
StructuredData::DictionarySP
|
||||
ScriptInterpreterPythonImpl::HandleOptionArgumentCompletionForScriptedCommand(
|
||||
StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_option,
|
||||
size_t char_in_arg) {
|
||||
StructuredData::DictionarySP completion_dict_sp;
|
||||
if (!impl_obj_sp || !impl_obj_sp->IsValid())
|
||||
return completion_dict_sp;
|
||||
|
||||
{
|
||||
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
|
||||
Locker::FreeLock);
|
||||
|
||||
completion_dict_sp = SWIGBridge::
|
||||
LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand(
|
||||
static_cast<PyObject *>(impl_obj_sp->GetValue()), long_option,
|
||||
char_in_arg);
|
||||
}
|
||||
return completion_dict_sp;
|
||||
}
|
||||
|
||||
/// In Python, a special attribute __doc__ contains the docstring for an object
|
||||
/// (function, method, class, ...) if any is defined Otherwise, the attribute's
|
||||
/// value is None.
|
||||
|
||||
Reference in New Issue
Block a user