summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2018-07-02 21:29:56 +0000
committerRaphael Isemann <teemperor@gmail.com>2018-07-02 21:29:56 +0000
commit2443bbd4aacd73b61cffe8e7a80a8a320b14dcde (patch)
tree4fed6531b2876ff9836cd6baa9345b61dc32f1cb /lldb/source/Commands
parent402b49084326f10d190f64fc46c04fdfec146f93 (diff)
downloadbcm5719-llvm-2443bbd4aacd73b61cffe8e7a80a8a320b14dcde.tar.gz
bcm5719-llvm-2443bbd4aacd73b61cffe8e7a80a8a320b14dcde.zip
Refactoring for for the internal command line completion API (NFC)
Summary: This patch refactors the internal completion API. It now takes (as far as possible) a single CompletionRequest object instead o half a dozen in/out/in-out parameters. The CompletionRequest contains a common superset of the different parameters as far as it makes sense. This includes the raw command line string and raw cursor position, which should make the `expr` command possible to implement (at least without hacks that reconstruct the command line from the args). This patch is not intended to change the observable behavior of lldb in any way. It's also as minimal as possible and doesn't attempt to fix all the problems the API has. Some Q&A: Q: Why is this not fixing all the problems in the completion API? A: Because is a blocker for the expr command completion which I want to get in ASAP. This is the smallest patch that unblocks the expr completion patch and which allows trivial refactoring in the future. The patch also doesn't really change the internal information flow in the API, so that hopefully saves us from ever having to revert and resubmit this humongous patch. Q: Can we merge all the copy-pasted code in the completion methods (like computing the current incomplete arg) into CompletionRequest class? A: Yes, but it's out of scope for this patch. Q: Why the `word_complete = request.GetWordComplete(); ... ` pattern? A: I don't want to add a getter that returns a reference to the internal integer. So we have to use a temporary variable and the Getter/Setter instead. We don't throw exceptions from what I can tell, so the behavior doesn't change. Q: Why are we not owning the list of matches? A: Because that's how the previous API works. But that should be fixed too (in another patch). Q: Can we make the constructor simpler and compute some of the values from the plain command? A: I think this works, but I rather want to have this in a follow up commit. Especially when making nested request it's a bit awkward that the parsed arguments behave as both input/output (as we should in theory propagate the changes on the nested request back to the parent request if we don't want to change the behavior too much). Q: Can't we pass one const request object and then just return another result object instead of mixing them together in one in/out parameter? A: It's hard to get keep the same behavior with that pattern, but I think we can also get a nice API with just a single request object. If we make all input parameters read-only, we have a clear separation between what is actually an input and what an output parameter (and hopefully we get rid of the in-out parameters). Q: Can we throw out the 'match' variables that are not implemented according to the comment? A: We currently just forward them as in the old code to the different methods, even though I think they are really not used. We can easily remove and readd them once every single completion method just takes a CompletionRequest, but for now I prefer NFC behavior from the perspective of the API user. Reviewers: davide, jingham, labath Reviewed By: jingham Subscribers: mgorny, friss, lldb-commits Differential Revision: https://reviews.llvm.org/D48796 llvm-svn: 336146
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp45
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp22
-rw-r--r--lldb/source/Commands/CommandObjectHelp.cpp28
-rw-r--r--lldb/source/Commands/CommandObjectHelp.h5
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp59
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp19
-rw-r--r--lldb/source/Commands/CommandObjectPlugin.cpp22
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp25
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp239
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp117
10 files changed, 285 insertions, 296 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 454efd12661..584e081c6e8 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -235,20 +235,20 @@ public:
return "";
}
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- auto completion_str = input[cursor_index].ref;
- completion_str = completion_str.take_front(cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ auto completion_str = request.GetParsedLine()[request.GetCursorIndex()].ref;
+ completion_str = completion_str.take_front(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str, match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str, request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
Options *GetOptions() override { return &m_options; }
@@ -1459,20 +1459,21 @@ public:
~CommandObjectCommandsScriptImport() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- llvm::StringRef completion_str = input[cursor_index].ref;
- completion_str = completion_str.take_front(cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ llvm::StringRef completion_str =
+ request.GetParsedLine()[request.GetCursorIndex()].ref;
+ completion_str = completion_str.take_front(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str, match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str, request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
Options *GetOptions() override { return &m_options; }
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index f4bce6e4b7b..68600215585 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -463,21 +463,21 @@ public:
Options *GetOptions() override { return &m_option_group; }
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
// Arguments are the standard source file completer.
- auto completion_str = input[cursor_index].ref;
- completion_str = completion_str.take_front(cursor_char_position);
+ auto completion_str = request.GetParsedLine()[request.GetCursorIndex()].ref;
+ completion_str = completion_str.take_front(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
- completion_str, match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str, request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
protected:
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index d379c62b619..903c6011b03 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -209,34 +209,24 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) {
return result.Succeeded();
}
-int CommandObjectHelp::HandleCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) {
+int CommandObjectHelp::HandleCompletion(CompletionRequest &request) {
// Return the completions of the commands in the help system:
- if (cursor_index == 0) {
- return m_interpreter.HandleCompletionMatches(
- input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
+ if (request.GetCursorIndex() == 0) {
+ return m_interpreter.HandleCompletionMatches(request);
} else {
- CommandObject *cmd_obj = m_interpreter.GetCommandObject(input[0].ref);
+ CommandObject *cmd_obj =
+ m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref);
// The command that they are getting help on might be ambiguous, in which
// case we should complete that, otherwise complete with the command the
// user is getting help on...
if (cmd_obj) {
- input.Shift();
- cursor_index--;
- return cmd_obj->HandleCompletion(
- input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
+ request.GetParsedLine().Shift();
+ request.SetCursorIndex(request.GetCursorIndex() - 1);
+ return cmd_obj->HandleCompletion(request);
} else {
- return m_interpreter.HandleCompletionMatches(
- input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
+ return m_interpreter.HandleCompletionMatches(request);
}
}
}
diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h
index f1f87f8e63c..c78682dead1 100644
--- a/lldb/source/Commands/CommandObjectHelp.h
+++ b/lldb/source/Commands/CommandObjectHelp.h
@@ -30,10 +30,7 @@ public:
~CommandObjectHelp() override;
- int HandleCompletion(Args &input, int &cursor_index,
- int &cursor_char_position, int match_start_point,
- int max_return_elements, bool &word_complete,
- StringList &matches) override;
+ int HandleCompletion(CompletionRequest &request) override;
static void GenerateAdditionalHelpAvenuesMessage(
Stream *s, llvm::StringRef command, llvm::StringRef prefix,
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 44a1320065b..ade1a2d01f3 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -186,18 +186,14 @@ void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
"'help <command> <subcommand>'.\n");
}
-int CommandObjectMultiword::HandleCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) {
+int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
// Any of the command matches will provide a complete word, otherwise the
// individual completers will override this.
- word_complete = true;
+ request.SetWordComplete(true);
+ auto &matches = request.GetMatches();
- auto arg0 = input[0].ref;
- if (cursor_index == 0) {
+ auto arg0 = request.GetParsedLine()[0].ref;
+ if (request.GetCursorIndex() == 0) {
AddNamesMatchingPartialString(m_subcommand_dict, arg0, matches);
if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != nullptr &&
@@ -205,16 +201,14 @@ int CommandObjectMultiword::HandleCompletion(Args &input, int &cursor_index,
StringList temp_matches;
CommandObject *cmd_obj = GetSubcommandObject(arg0, &temp_matches);
if (cmd_obj != nullptr) {
- if (input.GetArgumentCount() == 1) {
- word_complete = true;
+ if (request.GetParsedLine().GetArgumentCount() == 1) {
+ request.SetWordComplete(true);
} else {
matches.DeleteStringAtIndex(0);
- input.Shift();
- cursor_char_position = 0;
- input.AppendArgument(llvm::StringRef());
- return cmd_obj->HandleCompletion(
- input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
+ request.GetParsedLine().Shift();
+ request.SetCursorCharPosition(0);
+ request.GetParsedLine().AppendArgument(llvm::StringRef());
+ return cmd_obj->HandleCompletion(request);
}
}
}
@@ -226,11 +220,9 @@ int CommandObjectMultiword::HandleCompletion(Args &input, int &cursor_index,
} else {
// Remove the one match that we got from calling GetSubcommandObject.
matches.DeleteStringAtIndex(0);
- input.Shift();
- cursor_index--;
- return sub_command_object->HandleCompletion(
- input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
+ request.GetParsedLine().Shift();
+ request.SetCursorIndex(request.GetCursorIndex() - 1);
+ return sub_command_object->HandleCompletion(request);
}
}
}
@@ -370,31 +362,20 @@ Options *CommandObjectProxy::GetOptions() {
return nullptr;
}
-int CommandObjectProxy::HandleCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches) {
+int CommandObjectProxy::HandleCompletion(CompletionRequest &request) {
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
- return proxy_command->HandleCompletion(
- input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
- matches.Clear();
+ return proxy_command->HandleCompletion(request);
+ request.GetMatches().Clear();
return 0;
}
int CommandObjectProxy::HandleArgumentCompletion(
- Args &input, int &cursor_index, int &cursor_char_position,
- OptionElementVector &opt_element_vector, int match_start_point,
- int max_return_elements, bool &word_complete, StringList &matches) {
+ CompletionRequest &request, OptionElementVector &opt_element_vector) {
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
- return proxy_command->HandleArgumentCompletion(
- input, cursor_index, cursor_char_position, opt_element_vector,
- match_start_point, max_return_elements, word_complete, matches);
- matches.Clear();
+ return proxy_command->HandleArgumentCompletion(request, opt_element_vector);
+ request.GetMatches().Clear();
return 0;
}
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 3c44e8f252f..118f78e359e 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -178,17 +178,18 @@ public:
~CommandObjectPlatformSelect() override = default;
- int HandleCompletion(Args &input, int &cursor_index,
- int &cursor_char_position, int match_start_point,
- int max_return_elements, bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
+ int HandleCompletion(CompletionRequest &request) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()));
+ completion_str.erase(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::PlatformPluginNames(
- GetCommandInterpreter(), completion_str.c_str(), match_start_point,
- max_return_elements, nullptr, word_complete, matches);
- return matches.GetSize();
+ GetCommandInterpreter(), completion_str.c_str(),
+ request.GetMatchStartPoint(), request.GetMaxReturnElements(), nullptr,
+ word_complete, request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
Options *GetOptions() override { return &m_option_group; }
diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp
index 7e1b7f61f76..36db0d12005 100644
--- a/lldb/source/Commands/CommandObjectPlugin.cpp
+++ b/lldb/source/Commands/CommandObjectPlugin.cpp
@@ -42,20 +42,20 @@ public:
~CommandObjectPluginLoad() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- auto completion_str = input[cursor_index].ref;
- completion_str = completion_str.take_front(cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ auto completion_str = request.GetParsedLine()[request.GetCursorIndex()].ref;
+ completion_str = completion_str.take_front(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str, match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str, request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
protected:
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 9deb2e64940..86d477754ea 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -134,20 +134,21 @@ public:
~CommandObjectProcessLaunch() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
-
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()));
+ completion_str.erase(request.GetCursorCharPosition());
+
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
Options *GetOptions() override { return &m_options; }
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index b1b0ae8bfeb..58dbaee967d 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -133,32 +133,34 @@ insert-before or insert-after.");
bool m_global;
};
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
-
- const size_t argc = input.GetArgumentCount();
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+
+ const size_t argc = request.GetParsedLine().GetArgumentCount();
const char *arg = nullptr;
int setting_var_idx;
for (setting_var_idx = 0; setting_var_idx < static_cast<int>(argc);
++setting_var_idx) {
- arg = input.GetArgumentAtIndex(setting_var_idx);
+ arg = request.GetParsedLine().GetArgumentAtIndex(setting_var_idx);
if (arg && arg[0] != '-')
break; // We found our setting variable name index
}
- if (cursor_index == setting_var_idx) {
+ if (request.GetCursorIndex() == setting_var_idx) {
// Attempting to complete setting variable name
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements,
- nullptr, word_complete, matches);
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
} else {
- arg = input.GetArgumentAtIndex(cursor_index);
+ arg =
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex());
if (arg) {
if (arg[0] == '-') {
@@ -166,20 +168,23 @@ insert-before or insert-after.");
} else {
// Complete setting value
const char *setting_var_name =
- input.GetArgumentAtIndex(setting_var_idx);
+ request.GetParsedLine().GetArgumentAtIndex(setting_var_idx);
Status error;
lldb::OptionValueSP value_sp(
m_interpreter.GetDebugger().GetPropertyValue(
&m_exe_ctx, setting_var_name, false, error));
if (value_sp) {
+ bool word_complete = request.GetWordComplete();
value_sp->AutoComplete(m_interpreter, completion_str.c_str(),
- match_start_point, max_return_elements,
- word_complete, matches);
+ request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(),
+ word_complete, request.GetMatches());
+ request.SetWordComplete(word_complete);
}
}
}
}
- return matches.GetSize();
+ return request.GetMatches().GetSize();
}
protected:
@@ -272,20 +277,21 @@ public:
~CommandObjectSettingsShow() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
protected:
@@ -345,20 +351,21 @@ public:
~CommandObjectSettingsList() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
protected:
@@ -440,22 +447,23 @@ public:
~CommandObjectSettingsRemove() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
// Attempting to complete variable name
- if (cursor_index < 2)
+ bool word_complete = request.GetWordComplete();
+ if (request.GetCursorIndex() < 2)
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements,
- nullptr, word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
protected:
@@ -562,23 +570,24 @@ public:
// !WantsRawCommandString.
bool WantsCompletion() override { return true; }
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
// Attempting to complete variable name
- if (cursor_index < 2)
+ if (request.GetCursorIndex() < 2)
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements,
- nullptr, word_complete, matches);
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
- return matches.GetSize();
+ return request.GetMatches().GetSize();
}
protected:
@@ -668,23 +677,24 @@ public:
// !WantsRawCommandString.
bool WantsCompletion() override { return true; }
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
// Attempting to complete variable name
- if (cursor_index < 2)
+ if (request.GetCursorIndex() < 2)
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements,
- nullptr, word_complete, matches);
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
- return matches.GetSize();
+ return request.GetMatches().GetSize();
}
protected:
@@ -779,23 +789,24 @@ public:
// !WantsRawCommandString.
bool WantsCompletion() override { return true; }
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
// Attempting to complete variable name
- if (cursor_index < 2)
+ if (request.GetCursorIndex() < 2)
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements,
- nullptr, word_complete, matches);
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
- return matches.GetSize();
+ return request.GetMatches().GetSize();
}
protected:
@@ -879,23 +890,24 @@ public:
// !WantsRawCommandString.
bool WantsCompletion() override { return true; }
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
// Attempting to complete variable name
- if (cursor_index < 2)
+ if (request.GetCursorIndex() < 2)
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements,
- nullptr, word_complete, matches);
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
- return matches.GetSize();
+ return request.GetMatches().GetSize();
}
protected:
@@ -966,23 +978,24 @@ public:
~CommandObjectSettingsClear() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index),
- cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
+ request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
// Attempting to complete variable name
- if (cursor_index < 2)
+ if (request.GetCursorIndex() < 2)
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(), match_start_point, max_return_elements,
- nullptr, word_complete, matches);
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
- return matches.GetSize();
+ return request.GetMatches().GetSize();
}
protected:
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index feeecf5517c..fc25fb37d4d 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -195,20 +195,21 @@ public:
Options *GetOptions() override { return &m_option_group; }
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
-
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()));
+ completion_str.erase(request.GetCursorCharPosition());
+
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
protected:
@@ -1811,21 +1812,22 @@ public:
~CommandObjectTargetModulesModuleAutoComplete() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
// Arguments are the standard module completer.
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()));
+ completion_str.erase(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eModuleCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
};
@@ -1860,21 +1862,22 @@ public:
~CommandObjectTargetModulesSourceFileAutoComplete() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
// Arguments are the standard source file completer.
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()));
+ completion_str.erase(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSourceFileCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
};
@@ -2410,20 +2413,21 @@ public:
Options *GetOptions() override { return &m_option_group; }
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()));
+ completion_str.erase(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
protected:
@@ -4011,20 +4015,21 @@ public:
~CommandObjectTargetSymbolsAdd() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ std::string completion_str(
+ request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()));
+ completion_str.erase(request.GetCursorCharPosition());
+ bool word_complete = request.GetWordComplete();
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ completion_str.c_str(), request.GetMatchStartPoint(),
+ request.GetMaxReturnElements(), nullptr, word_complete,
+ request.GetMatches());
+ request.SetWordComplete(word_complete);
+ return request.GetMatches().GetSize();
}
Options *GetOptions() override { return &m_option_group; }
OpenPOWER on IntegriCloud