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
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index d6d271a..df27eb2 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1697,14 +1697,10 @@
     // We didn't find the first command object, so complete the first argument.
     Args command_args(command_string);
     StringList matches;
-    int cursor_index = 0;
-    int cursor_char_position = strlen(command_args.GetArgumentAtIndex(0));
-    bool word_complete = true;
-    CompletionRequest request(command_line, cursor_char_position, command_args,
-                              cursor_index, cursor_char_position, 0, -1,
-                              word_complete, matches);
+    unsigned cursor_char_position = strlen(command_args.GetArgumentAtIndex(0));
+    CompletionRequest request(command_line, cursor_char_position, 0, -1,
+                              matches);
     int num_matches = HandleCompletionMatches(request);
-    word_complete = request.GetWordComplete();
 
     if (num_matches > 0) {
       std::string error_msg;
@@ -1791,89 +1787,42 @@
 int CommandInterpreter::HandleCompletion(
     const char *current_line, const char *cursor, const char *last_char,
     int match_start_point, int max_return_elements, StringList &matches) {
-  // We parse the argument up to the cursor, so the last argument in
-  // parsed_line is the one containing the cursor, and the cursor is after the
-  // last character.
 
   llvm::StringRef command_line(current_line, last_char - current_line);
-  Args parsed_line(command_line);
-  Args partial_parsed_line(
-      llvm::StringRef(current_line, cursor - current_line));
+  CompletionRequest request(command_line, cursor - current_line,
+                            match_start_point, max_return_elements, matches);
 
   // Don't complete comments, and if the line we are completing is just the
   // history repeat character, substitute the appropriate history line.
-  const char *first_arg = parsed_line.GetArgumentAtIndex(0);
+  const char *first_arg = request.GetParsedLine().GetArgumentAtIndex(0);
   if (first_arg) {
     if (first_arg[0] == m_comment_char)
       return 0;
     else if (first_arg[0] == CommandHistory::g_repeat_char) {
       if (auto hist_str = m_command_history.FindString(first_arg)) {
-        matches.Clear();
-        matches.InsertStringAtIndex(0, *hist_str);
+        request.GetMatches().Clear();
+        request.GetMatches().InsertStringAtIndex(0, *hist_str);
         return -2;
       } else
         return 0;
     }
   }
 
-  int num_args = partial_parsed_line.GetArgumentCount();
-  int cursor_index = partial_parsed_line.GetArgumentCount() - 1;
-  int cursor_char_position;
-
-  if (cursor_index == -1)
-    cursor_char_position = 0;
-  else
-    cursor_char_position =
-        strlen(partial_parsed_line.GetArgumentAtIndex(cursor_index));
-
-  if (cursor > current_line && cursor[-1] == ' ') {
-    // We are just after a space.  If we are in an argument, then we will
-    // continue parsing, but if we are between arguments, then we have to
-    // complete whatever the next element would be. We can distinguish the two
-    // cases because if we are in an argument (e.g. because the space is
-    // protected by a quote) then the space will also be in the parsed
-    // argument...
-
-    const char *current_elem =
-        partial_parsed_line.GetArgumentAtIndex(cursor_index);
-    if (cursor_char_position == 0 ||
-        current_elem[cursor_char_position - 1] != ' ') {
-      parsed_line.InsertArgumentAtIndex(cursor_index + 1, llvm::StringRef(),
-                                        '\0');
-      cursor_index++;
-      cursor_char_position = 0;
-    }
-  }
-
-  int num_command_matches;
-
-  matches.Clear();
-
   // Only max_return_elements == -1 is supported at present:
   lldbassert(max_return_elements == -1);
-  bool word_complete = false;
 
-  CompletionRequest request(command_line, cursor - current_line, parsed_line,
-                            cursor_index, cursor_char_position,
-                            match_start_point, max_return_elements,
-                            word_complete, matches);
-
-  num_command_matches = HandleCompletionMatches(request);
-  word_complete = request.GetWordComplete();
+  int num_command_matches = HandleCompletionMatches(request);
 
   if (num_command_matches <= 0)
     return num_command_matches;
 
-  if (num_args == 0) {
+  if (request.GetParsedLine().GetArgumentCount() == 0) {
     // If we got an empty string, insert nothing.
     matches.InsertStringAtIndex(0, "");
   } else {
     // Now figure out if there is a common substring, and if so put that in
     // element 0, otherwise put an empty string in element 0.
-    std::string command_partial_str;
-    if (cursor_index >= 0)
-      command_partial_str =
-          parsed_line[cursor_index].ref.take_front(cursor_char_position);
+    std::string command_partial_str = request.GetCursorArgumentPrefix().str();
 
     std::string common_prefix;
     matches.LongestCommonPrefix(common_prefix);
@@ -1882,15 +1831,15 @@
 
     // If we matched a unique single command, add a space... Only do this if
     // the completer told us this was a complete word, however...
-    if (num_command_matches == 1 && word_complete) {
-      char quote_char = parsed_line[cursor_index].quote;
+    if (num_command_matches == 1 && request.GetWordComplete()) {
+      char quote_char = request.GetParsedLine()[request.GetCursorIndex()].quote;
       common_prefix =
           Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
       if (quote_char != '\0')
         common_prefix.push_back(quote_char);
       common_prefix.push_back(' ');
     }
-    matches.InsertStringAtIndex(0, common_prefix.c_str());
+    request.GetMatches().InsertStringAtIndex(0, common_prefix.c_str());
   }
   return num_command_matches;
 }
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index 004cdf0..07be913 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -279,14 +279,8 @@
       opt_element_vector = cur_options->ParseForCompletion(
           request.GetParsedLine(), request.GetCursorIndex());
 
-      bool handled_by_options;
-      bool word_complete = request.GetWordComplete();
-      handled_by_options = cur_options->HandleOptionCompletion(
-          request.GetParsedLine(), opt_element_vector, request.GetCursorIndex(),
-          request.GetCursorCharPosition(), request.GetMatchStartPoint(),
-          request.GetMaxReturnElements(), GetCommandInterpreter(),
-          word_complete, request.GetMatches());
-      request.SetWordComplete(word_complete);
+      bool handled_by_options = cur_options->HandleOptionCompletion(
+          request, opt_element_vector, GetCommandInterpreter());
       if (handled_by_options)
         return request.GetMatches().GetSize();
     }
@@ -1015,7 +1009,8 @@
   static StreamString g_archs_help;
   if (g_archs_help.Empty()) {
     StringList archs;
-    ArchSpec::AutoComplete(llvm::StringRef(), archs);
+
+    ArchSpec::ListSupportedArchNames(archs);
     g_archs_help.Printf("These are the supported architecture names:\n");
     archs.Join("\n", g_archs_help);
   }
diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
index a5362c3..f975c0e 100644
--- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
+++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
@@ -95,15 +95,8 @@
 
 int CommandObjectRegexCommand::HandleCompletion(CompletionRequest &request) {
   if (m_completion_type_mask) {
-    std::string completion_str(
-        request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()),
-        request.GetCursorCharPosition());
-    bool word_complete = request.GetWordComplete();
     CommandCompletions::InvokeCommonCompletionCallbacks(
-        GetCommandInterpreter(), m_completion_type_mask, completion_str.c_str(),
-        request.GetMatchStartPoint(), request.GetMaxReturnElements(), nullptr,
-        word_complete, request.GetMatches());
-    request.SetWordComplete(word_complete);
+        GetCommandInterpreter(), m_completion_type_mask, request, nullptr);
     return request.GetMatches().GetSize();
   } else {
     request.GetMatches().Clear();
diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp
index c02ffeb..2d7c69e 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -573,12 +573,10 @@
 }
 
 size_t OptionValue::AutoComplete(CommandInterpreter &interpreter,
-                                 llvm::StringRef s, int match_start_point,
-                                 int max_return_elements, bool &word_complete,
-                                 StringList &matches) {
-  word_complete = false;
-  matches.Clear();
-  return matches.GetSize();
+                                 CompletionRequest &request) {
+  request.SetWordComplete(false);
+  request.GetMatches().Clear();
+  return request.GetMatches().GetSize();
 }
 
 Status OptionValue::SetValueFromString(llvm::StringRef value,
diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp
index 12b8e603..3d08780 100644
--- a/lldb/source/Interpreter/OptionValueArch.cpp
+++ b/lldb/source/Interpreter/OptionValueArch.cpp
@@ -74,13 +74,11 @@
 }
 
 size_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
-                                     llvm::StringRef s, int match_start_point,
-                                     int max_return_elements,
-                                     bool &word_complete, StringList &matches) {
-  word_complete = false;
-  matches.Clear();
+                                     CompletionRequest &request) {
+  request.SetWordComplete(false);
+  request.GetMatches().Clear();
   CommandCompletions::InvokeCommonCompletionCallbacks(
-      interpreter, CommandCompletions::eArchitectureCompletion, s,
-      match_start_point, max_return_elements, nullptr, word_complete, matches);
-  return matches.GetSize();
+      interpreter, CommandCompletions::eArchitectureCompletion, request,
+      nullptr);
+  return request.GetMatches().GetSize();
 }
