This revision was automatically updated to reflect the committed changes. Closed by commit rG188f1ac301c5: [lldb] type category name common completion (authored by MrHate, committed by teemperor). Herald added a subscriber: lldb-commits.
Changed prior to commit: https://reviews.llvm.org/D84124?vs=279085&id=287448#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D84124/new/ https://reviews.llvm.org/D84124 Files: lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Interpreter/CommandObject.cpp lldb/test/API/functionalities/completion/TestCompletion.py
Index: lldb/test/API/functionalities/completion/TestCompletion.py =================================================================== --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -468,6 +468,12 @@ for subcommand in subcommands: self.complete_from_to('thread ' + subcommand + ' ', ['1']) + def test_common_completion_type_category_name(self): + subcommands = ['delete', 'list', 'enable', 'disable', 'define'] + for subcommand in subcommands: + self.complete_from_to('type category ' + subcommand + ' ', ['default']) + self.complete_from_to('type filter add -w ', ['default']) + def test_command_argument_completion(self): """Test completion of command arguments""" self.complete_from_to("watchpoint set variable -", ["-w", "-s"]) Index: lldb/source/Interpreter/CommandObject.cpp =================================================================== --- lldb/source/Interpreter/CommandObject.cpp +++ lldb/source/Interpreter/CommandObject.cpp @@ -1068,7 +1068,7 @@ { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." }, { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." }, { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { nullptr, false }, "A C++ method name." }, - { eArgTypeName, "name", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, + { eArgTypeName, "name", CommandCompletions::eTypeCategoryNameCompletion, { nullptr, false }, "Help text goes here." }, { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of lines to use." }, { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of items per line to display." }, Index: lldb/source/Commands/CommandObjectType.cpp =================================================================== --- lldb/source/Commands/CommandObjectType.cpp +++ lldb/source/Commands/CommandObjectType.cpp @@ -1769,6 +1769,14 @@ ~CommandObjectTypeCategoryDefine() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), + CommandCompletions::eTypeCategoryNameCompletion, request, nullptr); + } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); @@ -1865,6 +1873,14 @@ ~CommandObjectTypeCategoryEnable() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), + CommandCompletions::eTypeCategoryNameCompletion, request, nullptr); + } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); @@ -1927,6 +1943,14 @@ ~CommandObjectTypeCategoryDelete() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), + CommandCompletions::eTypeCategoryNameCompletion, request, nullptr); + } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); @@ -2032,6 +2056,14 @@ ~CommandObjectTypeCategoryDisable() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), + CommandCompletions::eTypeCategoryNameCompletion, request, nullptr); + } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); @@ -2089,6 +2121,16 @@ ~CommandObjectTypeCategoryList() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + if (request.GetCursorIndex()) + return; + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), + CommandCompletions::eTypeCategoryNameCompletion, request, nullptr); + } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); Index: lldb/source/Commands/CommandObjectTarget.cpp =================================================================== --- lldb/source/Commands/CommandObjectTarget.cpp +++ lldb/source/Commands/CommandObjectTarget.cpp @@ -4725,8 +4725,6 @@ void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override { - if (request.GetCursorIndex()) - return; CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eStopHookIDCompletion, request, nullptr); Index: lldb/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/source/Commands/CommandCompletions.cpp +++ lldb/source/Commands/CommandCompletions.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -74,7 +75,9 @@ {eProcessIDCompletion, CommandCompletions::ProcessIDs}, {eProcessNameCompletion, CommandCompletions::ProcessNames}, {eRemoteDiskFileCompletion, CommandCompletions::RemoteDiskFiles}, - {eRemoteDiskDirectoryCompletion, CommandCompletions::RemoteDiskDirectories}, + {eRemoteDiskDirectoryCompletion, + CommandCompletions::RemoteDiskDirectories}, + {eTypeCategoryNameCompletion, CommandCompletions::TypeCategoryNames}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -780,3 +783,14 @@ strm.GetString()); } } + +void CommandCompletions::TypeCategoryNames(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + DataVisualization::Categories::ForEach( + [&request](const lldb::TypeCategoryImplSP &category_sp) { + request.TryCompleteCurrentArg(category_sp->GetName(), + category_sp->GetDescription()); + return true; + }); +} Index: lldb/include/lldb/Interpreter/CommandCompletions.h =================================================================== --- lldb/include/lldb/Interpreter/CommandCompletions.h +++ lldb/include/lldb/Interpreter/CommandCompletions.h @@ -49,6 +49,7 @@ eProcessNameCompletion = (1u << 21), eRemoteDiskFileCompletion = (1u << 22), eRemoteDiskDirectoryCompletion = (1u << 23), + eTypeCategoryNameCompletion = (1u << 24), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. @@ -146,6 +147,10 @@ static void WatchPointIDs(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher); + + static void TypeCategoryNames(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher); }; } // namespace lldb_private
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits