[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
This commit is contained in:
Gongyu Deng 2020-06-04 09:53:05 +02:00 committed by Raphael Isemann
parent 0c1b88ec21
commit 2e8f304f5e
3 changed files with 21 additions and 0 deletions

View File

@ -494,6 +494,10 @@ public:
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);

View File

@ -1767,6 +1767,19 @@ public:
~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 {

View File

@ -371,6 +371,10 @@ class CommandLineCompletionTestCase(TestBase):
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("", [