Index: lldb/include/lldb/DataFormatters/FormattersContainer.h =================================================================== --- lldb/include/lldb/DataFormatters/FormattersContainer.h +++ lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -212,6 +212,10 @@ void ForEach(ForEachCallback callback) { m_format_map.ForEach(callback); } + void AutoComplete(CompletionRequest &request) { + AutoComplete(request, EmptyStruct()); + } + uint32_t GetCount() { return m_format_map.GetCount(); } protected: @@ -319,6 +323,34 @@ } return false; } + +private: + // The struct below is used to provide specialized AutoComplete functions with + // overloading. + template struct EmptyStruct {}; + + template + void AutoComplete(CompletionRequest &request, const EmptyStruct<_Ty> &) {} + + void AutoComplete(CompletionRequest &request, + const EmptyStruct &) { + m_format_map.ForEach( + [&request](const ConstString &key, + const typename ValueType::SharedPointer &value) { + request.TryCompleteCurrentArg(key.GetStringRef()); + return true; + }); + } + + void AutoComplete(CompletionRequest &request, + const EmptyStruct &) { + m_format_map.ForEach( + [&request](const RegularExpression &key, + const typename ValueType::SharedPointer &value) { + request.TryCompleteCurrentArg(key.GetText()); + return true; + }); + } }; } // namespace lldb_private Index: lldb/source/Commands/CommandObjectType.cpp =================================================================== --- lldb/source/Commands/CommandObjectType.cpp +++ lldb/source/Commands/CommandObjectType.cpp @@ -777,6 +777,47 @@ ~CommandObjectTypeFormatterDelete() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + if (request.GetCursorIndex()) + return; + + DataVisualization::Categories::ForEach( + [this, &request](const lldb::TypeCategoryImplSP &category_sp) { + if ((m_formatter_kind_mask & eFormatCategoryItemValue) == + eFormatCategoryItemValue) + category_sp->GetTypeFormatsContainer()->AutoComplete(request); + if ((m_formatter_kind_mask & eFormatCategoryItemRegexValue) == + eFormatCategoryItemRegexValue) + category_sp->GetRegexTypeFormatsContainer()->AutoComplete(request); + + if ((m_formatter_kind_mask & eFormatCategoryItemSummary) == + eFormatCategoryItemSummary) + category_sp->GetTypeSummariesContainer()->AutoComplete(request); + if ((m_formatter_kind_mask & eFormatCategoryItemRegexSummary) == + eFormatCategoryItemRegexSummary) + category_sp->GetRegexTypeSummariesContainer()->AutoComplete( + request); + + if ((m_formatter_kind_mask & eFormatCategoryItemFilter) == + eFormatCategoryItemFilter) + category_sp->GetTypeFiltersContainer()->AutoComplete(request); + if ((m_formatter_kind_mask & eFormatCategoryItemRegexFilter) == + eFormatCategoryItemRegexFilter) + category_sp->GetRegexTypeFiltersContainer()->AutoComplete(request); + + if ((m_formatter_kind_mask & eFormatCategoryItemSynth) == + eFormatCategoryItemSynth) + category_sp->GetTypeSyntheticsContainer()->AutoComplete(request); + if ((m_formatter_kind_mask & eFormatCategoryItemRegexSynth) == + eFormatCategoryItemRegexSynth) + category_sp->GetRegexTypeSyntheticsContainer()->AutoComplete( + request); + return true; + }); + } + protected: virtual bool FormatterSpecificDeletion(ConstString typeCS) { return false; } Index: lldb/test/API/functionalities/completion/TestCompletion.py =================================================================== --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -437,6 +437,27 @@ # (anonymous namespace)::Quux(). self.complete_from_to('breakpoint set -n Qu', '') + def test_completion_type_formatter_delete(self): + self.runCmd('type filter add --child a Aoo') + self.complete_from_to('type filter delete ', ['Aoo']) + self.runCmd('type filter add --child b -x Boo') + self.complete_from_to('type filter delete ', ['Boo']) + + self.runCmd('type format add -f hex Coo') + self.complete_from_to('type format delete ', ['Coo']) + self.runCmd('type format add -f hex -x Doo') + self.complete_from_to('type format delete ', ['Doo']) + + self.runCmd('type summary add -c Eoo') + self.complete_from_to('type summary delete ', ['Eoo']) + self.runCmd('type summary add -x -c Foo') + self.complete_from_to('type summary delete ', ['Foo']) + + self.runCmd('type synthetic add Goo -l test') + self.complete_from_to('type synthetic delete ', ['Goo']) + self.runCmd('type synthetic add -x Hoo -l test') + self.complete_from_to('type synthetic delete ', ['Hoo']) + @skipIf(archs=no_match(['x86_64'])) def test_register_read_and_write_on_x86(self): """Test the completion of the commands register read and write on x86"""