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
This commit is contained in:
Raphael Isemann
2018-07-13 18:28:14 +00:00
parent d6c062bce1
commit a2e76c0bfc
38 changed files with 379 additions and 704 deletions

View File

@@ -95,15 +95,8 @@ bool CommandObjectRegexCommand::AddRegexCommand(const char *re_cstr,
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();