diff --git a/lldb/source/Interpreter/OptionValueBoolean.cpp b/lldb/source/Interpreter/OptionValueBoolean.cpp
index 43c8233..8a34079 100644
--- a/lldb/source/Interpreter/OptionValueBoolean.cpp
+++ b/lldb/source/Interpreter/OptionValueBoolean.cpp
@@ -76,23 +76,22 @@
   return OptionValueSP(new OptionValueBoolean(*this));
 }
 
-size_t OptionValueBoolean::AutoComplete(
-    CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point,
-    int max_return_elements, bool &word_complete, StringList &matches) {
-  word_complete = false;
-  matches.Clear();
+size_t OptionValueBoolean::AutoComplete(CommandInterpreter &interpreter,
+                                        CompletionRequest &request) {
+  request.SetWordComplete(false);
+  request.GetMatches().Clear();
   static const llvm::StringRef g_autocomplete_entries[] = {
       "true", "false", "on", "off", "yes", "no", "1", "0"};
 
   auto entries = llvm::makeArrayRef(g_autocomplete_entries);
 
   // only suggest "true" or "false" by default
-  if (s.empty())
+  if (request.GetCursorArgumentPrefix().empty())
     entries = entries.take_front(2);
 
   for (auto entry : entries) {
-    if (entry.startswith_lower(s))
-      matches.AppendString(entry);
+    if (entry.startswith_lower(request.GetCursorArgumentPrefix()))
+      request.GetMatches().AppendString(entry);
   }
-  return matches.GetSize();
+  return request.GetMatches().GetSize();
 }
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index 9510f4a..e78618e 100644
--- a/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -109,23 +109,23 @@
   return OptionValueSP(new OptionValueEnumeration(*this));
 }
 
