summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/OptionValueEnumeration.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/Interpreter/OptionValueEnumeration.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/Interpreter/OptionValueEnumeration.cpp')
-rw-r--r--lldb/source/Interpreter/OptionValueEnumeration.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index 9510f4a671d..e78618ee3c6 100644
--- a/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -109,23 +109,23 @@ lldb::OptionValueSP OptionValueEnumeration::DeepCopy() const {
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();
}
OpenPOWER on IntegriCloud