diff options
author | Raphael Isemann <teemperor@gmail.com> | 2020-02-12 09:22:59 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-02-12 09:48:51 +0100 |
commit | 440460f1e70193f5805e2fdbc6d91ab5d5d0bbab (patch) | |
tree | 57be18eef54898fe21bd915cfe78e4dceb697401 /lldb/source/Commands/CommandCompletions.cpp | |
parent | a9a305716bbfa657ce0f7ae9cd50df82720a6db0 (diff) | |
download | llvm-440460f1e70193f5805e2fdbc6d91ab5d5d0bbab.zip llvm-440460f1e70193f5805e2fdbc6d91ab5d5d0bbab.tar.gz llvm-440460f1e70193f5805e2fdbc6d91ab5d5d0bbab.tar.bz2 |
[lldb][NFC] Move common_completions mapping out of CommandCompletions header.
Diffstat (limited to 'lldb/source/Commands/CommandCompletions.cpp')
-rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 31c8e6a..bc3a2ec 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -27,18 +27,17 @@ using namespace lldb_private; -CommandCompletions::CommonCompletionElement - CommandCompletions::g_common_completions[] = { - {eSourceFileCompletion, CommandCompletions::SourceFiles}, - {eDiskFileCompletion, CommandCompletions::DiskFiles}, - {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories}, - {eSymbolCompletion, CommandCompletions::Symbols}, - {eModuleCompletion, CommandCompletions::Modules}, - {eSettingsNameCompletion, CommandCompletions::SettingsNames}, - {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames}, - {eArchitectureCompletion, CommandCompletions::ArchitectureNames}, - {eVariablePathCompletion, CommandCompletions::VariablePath}, - {eNoCompletion, nullptr} // This one has to be last in the list. +// This is the command completion callback that is used to complete the +// argument of the option it is bound to (in the OptionDefinition table +// below). +typedef void (*CompletionCallback)(CommandInterpreter &interpreter, + CompletionRequest &request, + // A search filter to limit the search... + lldb_private::SearchFilter *searcher); + +struct CommonCompletionElement { + uint32_t type; + CompletionCallback callback; }; bool CommandCompletions::InvokeCommonCompletionCallbacks( @@ -46,14 +45,27 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( CompletionRequest &request, SearchFilter *searcher) { bool handled = false; + const CommonCompletionElement common_completions[] = { + {eSourceFileCompletion, CommandCompletions::SourceFiles}, + {eDiskFileCompletion, CommandCompletions::DiskFiles}, + {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories}, + {eSymbolCompletion, CommandCompletions::Symbols}, + {eModuleCompletion, CommandCompletions::Modules}, + {eSettingsNameCompletion, CommandCompletions::SettingsNames}, + {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames}, + {eArchitectureCompletion, CommandCompletions::ArchitectureNames}, + {eVariablePathCompletion, CommandCompletions::VariablePath}, + {eNoCompletion, nullptr} // This one has to be last in the list. + }; + for (int i = 0;; i++) { - if (g_common_completions[i].type == eNoCompletion) + if (common_completions[i].type == eNoCompletion) break; - else if ((g_common_completions[i].type & completion_mask) == - g_common_completions[i].type && - g_common_completions[i].callback != nullptr) { + else if ((common_completions[i].type & completion_mask) == + common_completions[i].type && + common_completions[i].callback != nullptr) { handled = true; - g_common_completions[i].callback(interpreter, request, searcher); + common_completions[i].callback(interpreter, request, searcher); } } return handled; |