-size_t OptionValueEnumeration::AutoComplete(
-    CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point,
-    int max_return_elements, bool &word_complete, StringList &matches) {
-  word_complete = false;
-  matches.Clear();
+size_t OptionValueEnumeration::AutoComplete(CommandInterpreter &interpreter,
+                                            CompletionRequest &request) {
+  request.SetWordComplete(false);
+  request.GetMatches().Clear();
 
   const uint32_t num_enumerators = m_enumerations.GetSize();
-  if (!s.empty()) {
+  if (!request.GetCursorArgumentPrefix().empty()) {
     for (size_t i = 0; i < num_enumerators; ++i) {
       llvm::StringRef name = m_enumerations.GetCStringAtIndex(i).GetStringRef();
-      if (name.startswith(s))
-        matches.AppendString(name);
+      if (name.startswith(request.GetCursorArgumentPrefix()))
+        request.GetMatches().AppendString(name);
     }
   } else {
     // only suggest "true" or "false" by default
     for (size_t i = 0; i < num_enumerators; ++i)
-      matches.AppendString(m_enumerations.GetCStringAtIndex(i).GetStringRef());
+      request.GetMatches().AppendString(
+          m_enumerations.GetCStringAtIndex(i).GetStringRef());
   }
-  return matches.GetSize();
+  return request.GetMatches().GetSize();
 }
diff --git a/lldb/source/Interpreter/OptionValueFileSpec.cpp b/lldb/source/Interpreter/OptionValueFileSpec.cpp
index d3abf3f..18bfcd6 100644
--- a/lldb/source/Interpreter/OptionValueFileSpec.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpec.cpp
@@ -99,15 +99,13 @@
   return OptionValueSP(new OptionValueFileSpec(*this));
 }
 
-size_t OptionValueFileSpec::AutoComplete(
-    CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point,
-    int max_return_elements, bool &word_complete, StringList &matches) {
-  word_complete = false;
-  matches.Clear();
+size_t OptionValueFileSpec::AutoComplete(CommandInterpreter &interpreter,
+                                         CompletionRequest &request) {
+  request.SetWordComplete(false);
+  request.GetMatches().Clear();
   CommandCompletions::InvokeCommonCompletionCallbacks(
-      interpreter, m_completion_mask, s, match_start_point, max_return_elements,
-      nullptr, word_complete, matches);
-  return matches.GetSize();
+      interpreter, m_completion_mask, request, nullptr);
+  return request.GetMatches().GetSize();
 }
 
 const lldb::DataBufferSP &OptionValueFileSpec::GetFileContents() {
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index dc9afea..ce1a84e 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -105,9 +105,7 @@
   return OptionValueSP(new OptionValueFormatEntity(*this));
 }
 
-size_t OptionValueFormatEntity::AutoComplete(
-    CommandInterpreter &interpreter, llvm::StringRef s, int match_start_point,
-    int max_return_elements, bool &word_complete, StringList &matches) {
-  return FormatEntity::AutoComplete(s, match_start_point, max_return_elements,
-                                    word_complete, matches);
+size_t OptionValueFormatEntity::AutoComplete(CommandInterpreter &interpreter,
+                                             CompletionRequest &request) {
+  return FormatEntity::AutoComplete(request);
 }
diff --git a/lldb/source/Interpreter/OptionValueUUID.cpp b/lldb/source/Interpreter/OptionValueUUID.cpp
index b940584..7fa1552 100644
--- a/lldb/source/Interpreter/OptionValueUUID.cpp
+++ b/lldb/source/Interpreter/OptionValueUUID.cpp
@@ -68,16 +68,15 @@
 }
 
 size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
-                                     llvm::StringRef s, int match_start_point,
-                                     int max_return_elements,
-                                     bool &word_complete, StringList &matches) {
-  word_complete = false;
-  matches.Clear();
+                                     CompletionRequest &request) {
+  request.SetWordComplete(false);
+  request.GetMatches().Clear();
   ExecutionContext exe_ctx(interpreter.GetExecutionContext());
   Target *target = exe_ctx.GetTargetPtr();
   if (target) {
+    auto prefix = request.GetCursorArgumentPrefix();
     llvm::SmallVector<uint8_t, 20> uuid_bytes;
-    if (UUID::DecodeUUIDBytesFromString(s, uuid_bytes).empty()) {
+    if (UUID::DecodeUUIDBytesFromString(prefix, uuid_bytes).empty()) {
       const size_t num_modules = target->GetImages().GetSize();
       for (size_t i = 0; i < num_modules; ++i) {
         ModuleSP module_sp(target->GetImages().GetModuleAtIndex(i));
@@ -87,12 +86,12 @@
             llvm::ArrayRef<uint8_t> module_bytes = module_uuid.GetBytes();
             if (module_bytes.size() >= uuid_bytes.size() &&
                 module_bytes.take_front(uuid_bytes.size()).equals(uuid_bytes)) {
-              matches.AppendString(module_uuid.GetAsString());
+              request.GetMatches().AppendString(module_uuid.GetAsString());
             }
           }
         }
       }
     }
   }
