From 21631494b068d9364b8dc8f18e59adee9131a0a5 Mon Sep 17 00:00:00 2001 From: jimingham Date: Mon, 19 Feb 2024 16:43:08 -0800 Subject: Centralize the handling of completion for simple argument lists. (#82085) Most commands were adding argument completion handling by themselves, resulting in a lot of unnecessary boilerplate. In many cases, this could be done generically given the argument definition and the entries in the g_argument_table. I'm going to address this in a couple passes. In this first pass, I added handling of commands that have only one argument list, with one argument type, either single or repeated, and changed all the commands that are of this sort (and don't have other bits of business in their completers.) I also added some missing connections between arg types and completions to the table, and added a RemoteFilename and RemotePath to use in places where we were using the Remote completers. Those arguments used to say they were "files" but they were in fact remote files. I also added a module arg type to use where we were using the module completer. In that case, we should call the argument module. --- lldb/source/Commands/CommandObjectTarget.cpp | 29 +++------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'lldb/source/Commands/CommandObjectTarget.cpp') diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index c3ecdb7..4e006e4 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -257,13 +257,6 @@ public: Options *GetOptions() override { return &m_option_group; } - void - HandleArgumentCompletion(CompletionRequest &request, - OptionElementVector &opt_element_vector) override { - lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks( - GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr); - } - protected: void DoExecute(Args &command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); @@ -2789,13 +2782,6 @@ public: Options *GetOptions() override { return &m_option_group; } - void - HandleArgumentCompletion(CompletionRequest &request, - OptionElementVector &opt_element_vector) override { - lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks( - GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr); - } - protected: OptionGroupOptions m_option_group; OptionGroupUUID m_uuid_option_group; @@ -3233,7 +3219,7 @@ public: : CommandObjectParsed( interpreter, "target modules list", "List current executable and dependent shared library images.") { - CommandArgumentData module_arg{eArgTypeShlibName, eArgRepeatStar}; + CommandArgumentData module_arg{eArgTypeModule, eArgRepeatStar}; m_arguments.push_back({module_arg}); } @@ -4343,13 +4329,6 @@ public: ~CommandObjectTargetSymbolsAdd() override = default; - void - HandleArgumentCompletion(CompletionRequest &request, - OptionElementVector &opt_element_vector) override { - lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks( - GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr); - } - Options *GetOptions() override { return &m_option_group; } protected: @@ -5195,8 +5174,7 @@ public: OptionElementVector &opt_element_vector) override { if (request.GetCursorIndex()) return; - lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks( - GetCommandInterpreter(), lldb::eStopHookIDCompletion, request, nullptr); + CommandObject::HandleArgumentCompletion(request, opt_element_vector); } protected: @@ -5251,8 +5229,7 @@ public: OptionElementVector &opt_element_vector) override { if (request.GetCursorIndex()) return; - lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks( - GetCommandInterpreter(), lldb::eStopHookIDCompletion, request, nullptr); + CommandObject::HandleArgumentCompletion(request, opt_element_vector); } protected: -- cgit v1.1