aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Commands/CommandObjectMultiword.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lldb/source/Commands/CommandObjectMultiword.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Commands/CommandObjectMultiword.cpp68
1 files changed, 30 insertions, 38 deletions
diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectMultiword.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectMultiword.cpp
index 4011cceb8a26..03a3770d8df7 100644
--- a/contrib/llvm-project/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -93,9 +93,11 @@ bool CommandObjectMultiword::Execute(const char *args_string,
return result.Succeeded();
}
- auto sub_command = args[0].ref;
- if (sub_command.empty())
+ auto sub_command = args[0].ref();
+ if (sub_command.empty()) {
+ result.AppendError("Need to specify a non-empty subcommand.");
return result.Succeeded();
+ }
if (sub_command.equals_lower("help")) {
this->CommandObject::GenerateHelpText(result);
@@ -136,9 +138,9 @@ bool CommandObjectMultiword::Execute(const char *args_string,
if (num_subcmd_matches > 0) {
error_msg.append(" Possible completions:");
- for (size_t i = 0; i < matches.GetSize(); i++) {
+ for (const std::string &match : matches) {
error_msg.append("\n\t");
- error_msg.append(matches.GetStringAtIndex(i));
+ error_msg.append(match);
}
}
error_msg.append("\n");
@@ -179,12 +181,8 @@ void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
"'help <command> <subcommand>'.\n");
}
-int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
- // Any of the command matches will provide a complete word, otherwise the
- // individual completers will override this.
- request.SetWordComplete(true);
-
- auto arg0 = request.GetParsedLine()[0].ref;
+void CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
+ auto arg0 = request.GetParsedLine()[0].ref();
if (request.GetCursorIndex() == 0) {
StringList new_matches, descriptions;
AddNamesMatchingPartialString(m_subcommand_dict, arg0, new_matches,
@@ -197,32 +195,28 @@ int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
StringList temp_matches;
CommandObject *cmd_obj = GetSubcommandObject(arg0, &temp_matches);
if (cmd_obj != nullptr) {
- if (request.GetParsedLine().GetArgumentCount() == 1) {
- request.SetWordComplete(true);
- } else {
+ if (request.GetParsedLine().GetArgumentCount() != 1) {
request.GetParsedLine().Shift();
- request.SetCursorCharPosition(0);
- request.GetParsedLine().AppendArgument(llvm::StringRef());
- return cmd_obj->HandleCompletion(request);
+ request.AppendEmptyArgument();
+ cmd_obj->HandleCompletion(request);
}
}
}
- return new_matches.GetSize();
- } else {
- StringList new_matches;
- CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
- if (sub_command_object == nullptr) {
- request.AddCompletions(new_matches);
- return request.GetNumberOfMatches();
- } else {
- // Remove the one match that we got from calling GetSubcommandObject.
- new_matches.DeleteStringAtIndex(0);
- request.AddCompletions(new_matches);
- request.GetParsedLine().Shift();
- request.SetCursorIndex(request.GetCursorIndex() - 1);
- return sub_command_object->HandleCompletion(request);
- }
+ return;
}
+
+ StringList new_matches;
+ CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
+ if (sub_command_object == nullptr) {
+ request.AddCompletions(new_matches);
+ return;
+ }
+
+ // Remove the one match that we got from calling GetSubcommandObject.
+ new_matches.DeleteStringAtIndex(0);
+ request.AddCompletions(new_matches);
+ request.ShiftArguments();
+ sub_command_object->HandleCompletion(request);
}
const char *CommandObjectMultiword::GetRepeatCommand(Args &current_command_args,
@@ -231,7 +225,7 @@ const char *CommandObjectMultiword::GetRepeatCommand(Args &current_command_args,
if (current_command_args.GetArgumentCount() <= index)
return nullptr;
CommandObject *sub_command_object =
- GetSubcommandObject(current_command_args[index].ref);
+ GetSubcommandObject(current_command_args[index].ref());
if (sub_command_object == nullptr)
return nullptr;
return sub_command_object->GetRepeatCommand(current_command_args, index);
@@ -360,19 +354,17 @@ Options *CommandObjectProxy::GetOptions() {
return nullptr;
}
-int CommandObjectProxy::HandleCompletion(CompletionRequest &request) {
+void CommandObjectProxy::HandleCompletion(CompletionRequest &request) {
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
- return proxy_command->HandleCompletion(request);
- return 0;
+ proxy_command->HandleCompletion(request);
}
-int CommandObjectProxy::HandleArgumentCompletion(
+void CommandObjectProxy::HandleArgumentCompletion(
CompletionRequest &request, OptionElementVector &opt_element_vector) {
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
- return proxy_command->HandleArgumentCompletion(request, opt_element_vector);
- return 0;
+ proxy_command->HandleArgumentCompletion(request, opt_element_vector);
}
const char *CommandObjectProxy::GetRepeatCommand(Args &current_command_args,