[Lldb-commits] [PATCH] D80775: [lldb] tab completion for `command script delete'

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 4 01:35:12 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e8f304f5ea5: [lldb] tab completion for `command script delete' (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80775/new/

https://reviews.llvm.org/D80775

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CommandObjectCommands.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
@@ -371,6 +371,10 @@
         self.complete_from_to("watchpoint set variable foo --watch w", "watchpoint set variable foo --watch write")
         self.complete_from_to('watchpoint set variable foo -w read_', 'watchpoint set variable foo -w read_write')
 
+    def test_command_script_delete(self):
+        self.runCmd("command script add -h test_desc -f none -s current usercmd1")
+        self.check_completion_with_desc('command script delete ', [['usercmd1', 'test_desc']])
+
     def test_completion_description_commands(self):
         """Test descriptions of top-level command completions"""
         self.check_completion_with_desc("", [
Index: lldb/source/Commands/CommandObjectCommands.cpp
===================================================================
--- lldb/source/Commands/CommandObjectCommands.cpp
+++ lldb/source/Commands/CommandObjectCommands.cpp
@@ -1767,6 +1767,19 @@
 
   ~CommandObjectCommandsScriptDelete() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest &request,
+                           OptionElementVector &opt_element_vector) override {
+
+    if (!m_interpreter.HasCommands() || request.GetCursorIndex() != 0)
+      return;
+    const auto &user_dict = m_interpreter.GetUserCommands();
+
+    for (auto pos = user_dict.begin(); pos != user_dict.end(); ++pos) {
+      request.TryCompleteCurrentArg(pos->first, pos->second->GetHelp());
+    }
+  }
+
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
 
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===================================================================
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -494,6 +494,10 @@
   bool GetEchoCommentCommands() const;
   void SetEchoCommentCommands(bool enable);
 
+  const CommandObject::CommandMap &GetUserCommands() const {
+    return m_user_dict;
+  }
+
   /// Specify if the command interpreter should allow that the user can
   /// specify a custom exit code when calling 'quit'.
   void AllowExitCodeOnQuit(bool allow);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80775.268384.patch
Type: text/x-patch
Size: 2370 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200604/d8c79bf9/attachment-0001.bin>


More information about the lldb-commits mailing list