-  return matches.GetSize();
+  return request.GetMatches().GetSize();
 }
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 1840598..f475897 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -647,12 +647,10 @@
   return options_are_valid;
 }
 
-bool Options::HandleOptionCompletion(
-    Args &input, OptionElementVector &opt_element_vector, int cursor_index,
-    int char_pos, int match_start_point, int max_return_elements,
-    CommandInterpreter &interpreter, bool &word_complete,
-    lldb_private::StringList &matches) {
-  word_complete = true;
+bool Options::HandleOptionCompletion(CompletionRequest &request,
+                                     OptionElementVector &opt_element_vector,
+                                     CommandInterpreter &interpreter) {
+  request.SetWordComplete(true);
 
   // For now we just scan the completions to see if the cursor position is in
   // an option or its argument.  Otherwise we'll call HandleArgumentCompletion.
@@ -661,15 +659,14 @@
 
   auto opt_defs = GetDefinitions();
 
-  std::string cur_opt_std_str(input.GetArgumentAtIndex(cursor_index));
-  cur_opt_std_str.erase(char_pos);
+  std::string cur_opt_std_str = request.GetCursorArgumentPrefix().str();
   const char *cur_opt_str = cur_opt_std_str.c_str();
 
   for (size_t i = 0; i < opt_element_vector.size(); i++) {
     int opt_pos = opt_element_vector[i].opt_pos;
     int opt_arg_pos = opt_element_vector[i].opt_arg_pos;
     int opt_defs_index = opt_element_vector[i].opt_defs_index;
-    if (opt_pos == cursor_index) {
+    if (opt_pos == request.GetCursorIndex()) {
       // We're completing the option itself.
 
       if (opt_defs_index == OptionArgElement::eBareDash) {
@@ -683,7 +680,7 @@
           if (!def.short_option)
             continue;
           opt_str[1] = def.short_option;
-          matches.AppendString(opt_str);
+          request.GetMatches().AppendString(opt_str);
         }
 
         return true;
@@ -695,7 +692,7 @@
 
           full_name.erase(full_name.begin() + 2, full_name.end());
           full_name.append(def.long_option);
-          matches.AppendString(full_name.c_str());
+          request.GetMatches().AppendString(full_name.c_str());
         }
         return true;
       } else if (opt_defs_index != OptionArgElement::eUnrecognizedArg) {
@@ -708,10 +705,10 @@
             strcmp(opt_defs[opt_defs_index].long_option, cur_opt_str) != 0) {
           std::string full_name("--");
           full_name.append(opt_defs[opt_defs_index].long_option);
-          matches.AppendString(full_name.c_str());
+          request.GetMatches().AppendString(full_name.c_str());
           return true;
         } else {
-          matches.AppendString(input.GetArgumentAtIndex(cursor_index));
+          request.GetMatches().AppendString(request.GetCursorArgument());
           return true;
         }
       } else {
@@ -734,29 +731,30 @@
               // The options definitions table has duplicates because of the
               // way the grouping information is stored, so only add once.
               bool duplicate = false;
-              for (size_t k = 0; k < matches.GetSize(); k++) {
-                if (matches.GetStringAtIndex(k) == full_name) {
+              for (size_t k = 0; k < request.GetMatches().GetSize(); k++) {
+                if (request.GetMatches().GetStringAtIndex(k) == full_name) {
                   duplicate = true;
                   break;
                 }
               }
               if (!duplicate)
-                matches.AppendString(full_name.c_str());
+                request.GetMatches().AppendString(full_name.c_str());
             }
           }
         }
         return true;
       }
 
-    } else if (opt_arg_pos == cursor_index) {
+    } else if (opt_arg_pos == request.GetCursorIndex()) {
       // Okay the cursor is on the completion of an argument. See if it has a
       // completion, otherwise return no matches.
 
+      CompletionRequest subrequest = request;
+      subrequest.SetCursorCharPosition(subrequest.GetCursorArgument().size());
       if (opt_defs_index != -1) {
-        HandleOptionArgumentCompletion(
-            input, cursor_index, strlen(input.GetArgumentAtIndex(cursor_index)),
-            opt_element_vector, i, match_start_point, max_return_elements,
-            interpreter, word_complete, matches);
+        HandleOptionArgumentCompletion(subrequest, opt_element_vector, i,
+                                       interpreter);
+        request.SetWordComplete(subrequest.GetWordComplete());
         return true;
       } else {
         // No completion callback means no completions...
@@ -772,11 +770,8 @@
 }
 
 bool Options::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,
-    lldb_private::StringList &matches) {
+    CompletionRequest &request, OptionElementVector &opt_element_vector,
+    int opt_element_index, CommandInterpreter &interpreter) {
   auto opt_defs = GetDefinitions();
   std::unique_ptr<SearchFilter> filter_ap;
 
@@ -788,12 +783,14 @@
   OptionEnumValueElement *enum_values = opt_defs[opt_defs_index].enum_values;
   if (enum_values != nullptr) {
     bool return_value = false;
-    std::string match_string(input.GetArgumentAtIndex(opt_arg_pos),
-                             input.GetArgumentAtIndex(opt_arg_pos) + char_pos);
+    std::string match_string(
+        request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos),
+        request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos) +
+            request.GetCursorCharPosition());
     for (int i = 0; enum_values[i].string_value != nullptr; i++) {
       if (strstr(enum_values[i].string_value, match_string.c_str()) ==
           enum_values[i].string_value) {
-        matches.AppendString(enum_values[i].string_value);
+        request.GetMatches().AppendString(enum_values[i].string_value);
         return_value = true;
       }
     }
@@ -838,7 +835,8 @@
       // restrict it to that shared library.
       if (cur_opt_name && strcmp(cur_opt_name, "shlib") == 0 &&
           cur_arg_pos != -1) {
-        const char *module_name = input.GetArgumentAtIndex(cur_arg_pos);
+        const char *module_name =
+            request.GetParsedLine().GetArgumentAtIndex(cur_arg_pos);
         if (module_name) {
           FileSpec module_spec(module_name, false);
           lldb::TargetSP target_sp =
@@ -853,9 +851,7 @@
   }
 
   return CommandCompletions::InvokeCommonCompletionCallbacks(
-      interpreter, completion_mask, input.GetArgumentAtIndex(opt_arg_pos),
-      match_start_point, max_return_elements, filter_ap.get(), word_complete,
-      matches);
+      interpreter, completion_mask, request, filter_ap.get());
 }
 
 void OptionGroupOptions::Append(OptionGroup *group) {