summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectPlatform.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2018-07-13 18:28:14 +0000
committerRaphael Isemann <teemperor@gmail.com>2018-07-13 18:28:14 +0000
commita2e76c0bfc5bec8d50e8d13f71b72a66eaa0a386 (patch)
tree55563c896d181a4de6dc254f335c10a379e0eac0 /lldb/source/Commands/CommandObjectPlatform.cpp
parentd6c062bce1e499f52500cc759a7c0846dd178cda (diff)
downloadbcm5719-llvm-a2e76c0bfc5bec8d50e8d13f71b72a66eaa0a386.tar.gz
bcm5719-llvm-a2e76c0bfc5bec8d50e8d13f71b72a66eaa0a386.zip
Replaced more boilerplate code with CompletionRequest (NFC)
Summary: As suggested in D48796, this patch replaces even more internal calls that were using the old completion API style with a single CompletionRequest. In some cases we also pass an option vector/index, but as we don't always have this information, it currently is not part of the CompletionRequest class. The constructor of the CompletionRequest is now also more sensible. You only pass the user input, cursor position and your list of matches to the request and the rest will be inferred (using the same code we used before to calculate this). You also have to pass these match window parameters to it, even though they are unused right now. The patch shouldn't change any behavior. Reviewers: jingham Reviewed By: jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48976 llvm-svn: 337031
Diffstat (limited to 'lldb/source/Commands/CommandObjectPlatform.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 3a27f34fec7..f822a8b54cb 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -179,16 +179,8 @@ public:
~CommandObjectPlatformSelect() override = default;
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(),
- request.GetMatchStartPoint(), request.GetMaxReturnElements(), nullptr,
- word_complete, request.GetMatches());
- request.SetWordComplete(word_complete);
+ CommandCompletions::PlatformPluginNames(GetCommandInterpreter(), request,
+ nullptr);
return request.GetMatches().GetSize();
}
@@ -1562,11 +1554,8 @@ public:
}
bool HandleOptionArgumentCompletion(
- Args &input, int cursor_index, int char_pos,
- OptionElementVector &opt_element_vector, int opt_element_index,
- int match_start_point, int max_return_elements,
- CommandInterpreter &interpreter, bool &word_complete,
- StringList &matches) override {
+ CompletionRequest &request, OptionElementVector &opt_element_vector,
+ int opt_element_index, CommandInterpreter &interpreter) override {
int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
@@ -1579,7 +1568,7 @@ public:
// plugin, otherwise use the default plugin.
const char *partial_name = nullptr;
- partial_name = input.GetArgumentAtIndex(opt_arg_pos);
+ partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
PlatformSP platform_sp(interpreter.GetPlatform(true));
if (platform_sp) {
@@ -1594,7 +1583,7 @@ public:
const uint32_t num_matches = process_infos.GetSize();
if (num_matches > 0) {
for (uint32_t i = 0; i < num_matches; ++i) {
- matches.AppendString(
+ request.GetMatches().AppendString(
process_infos.GetProcessNameAtIndex(i),
process_infos.GetProcessNameLengthAtIndex(i));
}
OpenPOWER on IntegriCloud