[lldb] Tab completion for `frame recognizer delete`
authorGongyu Deng <gy_deng@icloud.com>
Tue, 30 Jun 2020 11:14:46 +0000 (13:14 +0200)
committerRaphael Isemann <teemperor@gmail.com>
Tue, 30 Jun 2020 11:50:14 +0000 (13:50 +0200)
Summary: Provided tab completion for command `frame recognizer delete`.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor, JDevlieghere

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81241

lldb/source/Commands/CommandObjectFrame.cpp
lldb/test/API/functionalities/completion/TestCompletion.py

index 9ad4e32..5677b16 100644 (file)
@@ -936,6 +936,33 @@ public:
 
   ~CommandObjectFrameRecognizerDelete() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest &request,
+                           OptionElementVector &opt_element_vector) override {
+    if (request.GetCursorIndex() != 0)
+      return;
+
+    StackFrameRecognizerManager::ForEach(
+        [&request](uint32_t rid, std::string rname, std::string module,
+                   llvm::ArrayRef<lldb_private::ConstString> symbols,
+                   bool regexp) {
+          StreamString strm;
+          if (rname.empty())
+            rname = "(internal)";
+
+          strm << rname;
+          if (!module.empty())
+            strm << ", module " << module;
+          if (!symbols.empty())
+            for (auto &symbol : symbols)
+              strm << ", symbol " << symbol;
+          if (regexp)
+            strm << " (regexp)";
+
+          request.TryCompleteCurrentArg(std::to_string(rid), strm.GetString());
+        });
+  }
+
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
     if (command.GetArgumentCount() == 0) {
index b9ddba3..0cec206 100644 (file)
@@ -421,6 +421,10 @@ class CommandLineCompletionTestCase(TestBase):
         lldbutil.run_to_source_breakpoint(self, '// Break here', self.main_source_spec)
 
         self.complete_from_to('frame select ', ['0'])
+    
+    def test_frame_recognizer_delete(self):
+        self.runCmd("frame recognizer add -l py_class -s module_name -n recognizer_name")
+        self.check_completion_with_desc('frame recognizer delete ', [['0', 'py_class, module module_name, symbol recognizer_name']])
 
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489")
     def test_symbol_name(self):