summaryrefslogtreecommitdiff
path: root/source/Commands
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:54 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:54 +0000
commit39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (patch)
tree37fd694b2fe544b0ccefb369794632592d138dde /source/Commands
parentf73363f1dd94996356cefbf24388f561891acf0b (diff)
Diffstat (limited to 'source/Commands')
-rw-r--r--source/Commands/CommandCompletions.cpp60
-rw-r--r--source/Commands/CommandObjectCommands.cpp4
-rw-r--r--source/Commands/CommandObjectFrame.cpp2
-rw-r--r--source/Commands/CommandObjectMultiword.cpp26
-rw-r--r--source/Commands/CommandObjectPlatform.cpp6
-rw-r--r--source/Commands/CommandObjectPlugin.cpp2
-rw-r--r--source/Commands/CommandObjectProcess.cpp6
-rw-r--r--source/Commands/CommandObjectSettings.cpp18
-rw-r--r--source/Commands/CommandObjectTarget.cpp10
9 files changed, 72 insertions, 62 deletions
diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp
index bdfdbb83219b..7b351c50dc69 100644
--- a/source/Commands/CommandCompletions.cpp
+++ b/source/Commands/CommandCompletions.cpp
@@ -90,7 +90,7 @@ int CommandCompletions::SourceFiles(CommandInterpreter &interpreter,
} else {
completer.DoCompletion(searcher);
}
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
static int DiskFilesOrDirectories(const llvm::Twine &partial_name,
@@ -103,7 +103,7 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name,
partial_name.toVector(CompletionBuffer);
if (CompletionBuffer.size() >= PATH_MAX)
- return 0;
+ return matches.GetSize();
namespace fs = llvm::sys::fs;
namespace path = llvm::sys::path;
@@ -145,7 +145,7 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name,
// Make sure it ends with a separator.
path::append(CompletionBuffer, path::get_separator());
matches.AppendString(CompletionBuffer);
- return 1;
+ return matches.GetSize();
}
// We want to keep the form the user typed, so we special case this to
@@ -224,13 +224,21 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name,
return matches.GetSize();
}
+static int DiskFilesOrDirectories(CompletionRequest &request,
+ bool only_directories) {
+ request.SetWordComplete(false);
+ StandardTildeExpressionResolver resolver;
+ StringList matches;
+ DiskFilesOrDirectories(request.GetCursorArgumentPrefix(), only_directories,
+ matches, resolver);
+ request.AddCompletions(matches);
+ return request.GetNumberOfMatches();
+}
+
int CommandCompletions::DiskFiles(CommandInterpreter &interpreter,
CompletionRequest &request,
SearchFilter *searcher) {
- request.SetWordComplete(false);
- StandardTildeExpressionResolver Resolver;
- return DiskFiles(request.GetCursorArgumentPrefix(), request.GetMatches(),
- Resolver);
+ return DiskFilesOrDirectories(request, /*only_dirs*/ false);
}
int CommandCompletions::DiskFiles(const llvm::Twine &partial_file_name,
@@ -242,10 +250,7 @@ int CommandCompletions::DiskFiles(const llvm::Twine &partial_file_name,
int CommandCompletions::DiskDirectories(CommandInterpreter &interpreter,
CompletionRequest &request,
SearchFilter *searcher) {
- request.SetWordComplete(false);
- StandardTildeExpressionResolver Resolver;
- return DiskDirectories(request.GetCursorArgumentPrefix(),
- request.GetMatches(), Resolver);
+ return DiskFilesOrDirectories(request, /*only_dirs*/ true);
}
int CommandCompletions::DiskDirectories(const llvm::Twine &partial_file_name,
@@ -267,7 +272,7 @@ int CommandCompletions::Modules(CommandInterpreter &interpreter,
} else {
completer.DoCompletion(searcher);
}
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
int CommandCompletions::Symbols(CommandInterpreter &interpreter,
@@ -283,7 +288,7 @@ int CommandCompletions::Symbols(CommandInterpreter &interpreter,
} else {
completer.DoCompletion(searcher);
}
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
int CommandCompletions::SettingsNames(CommandInterpreter &interpreter,
@@ -304,20 +309,23 @@ int CommandCompletions::SettingsNames(CommandInterpreter &interpreter,
}
size_t exact_matches_idx = SIZE_MAX;
- const size_t num_matches =
- g_property_names.AutoComplete(request.GetCursorArgumentPrefix(),
- request.GetMatches(), exact_matches_idx);
+ StringList matches;
+ g_property_names.AutoComplete(request.GetCursorArgumentPrefix(), matches,
+ exact_matches_idx);
request.SetWordComplete(exact_matches_idx != SIZE_MAX);
- return num_matches;
+ request.AddCompletions(matches);
+ return request.GetNumberOfMatches();
}
int CommandCompletions::PlatformPluginNames(CommandInterpreter &interpreter,
CompletionRequest &request,
SearchFilter *searcher) {
- const uint32_t num_matches = PluginManager::AutoCompletePlatformName(
- request.GetCursorArgumentPrefix(), request.GetMatches());
+ StringList new_matches;
+ std::size_t num_matches = PluginManager::AutoCompletePlatformName(
+ request.GetCursorArgumentPrefix(), new_matches);
request.SetWordComplete(num_matches == 1);
- return num_matches;
+ request.AddCompletions(new_matches);
+ return request.GetNumberOfMatches();
}
int CommandCompletions::ArchitectureNames(CommandInterpreter &interpreter,
@@ -409,10 +417,10 @@ CommandCompletions::SourceFileCompleter::DoCompletion(SearchFilter *filter) {
filter->Search(*this);
// Now convert the filelist to completions:
for (size_t i = 0; i < m_matching_files.GetSize(); i++) {
- m_request.GetMatches().AppendString(
+ m_request.AddCompletion(
m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString());
}
- return m_request.GetMatches().GetSize();
+ return m_request.GetNumberOfMatches();
}
//----------------------------------------------------------------------
@@ -478,9 +486,9 @@ size_t CommandCompletions::SymbolCompleter::DoCompletion(SearchFilter *filter) {
filter->Search(*this);
collection::iterator pos = m_match_set.begin(), end = m_match_set.end();
for (pos = m_match_set.begin(); pos != end; pos++)
- m_request.GetMatches().AppendString((*pos).GetCString());
+ m_request.AddCompletion((*pos).GetCString());
- return m_request.GetMatches().GetSize();
+ return m_request.GetNumberOfMatches();
}
//----------------------------------------------------------------------
@@ -517,7 +525,7 @@ Searcher::CallbackReturn CommandCompletions::ModuleCompleter::SearchCallback(
match = false;
if (match) {
- m_request.GetMatches().AppendString(cur_file_name);
+ m_request.AddCompletion(cur_file_name);
}
}
return Searcher::eCallbackReturnContinue;
@@ -525,5 +533,5 @@ Searcher::CallbackReturn CommandCompletions::ModuleCompleter::SearchCallback(
size_t CommandCompletions::ModuleCompleter::DoCompletion(SearchFilter *filter) {
filter->Search(*this);
- return m_request.GetMatches().GetSize();
+ return m_request.GetNumberOfMatches();
}
diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp
index 3012ee4a188d..333f72056cbc 100644
--- a/source/Commands/CommandObjectCommands.cpp
+++ b/source/Commands/CommandObjectCommands.cpp
@@ -241,7 +241,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
Options *GetOptions() override { return &m_options; }
@@ -1429,7 +1429,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
Options *GetOptions() override { return &m_options; }
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index 0183c43f85b5..64de14f2edbf 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -470,7 +470,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp
index ade1a2d01f38..19fcf60e557c 100644
--- a/source/Commands/CommandObjectMultiword.cpp
+++ b/source/Commands/CommandObjectMultiword.cpp
@@ -143,7 +143,7 @@ bool CommandObjectMultiword::Execute(const char *args_string,
if (num_subcmd_matches > 0) {
error_msg.append(" Possible completions:");
- for (size_t i = 0; i < num_subcmd_matches; i++) {
+ for (size_t i = 0; i < matches.GetSize(); i++) {
error_msg.append("\n\t");
error_msg.append(matches.GetStringAtIndex(i));
}
@@ -190,21 +190,22 @@ int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
// Any of the command matches will provide a complete word, otherwise the
// individual completers will override this.
request.SetWordComplete(true);
- auto &matches = request.GetMatches();
auto arg0 = request.GetParsedLine()[0].ref;
if (request.GetCursorIndex() == 0) {
- AddNamesMatchingPartialString(m_subcommand_dict, arg0, matches);
+ StringList new_matches;
+ AddNamesMatchingPartialString(m_subcommand_dict, arg0, new_matches);
+ request.AddCompletions(new_matches);
- if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != nullptr &&
- (arg0 == matches.GetStringAtIndex(0))) {
+ if (new_matches.GetSize() == 1 &&
+ new_matches.GetStringAtIndex(0) != nullptr &&
+ (arg0 == new_matches.GetStringAtIndex(0))) {
StringList temp_matches;
CommandObject *cmd_obj = GetSubcommandObject(arg0, &temp_matches);
if (cmd_obj != nullptr) {
if (request.GetParsedLine().GetArgumentCount() == 1) {
request.SetWordComplete(true);
} else {
- matches.DeleteStringAtIndex(0);
request.GetParsedLine().Shift();
request.SetCursorCharPosition(0);
request.GetParsedLine().AppendArgument(llvm::StringRef());
@@ -212,14 +213,17 @@ int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
}
}
}
- return matches.GetSize();
+ return new_matches.GetSize();
} else {
- CommandObject *sub_command_object = GetSubcommandObject(arg0, &matches);
+ StringList new_matches;
+ CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
if (sub_command_object == nullptr) {
- return matches.GetSize();
+ request.AddCompletions(new_matches);
+ return request.GetNumberOfMatches();
} else {
// Remove the one match that we got from calling GetSubcommandObject.
- matches.DeleteStringAtIndex(0);
+ new_matches.DeleteStringAtIndex(0);
+ request.AddCompletions(new_matches);
request.GetParsedLine().Shift();
request.SetCursorIndex(request.GetCursorIndex() - 1);
return sub_command_object->HandleCompletion(request);
@@ -366,7 +370,6 @@ int CommandObjectProxy::HandleCompletion(CompletionRequest &request) {
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->HandleCompletion(request);
- request.GetMatches().Clear();
return 0;
}
@@ -375,7 +378,6 @@ int CommandObjectProxy::HandleArgumentCompletion(
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->HandleArgumentCompletion(request, opt_element_vector);
- request.GetMatches().Clear();
return 0;
}
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index f822a8b54cb0..22a9a169c7c8 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -181,7 +181,7 @@ public:
int HandleCompletion(CompletionRequest &request) override {
CommandCompletions::PlatformPluginNames(GetCommandInterpreter(), request,
nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
Options *GetOptions() override { return &m_option_group; }
@@ -1583,9 +1583,9 @@ public:
const uint32_t num_matches = process_infos.GetSize();
if (num_matches > 0) {
for (uint32_t i = 0; i < num_matches; ++i) {
- request.GetMatches().AppendString(
+ request.AddCompletion(llvm::StringRef(
process_infos.GetProcessNameAtIndex(i),
- process_infos.GetProcessNameLengthAtIndex(i));
+ process_infos.GetProcessNameLengthAtIndex(i)));
}
}
}
diff --git a/source/Commands/CommandObjectPlugin.cpp b/source/Commands/CommandObjectPlugin.cpp
index 1f379a2660ed..13ef6b227c5b 100644
--- a/source/Commands/CommandObjectPlugin.cpp
+++ b/source/Commands/CommandObjectPlugin.cpp
@@ -48,7 +48,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 3ac27918df4c..eb5a19aa4d39 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -141,7 +141,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
Options *GetOptions() override { return &m_options; }
@@ -410,9 +410,9 @@ public:
const size_t num_matches = process_infos.GetSize();
if (num_matches > 0) {
for (size_t i = 0; i < num_matches; ++i) {
- request.GetMatches().AppendString(
+ request.AddCompletion(llvm::StringRef(
process_infos.GetProcessNameAtIndex(i),
- process_infos.GetProcessNameLengthAtIndex(i));
+ process_infos.GetProcessNameLengthAtIndex(i)));
}
}
}
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp
index f259f2fe200d..3db1e35cd702 100644
--- a/source/Commands/CommandObjectSettings.cpp
+++ b/source/Commands/CommandObjectSettings.cpp
@@ -172,7 +172,7 @@ insert-before or insert-after.");
}
}
}
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -272,7 +272,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -338,7 +338,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -427,7 +427,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -544,7 +544,7 @@ public:
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -644,7 +644,7 @@ public:
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -749,7 +749,7 @@ public:
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -843,7 +843,7 @@ public:
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -924,7 +924,7 @@ public:
GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index a9062c14b367..8be43cbf9bb0 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -201,7 +201,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -1810,7 +1810,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eModuleCompletion, request,
nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
};
@@ -1851,7 +1851,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eSourceFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
};
@@ -2393,7 +2393,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
protected:
@@ -3987,7 +3987,7 @@ public:
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
- return request.GetMatches().GetSize();
+ return request.GetNumberOfMatches();
}
Options *GetOptions() override { return &m_option_group; }