@@ -5639,6 +5639,79 @@ lldb_private::python::SWIGBridge::LLDBSwigPythonGetRepeatCommandForScriptedComma
5639
5639
return result.Str().GetString().str();
5640
5640
}
5641
5641
5642
+ StructuredData::DictionarySP
5643
+ lldb_private::python::SWIGBridge::LLDBSwigPythonHandleArgumentCompletionForScriptedCommand(PyObject *implementor,
5644
+ std::vector<llvm::StringRef> &args_vec, size_t args_pos, size_t pos_in_arg) {
5645
+
5646
+ PyErr_Cleaner py_err_cleaner(true);
5647
+
5648
+ PythonObject self(PyRefType::Borrowed, implementor);
5649
+ auto pfunc = self.ResolveName<PythonCallable>("handle_argument_completion");
5650
+ // If this isn't implemented, return an empty dict to signal falling back to default completion:
5651
+ if (!pfunc.IsAllocated())
5652
+ return {};
5653
+
5654
+ PythonList args_list(PyInitialValue::Empty);
5655
+ for (auto elem : args_vec)
5656
+ args_list.AppendItem(PythonString(elem));
5657
+
5658
+ PythonObject result = pfunc(args_list, PythonInteger(args_pos), PythonInteger(pos_in_arg));
5659
+ // Returning None means do the ordinary completion
5660
+ if (result.IsNone())
5661
+ return {};
5662
+
5663
+ // Convert the return dictionary to a DictionarySP.
5664
+ StructuredData::ObjectSP result_obj_sp = result.CreateStructuredObject();
5665
+ if (!result_obj_sp)
5666
+ return {};
5667
+
5668
+ StructuredData::DictionarySP dict_sp(new StructuredData::Dictionary(result_obj_sp));
5669
+ if (dict_sp->GetType() == lldb::eStructuredDataTypeInvalid)
5670
+ return {};
5671
+ return dict_sp;
5672
+ }
5673
+
5674
+ StructuredData::DictionarySP
5675
+ lldb_private::python::SWIGBridge::LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand(PyObject *implementor,
5676
+ llvm::StringRef &long_option, size_t pos_in_arg) {
5677
+
5678
+ PyErr_Cleaner py_err_cleaner(true);
5679
+
5680
+ PythonObject self(PyRefType::Borrowed, implementor);
5681
+ auto pfunc = self.ResolveName<PythonCallable>("handle_option_argument_completion");
5682
+ // If this isn't implemented, return an empty dict to signal falling back to default completion:
5683
+ if (!pfunc.IsAllocated())
5684
+ return {};
5685
+
5686
+ PythonObject result = pfunc(PythonString(long_option), PythonInteger(pos_in_arg));
5687
+ // Returning None means do the ordinary completion
5688
+ if (result.IsNone())
5689
+ return {};
5690
+
5691
+ // Returning a boolean:
5692
+ // True means the completion was handled, but there were no completions
5693
+ // False means that the completion was not handled, again, do the ordinary completion:
5694
+ if (result.GetObjectType() == PyObjectType::Boolean) {
5695
+ if (!result.IsTrue())
5696
+ return {};
5697
+ // Make up a completion dictionary with the right element:
5698
+ StructuredData::DictionarySP dict_sp(new StructuredData::Dictionary());
5699
+ dict_sp->AddBooleanItem("no-completion", true);
5700
+ return dict_sp;
5701
+ }
5702
+
5703
+
5704
+ // Convert the return dictionary to a DictionarySP.
5705
+ StructuredData::ObjectSP result_obj_sp = result.CreateStructuredObject();
5706
+ if (!result_obj_sp)
5707
+ return {};
5708
+
5709
+ StructuredData::DictionarySP dict_sp(new StructuredData::Dictionary(result_obj_sp));
5710
+ if (dict_sp->GetType() == lldb::eStructuredDataTypeInvalid)
5711
+ return {};
5712
+ return dict_sp;
5713
+ }
5714
+
5642
5715
#include "lldb/Interpreter/CommandReturnObject.h"
5643
5716
5644
5717
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
0 commit comments