[Lldb-commits] [lldb] 2e8f304 - [lldb] tab completion for `command script delete'

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 4 01:19:24 PDT 2020


Author: Gongyu Deng
Date: 2020-06-04T10:19:03+02:00
New Revision: 2e8f304f5ea5f7b2bd4f5689eae23d4399cd5120

URL: https://github.com/llvm/llvm-project/commit/2e8f304f5ea5f7b2bd4f5689eae23d4399cd5120
DIFF: https://github.com/llvm/llvm-project/commit/2e8f304f5ea5f7b2bd4f5689eae23d4399cd5120.diff

LOG: [lldb] tab completion for `command script delete'

Summary: Added the tab completion for `command script delete`.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

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

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/CommandInterpreter.h
    lldb/source/Commands/CommandObjectCommands.cpp
    lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index a0a9bcb49969..8a9dce7a19bc 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -494,6 +494,10 @@ class CommandInterpreter : public Broadcaster,
   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);

diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index b12377d71512..8f72ed7177e0 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1767,6 +1767,19 @@ class CommandObjectCommandsScriptDelete : public CommandObjectParsed {
 
   ~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 {
 

diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py
index 7c674dc872ed..4a548ad77083 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -371,6 +371,10 @@ def test_command_argument_completion(self):
         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("", [


        


More information about the lldb-commits mailing list