summaryrefslogtreecommitdiff
path: root/source/Interpreter
diff options
context:
space:
mode:
Diffstat (limited to 'source/Interpreter')
-rw-r--r--source/Interpreter/CommandInterpreter.cpp26
-rw-r--r--source/Interpreter/CommandObject.cpp3
-rw-r--r--source/Interpreter/CommandObjectRegexCommand.cpp3
-rw-r--r--source/Interpreter/OptionValue.cpp3
-rw-r--r--source/Interpreter/OptionValueArch.cpp3
-rw-r--r--source/Interpreter/OptionValueBoolean.cpp5
-rw-r--r--source/Interpreter/OptionValueEnumeration.cpp8
-rw-r--r--source/Interpreter/OptionValueFileSpec.cpp3
-rw-r--r--source/Interpreter/OptionValueUUID.cpp5
-rw-r--r--source/Interpreter/Options.cpp22
10 files changed, 32 insertions, 49 deletions
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index 4c8b65441366b..64d2c3222fb6b 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -478,7 +478,7 @@ void CommandInterpreter::LoadCommandDictionary() {
std::unique_ptr<CommandObjectRegexCommand> break_regex_cmd_ap(
new CommandObjectRegexCommand(
*this, "_regexp-break",
- "Set a breakpoint using one of several shorthand formats.\n",
+ "Set a breakpoint using one of several shorthand formats.",
"\n"
"_regexp-break <filename>:<linenum>\n"
" main.c:12 // Break at line 12 of "
@@ -527,7 +527,7 @@ void CommandInterpreter::LoadCommandDictionary() {
std::unique_ptr<CommandObjectRegexCommand> tbreak_regex_cmd_ap(
new CommandObjectRegexCommand(
*this, "_regexp-tbreak",
- "Set a one-shot breakpoint using one of several shorthand formats.\n",
+ "Set a one-shot breakpoint using one of several shorthand formats.",
"\n"
"_regexp-break <filename>:<linenum>\n"
" main.c:12 // Break at line 12 of "
@@ -1703,7 +1703,6 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
}
int CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) {
- auto &matches = request.GetMatches();
int num_command_matches = 0;
bool look_for_subcommand = false;
@@ -1713,30 +1712,34 @@ int CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) {
if (request.GetCursorIndex() == -1) {
// We got nothing on the command line, so return the list of commands
bool include_aliases = true;
+ StringList new_matches;
num_command_matches =
- GetCommandNamesMatchingPartialString("", include_aliases, matches);
+ GetCommandNamesMatchingPartialString("", include_aliases, new_matches);
+ request.AddCompletions(new_matches);
} else if (request.GetCursorIndex() == 0) {
// The cursor is in the first argument, so just do a lookup in the
// dictionary.
+ StringList new_matches;
CommandObject *cmd_obj = GetCommandObject(
- request.GetParsedLine().GetArgumentAtIndex(0), &matches);
- num_command_matches = matches.GetSize();
+ request.GetParsedLine().GetArgumentAtIndex(0), &new_matches);
if (num_command_matches == 1 && cmd_obj && cmd_obj->IsMultiwordObject() &&
- matches.GetStringAtIndex(0) != nullptr &&
+ new_matches.GetStringAtIndex(0) != nullptr &&
strcmp(request.GetParsedLine().GetArgumentAtIndex(0),
- matches.GetStringAtIndex(0)) == 0) {
+ new_matches.GetStringAtIndex(0)) == 0) {
if (request.GetParsedLine().GetArgumentCount() == 1) {
request.SetWordComplete(true);
} else {
look_for_subcommand = true;
num_command_matches = 0;
- matches.DeleteStringAtIndex(0);
+ new_matches.DeleteStringAtIndex(0);
request.GetParsedLine().AppendArgument(llvm::StringRef());
request.SetCursorIndex(request.GetCursorIndex() + 1);
request.SetCursorCharPosition(0);
}
}
+ request.AddCompletions(new_matches);
+ num_command_matches = request.GetNumberOfMatches();
}
if (request.GetCursorIndex() > 0 || look_for_subcommand) {
@@ -1773,8 +1776,7 @@ int CommandInterpreter::HandleCompletion(
return 0;
else if (first_arg[0] == CommandHistory::g_repeat_char) {
if (auto hist_str = m_command_history.FindString(first_arg)) {
- request.GetMatches().Clear();
- request.GetMatches().InsertStringAtIndex(0, *hist_str);
+ matches.InsertStringAtIndex(0, *hist_str);
return -2;
} else
return 0;
@@ -1812,7 +1814,7 @@ int CommandInterpreter::HandleCompletion(
common_prefix.push_back(quote_char);
common_prefix.push_back(' ');
}
- request.GetMatches().InsertStringAtIndex(0, common_prefix.c_str());
+ matches.InsertStringAtIndex(0, common_prefix.c_str());
}
return num_command_matches;
}
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 07be9139f2199..324b0b511220f 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -267,7 +267,6 @@ int CommandObject::HandleCompletion(CompletionRequest &request) {
if (WantsRawCommandString() && !WantsCompletion()) {
// FIXME: Abstract telling the completion to insert the completion
// character.
- request.GetMatches().Clear();
return -1;
} else {
// Can we do anything generic with the options?
@@ -282,7 +281,7 @@ int CommandObject::HandleCompletion(CompletionRequest &request) {
bool handled_by_options = cur_options->HandleOptionCompletion(
request, opt_element_vector, GetCommandInterpreter());
if (handled_by_options)
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
// If we got here, the last word is not an option or an option argument.
diff --git a/source/Interpreter/CommandObjectRegexCommand.cpp b/source/Interpreter/CommandObjectRegexCommand.cpp
index f975c0eea2ee8..ec89ad8fb1626 100644
--- a/source/Interpreter/CommandObjectRegexCommand.cpp
+++ b/source/Interpreter/CommandObjectRegexCommand.cpp
@@ -97,9 +97,8 @@ int CommandObjectRegexCommand::HandleCompletion(CompletionRequest &request) {
if (m_completion_type_mask) {
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), m_completion_type_mask, request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
} else {
- request.GetMatches().Clear();
request.SetWordComplete(false);
}
return 0;
diff --git a/source/Interpreter/OptionValue.cpp b/source/Interpreter/OptionValue.cpp
index 2d7c69eaa4326..c3f363b059880 100644
--- a/source/Interpreter/OptionValue.cpp
+++ b/source/Interpreter/OptionValue.cpp
@@ -575,8 +575,7 @@ bool OptionValue::DumpQualifiedName(Stream &strm) const {
size_t OptionValue::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
request.SetWordComplete(false);
- request.GetMatches().Clear();
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
Status OptionValue::SetValueFromString(llvm::StringRef value,
diff --git a/source/Interpreter/OptionValueArch.cpp b/source/Interpreter/OptionValueArch.cpp
index 3d08780ae6f69..d4f1fcb8a70a6 100644
--- a/source/Interpreter/OptionValueArch.cpp
+++ b/source/Interpreter/OptionValueArch.cpp
@@ -76,9 +76,8 @@ lldb::OptionValueSP OptionValueArch::DeepCopy() const {
size_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
request.SetWordComplete(false);
- request.GetMatches().Clear();
CommandCompletions::InvokeCommonCompletionCallbacks(
interpreter, CommandCompletions::eArchitectureCompletion, request,
nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
diff --git a/source/Interpreter/OptionValueBoolean.cpp b/source/Interpreter/OptionValueBoolean.cpp
index 8a340792d78ff..94c774d691118 100644
--- a/source/Interpreter/OptionValueBoolean.cpp
+++ b/source/Interpreter/OptionValueBoolean.cpp
@@ -79,7 +79,6 @@ lldb::OptionValueSP OptionValueBoolean::DeepCopy() const {
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"};
@@ -91,7 +90,7 @@ size_t OptionValueBoolean::AutoComplete(CommandInterpreter &interpreter,
for (auto entry : entries) {
if (entry.startswith_lower(request.GetCursorArgumentPrefix()))
- request.GetMatches().AppendString(entry);
+ request.AddCompletion(entry);
}
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
diff --git a/source/Interpreter/OptionValueEnumeration.cpp b/source/Interpreter/OptionValueEnumeration.cpp
index e78618ee3c6b4..c7cbcab7fcc8d 100644
--- a/source/Interpreter/OptionValueEnumeration.cpp
+++ b/source/Interpreter/OptionValueEnumeration.cpp
@@ -112,20 +112,18 @@ lldb::OptionValueSP OptionValueEnumeration::DeepCopy() const {
size_t OptionValueEnumeration::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
request.SetWordComplete(false);
- request.GetMatches().Clear();
const uint32_t num_enumerators = m_enumerations.GetSize();
if (!request.GetCursorArgumentPrefix().empty()) {
for (size_t i = 0; i < num_enumerators; ++i) {
llvm::StringRef name = m_enumerations.GetCStringAtIndex(i).GetStringRef();
if (name.startswith(request.GetCursorArgumentPrefix()))
- request.GetMatches().AppendString(name);
+ request.AddCompletion(name);
}
} else {
// only suggest "true" or "false" by default
for (size_t i = 0; i < num_enumerators; ++i)
- request.GetMatches().AppendString(
- m_enumerations.GetCStringAtIndex(i).GetStringRef());
+ request.AddCompletion(m_enumerations.GetCStringAtIndex(i).GetStringRef());
}
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
diff --git a/source/Interpreter/OptionValueFileSpec.cpp b/source/Interpreter/OptionValueFileSpec.cpp
index 18bfcd693949b..2b93628679ce1 100644
--- a/source/Interpreter/OptionValueFileSpec.cpp
+++ b/source/Interpreter/OptionValueFileSpec.cpp
@@ -102,10 +102,9 @@ lldb::OptionValueSP OptionValueFileSpec::DeepCopy() const {
size_t OptionValueFileSpec::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
request.SetWordComplete(false);
- request.GetMatches().Clear();
CommandCompletions::InvokeCommonCompletionCallbacks(
interpreter, m_completion_mask, request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
const lldb::DataBufferSP &OptionValueFileSpec::GetFileContents() {
diff --git a/source/Interpreter/OptionValueUUID.cpp b/source/Interpreter/OptionValueUUID.cpp
index 7fa155277cecb..355e07bb2b5fe 100644
--- a/source/Interpreter/OptionValueUUID.cpp
+++ b/source/Interpreter/OptionValueUUID.cpp
@@ -70,7 +70,6 @@ lldb::OptionValueSP OptionValueUUID::DeepCopy() const {
size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
request.SetWordComplete(false);
- request.GetMatches().Clear();
ExecutionContext exe_ctx(interpreter.GetExecutionContext());
Target *target = exe_ctx.GetTargetPtr();
if (target) {
@@ -86,12 +85,12 @@ size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
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)) {
- request.GetMatches().AppendString(module_uuid.GetAsString());
+ request.AddCompletion(module_uuid.GetAsString());
}
}
}
}
}
}
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index f4758978e2a64..c9567e91f6b8d 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -680,7 +680,7 @@ bool Options::HandleOptionCompletion(CompletionRequest &request,
if (!def.short_option)
continue;
opt_str[1] = def.short_option;
- request.GetMatches().AppendString(opt_str);
+ request.AddCompletion(opt_str);
}
return true;
@@ -692,7 +692,7 @@ bool Options::HandleOptionCompletion(CompletionRequest &request,
full_name.erase(full_name.begin() + 2, full_name.end());
full_name.append(def.long_option);
- request.GetMatches().AppendString(full_name.c_str());
+ request.AddCompletion(full_name.c_str());
}
return true;
} else if (opt_defs_index != OptionArgElement::eUnrecognizedArg) {
@@ -705,10 +705,10 @@ bool Options::HandleOptionCompletion(CompletionRequest &request,
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);
- request.GetMatches().AppendString(full_name.c_str());
+ request.AddCompletion(full_name.c_str());
return true;
} else {
- request.GetMatches().AppendString(request.GetCursorArgument());
+ request.AddCompletion(request.GetCursorArgument());
return true;
}
} else {
@@ -728,17 +728,7 @@ bool Options::HandleOptionCompletion(CompletionRequest &request,
if (strstr(def.long_option, cur_opt_str + 2) == def.long_option) {
std::string full_name("--");
full_name.append(def.long_option);
- // 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 < request.GetMatches().GetSize(); k++) {
- if (request.GetMatches().GetStringAtIndex(k) == full_name) {
- duplicate = true;
- break;
- }
- }
- if (!duplicate)
- request.GetMatches().AppendString(full_name.c_str());
+ request.AddCompletion(full_name.c_str());
}
}
}
@@ -790,7 +780,7 @@ bool Options::HandleOptionArgumentCompletion(
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) {
- request.GetMatches().AppendString(enum_values[i].string_value);
+ request.AddCompletion(enum_values[i].string_value);
return_value = true;
}
}