diff options
author | Raphael Isemann <teemperor@gmail.com> | 2018-07-13 18:28:14 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2018-07-13 18:28:14 +0000 |
commit | a2e76c0bfc5bec8d50e8d13f71b72a66eaa0a386 (patch) | |
tree | 55563c896d181a4de6dc254f335c10a379e0eac0 /lldb/source/Commands | |
parent | d6c062bce1e499f52500cc759a7c0846dd178cda (diff) | |
download | bcm5719-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/Commands')
-rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 189 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 19 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 9 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectPlatform.cpp | 23 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectPlugin.cpp | 9 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 20 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.cpp | 97 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 54 |
8 files changed, 103 insertions, 317 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index f83a06d6748..bdfdbb83219 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -57,9 +57,7 @@ CommandCompletions::CommonCompletionElement bool CommandCompletions::InvokeCommonCompletionCallbacks( CommandInterpreter &interpreter, uint32_t completion_mask, - llvm::StringRef completion_str, int match_start_point, - int max_return_elements, SearchFilter *searcher, bool &word_complete, - StringList &matches) { + CompletionRequest &request, SearchFilter *searcher) { bool handled = false; if (completion_mask & eCustomCompletion) @@ -72,25 +70,18 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( g_common_completions[i].type && g_common_completions[i].callback != nullptr) { handled = true; - g_common_completions[i].callback(interpreter, completion_str, - match_start_point, max_return_elements, - searcher, word_complete, matches); + g_common_completions[i].callback(interpreter, request, searcher); } } return handled; } int CommandCompletions::SourceFiles(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, - int max_return_elements, - SearchFilter *searcher, bool &word_complete, - StringList &matches) { - word_complete = true; + CompletionRequest &request, + SearchFilter *searcher) { + request.SetWordComplete(true); // Find some way to switch "include support files..." - SourceFileCompleter completer(interpreter, false, partial_file_name, - match_start_point, max_return_elements, - matches); + SourceFileCompleter completer(interpreter, false, request); if (searcher == nullptr) { lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget(); @@ -99,12 +90,11 @@ int CommandCompletions::SourceFiles(CommandInterpreter &interpreter, } else { completer.DoCompletion(searcher); } - return matches.GetSize(); + return request.GetMatches().GetSize(); } static int DiskFilesOrDirectories(const llvm::Twine &partial_name, - bool only_directories, bool &saw_directory, - StringList &matches, + bool only_directories, StringList &matches, TildeExpressionResolver &Resolver) { matches.Clear(); @@ -138,13 +128,12 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, // but after that, we're done regardless of any matches. if (FirstSep == llvm::StringRef::npos) { llvm::StringSet<> MatchSet; - saw_directory = Resolver.ResolvePartial(Username, MatchSet); + Resolver.ResolvePartial(Username, MatchSet); for (const auto &S : MatchSet) { Resolved = S.getKey(); path::append(Resolved, path::get_separator()); matches.AppendString(Resolved); } - saw_directory = (matches.GetSize() > 0); } return matches.GetSize(); } @@ -155,7 +144,6 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, if (FirstSep == llvm::StringRef::npos) { // Make sure it ends with a separator. path::append(CompletionBuffer, path::get_separator()); - saw_directory = true; matches.AppendString(CompletionBuffer); return 1; } @@ -227,7 +215,6 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, CompletionBuffer.append(Name); if (is_dir) { - saw_directory = true; path::append(CompletionBuffer, path::get_separator()); } @@ -238,51 +225,40 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, } int CommandCompletions::DiskFiles(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, - int max_return_elements, - SearchFilter *searcher, bool &word_complete, - StringList &matches) { - word_complete = false; + CompletionRequest &request, + SearchFilter *searcher) { + request.SetWordComplete(false); StandardTildeExpressionResolver Resolver; - return DiskFiles(partial_file_name, matches, Resolver); + return DiskFiles(request.GetCursorArgumentPrefix(), request.GetMatches(), + Resolver); } int CommandCompletions::DiskFiles(const llvm::Twine &partial_file_name, StringList &matches, TildeExpressionResolver &Resolver) { - bool word_complete; - int ret_val = DiskFilesOrDirectories(partial_file_name, false, word_complete, - matches, Resolver); - return ret_val; + return DiskFilesOrDirectories(partial_file_name, false, matches, Resolver); } -int CommandCompletions::DiskDirectories( - CommandInterpreter &interpreter, llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, SearchFilter *searcher, - bool &word_complete, StringList &matches) { - word_complete = false; +int CommandCompletions::DiskDirectories(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + request.SetWordComplete(false); StandardTildeExpressionResolver Resolver; - return DiskDirectories(partial_file_name, matches, Resolver); + return DiskDirectories(request.GetCursorArgumentPrefix(), + request.GetMatches(), Resolver); } int CommandCompletions::DiskDirectories(const llvm::Twine &partial_file_name, StringList &matches, TildeExpressionResolver &Resolver) { - bool word_complete; - int ret_val = DiskFilesOrDirectories(partial_file_name, true, word_complete, - matches, Resolver); - return ret_val; + return DiskFilesOrDirectories(partial_file_name, true, matches, Resolver); } int CommandCompletions::Modules(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - StringList &matches) { - word_complete = true; - ModuleCompleter completer(interpreter, partial_file_name, match_start_point, - max_return_elements, matches); + CompletionRequest &request, + SearchFilter *searcher) { + request.SetWordComplete(true); + ModuleCompleter completer(interpreter, request); if (searcher == nullptr) { lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget(); @@ -291,17 +267,14 @@ int CommandCompletions::Modules(CommandInterpreter &interpreter, } else { completer.DoCompletion(searcher); } - return matches.GetSize(); + return request.GetMatches().GetSize(); } int CommandCompletions::Symbols(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - StringList &matches) { - word_complete = true; - SymbolCompleter completer(interpreter, partial_file_name, match_start_point, - max_return_elements, matches); + CompletionRequest &request, + SearchFilter *searcher) { + request.SetWordComplete(true); + SymbolCompleter completer(interpreter, request); if (searcher == nullptr) { lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget(); @@ -310,13 +283,12 @@ int CommandCompletions::Symbols(CommandInterpreter &interpreter, } else { completer.DoCompletion(searcher); } - return matches.GetSize(); + return request.GetMatches().GetSize(); } -int CommandCompletions::SettingsNames( - CommandInterpreter &interpreter, llvm::StringRef partial_setting_name, - int match_start_point, int max_return_elements, SearchFilter *searcher, - bool &word_complete, StringList &matches) { +int CommandCompletions::SettingsNames(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { // Cache the full setting name list static StringList g_property_names; if (g_property_names.GetSize() == 0) { @@ -332,47 +304,39 @@ int CommandCompletions::SettingsNames( } size_t exact_matches_idx = SIZE_MAX; - const size_t num_matches = g_property_names.AutoComplete( - partial_setting_name, matches, exact_matches_idx); - word_complete = exact_matches_idx != SIZE_MAX; + const size_t num_matches = + g_property_names.AutoComplete(request.GetCursorArgumentPrefix(), + request.GetMatches(), exact_matches_idx); + request.SetWordComplete(exact_matches_idx != SIZE_MAX); return num_matches; } -int CommandCompletions::PlatformPluginNames( - CommandInterpreter &interpreter, llvm::StringRef partial_name, - int match_start_point, int max_return_elements, SearchFilter *searcher, - bool &word_complete, lldb_private::StringList &matches) { - const uint32_t num_matches = - PluginManager::AutoCompletePlatformName(partial_name, matches); - word_complete = num_matches == 1; +int CommandCompletions::PlatformPluginNames(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + const uint32_t num_matches = PluginManager::AutoCompletePlatformName( + request.GetCursorArgumentPrefix(), request.GetMatches()); + request.SetWordComplete(num_matches == 1); return num_matches; } -int CommandCompletions::ArchitectureNames( - CommandInterpreter &interpreter, llvm::StringRef partial_name, - int match_start_point, int max_return_elements, SearchFilter *searcher, - bool &word_complete, lldb_private::StringList &matches) { - const uint32_t num_matches = ArchSpec::AutoComplete(partial_name, matches); - word_complete = num_matches == 1; +int CommandCompletions::ArchitectureNames(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + const uint32_t num_matches = ArchSpec::AutoComplete(request); + request.SetWordComplete(num_matches == 1); return num_matches; } -int CommandCompletions::VariablePath( - CommandInterpreter &interpreter, llvm::StringRef partial_name, - int match_start_point, int max_return_elements, SearchFilter *searcher, - bool &word_complete, lldb_private::StringList &matches) { - return Variable::AutoComplete(interpreter.GetExecutionContext(), partial_name, - matches, word_complete); +int CommandCompletions::VariablePath(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + return Variable::AutoComplete(interpreter.GetExecutionContext(), request); } CommandCompletions::Completer::Completer(CommandInterpreter &interpreter, - llvm::StringRef completion_str, - int match_start_point, - int max_return_elements, - StringList &matches) - : m_interpreter(interpreter), m_completion_str(completion_str), - m_match_start_point(match_start_point), - m_max_return_elements(max_return_elements), m_matches(matches) {} + CompletionRequest &request) + : m_interpreter(interpreter), m_request(request) {} CommandCompletions::Completer::~Completer() = default; @@ -382,13 +346,10 @@ CommandCompletions::Completer::~Completer() = default; CommandCompletions::SourceFileCompleter::SourceFileCompleter( CommandInterpreter &interpreter, bool include_support_files, - llvm::StringRef completion_str, int match_start_point, - int max_return_elements, StringList &matches) - : CommandCompletions::Completer(interpreter, completion_str, - match_start_point, max_return_elements, - matches), + CompletionRequest &request) + : CommandCompletions::Completer(interpreter, request), m_include_support_files(include_support_files), m_matching_files() { - FileSpec partial_spec(m_completion_str, false); + FileSpec partial_spec(m_request.GetCursorArgumentPrefix(), false); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } @@ -448,10 +409,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_matches.AppendString( + m_request.GetMatches().AppendString( m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString()); } - return m_matches.GetSize(); + return m_request.GetMatches().GetSize(); } //---------------------------------------------------------------------- @@ -466,15 +427,12 @@ static bool regex_chars(const char comp) { } CommandCompletions::SymbolCompleter::SymbolCompleter( - CommandInterpreter &interpreter, llvm::StringRef completion_str, - int match_start_point, int max_return_elements, StringList &matches) - : CommandCompletions::Completer(interpreter, completion_str, - match_start_point, max_return_elements, - matches) { + CommandInterpreter &interpreter, CompletionRequest &request) + : CommandCompletions::Completer(interpreter, request) { std::string regex_str; - if (!completion_str.empty()) { + if (!m_request.GetCursorArgumentPrefix().empty()) { regex_str.append("^"); - regex_str.append(completion_str); + regex_str.append(m_request.GetCursorArgumentPrefix()); } else { // Match anything since the completion string is empty regex_str.append("."); @@ -520,21 +478,18 @@ 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_matches.AppendString((*pos).GetCString()); + m_request.GetMatches().AppendString((*pos).GetCString()); - return m_matches.GetSize(); + return m_request.GetMatches().GetSize(); } //---------------------------------------------------------------------- // ModuleCompleter //---------------------------------------------------------------------- CommandCompletions::ModuleCompleter::ModuleCompleter( - CommandInterpreter &interpreter, llvm::StringRef completion_str, - int match_start_point, int max_return_elements, StringList &matches) - : CommandCompletions::Completer(interpreter, completion_str, - match_start_point, max_return_elements, - matches) { - FileSpec partial_spec(m_completion_str, false); + CommandInterpreter &interpreter, CompletionRequest &request) + : CommandCompletions::Completer(interpreter, request) { + FileSpec partial_spec(m_request.GetCursorArgumentPrefix(), false); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } @@ -562,7 +517,7 @@ Searcher::CallbackReturn CommandCompletions::ModuleCompleter::SearchCallback( match = false; if (match) { - m_matches.AppendString(cur_file_name); + m_request.GetMatches().AppendString(cur_file_name); } } return Searcher::eCallbackReturnContinue; @@ -570,5 +525,5 @@ Searcher::CallbackReturn CommandCompletions::ModuleCompleter::SearchCallback( size_t CommandCompletions::ModuleCompleter::DoCompletion(SearchFilter *filter) { filter->Search(*this); - return m_matches.GetSize(); + return m_request.GetMatches().GetSize(); } diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index b7f439e5219..3012ee4a188 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -238,16 +238,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - auto completion_str = request.GetParsedLine()[request.GetCursorIndex()].ref; - completion_str = completion_str.take_front(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, - completion_str, request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -1433,17 +1426,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - llvm::StringRef completion_str = - request.GetParsedLine()[request.GetCursorIndex()].ref; - completion_str = completion_str.take_front(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, - completion_str, request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 68600215585..0183c43f85b 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -467,16 +467,9 @@ public: CompletionRequest &request, OptionElementVector &opt_element_vector) override { // Arguments are the standard source file completer. - auto completion_str = request.GetParsedLine()[request.GetCursorIndex()].ref; - completion_str = completion_str.take_front(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion, - completion_str, request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 3a27f34fec7..f822a8b54cb 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -179,16 +179,8 @@ public: ~CommandObjectPlatformSelect() override = default; int HandleCompletion(CompletionRequest &request) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex())); - completion_str.erase(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); - CommandCompletions::PlatformPluginNames( - GetCommandInterpreter(), completion_str.c_str(), - request.GetMatchStartPoint(), request.GetMaxReturnElements(), nullptr, - word_complete, request.GetMatches()); - request.SetWordComplete(word_complete); + CommandCompletions::PlatformPluginNames(GetCommandInterpreter(), request, + nullptr); return request.GetMatches().GetSize(); } @@ -1562,11 +1554,8 @@ public: } bool HandleOptionArgumentCompletion( - Args &input, int cursor_index, int char_pos, - OptionElementVector &opt_element_vector, int opt_element_index, - int match_start_point, int max_return_elements, - CommandInterpreter &interpreter, bool &word_complete, - StringList &matches) override { + CompletionRequest &request, OptionElementVector &opt_element_vector, + int opt_element_index, CommandInterpreter &interpreter) override { int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; @@ -1579,7 +1568,7 @@ public: // plugin, otherwise use the default plugin. const char *partial_name = nullptr; - partial_name = input.GetArgumentAtIndex(opt_arg_pos); + partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos); PlatformSP platform_sp(interpreter.GetPlatform(true)); if (platform_sp) { @@ -1594,7 +1583,7 @@ public: const uint32_t num_matches = process_infos.GetSize(); if (num_matches > 0) { for (uint32_t i = 0; i < num_matches; ++i) { - matches.AppendString( + request.GetMatches().AppendString( process_infos.GetProcessNameAtIndex(i), process_infos.GetProcessNameLengthAtIndex(i)); } diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp index 36db0d12005..1f379a2660e 100644 --- a/lldb/source/Commands/CommandObjectPlugin.cpp +++ b/lldb/source/Commands/CommandObjectPlugin.cpp @@ -45,16 +45,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - auto completion_str = request.GetParsedLine()[request.GetCursorIndex()].ref; - completion_str = completion_str.take_front(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, - completion_str, request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 86d477754ea..3ac27918df4 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -137,17 +137,10 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex())); - completion_str.erase(request.GetCursorCharPosition()); - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -388,11 +381,8 @@ public: } bool HandleOptionArgumentCompletion( - Args &input, int cursor_index, int char_pos, - OptionElementVector &opt_element_vector, int opt_element_index, - int match_start_point, int max_return_elements, - CommandInterpreter &interpreter, bool &word_complete, - StringList &matches) override { + CompletionRequest &request, OptionElementVector &opt_element_vector, + int opt_element_index, CommandInterpreter &interpreter) override { int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; @@ -405,7 +395,7 @@ public: // plugin, otherwise use the default plugin. const char *partial_name = nullptr; - partial_name = input.GetArgumentAtIndex(opt_arg_pos); + partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos); PlatformSP platform_sp(interpreter.GetPlatform(true)); if (platform_sp) { @@ -420,7 +410,7 @@ public: const size_t num_matches = process_infos.GetSize(); if (num_matches > 0) { for (size_t i = 0; i < num_matches; ++i) { - matches.AppendString( + request.GetMatches().AppendString( process_infos.GetProcessNameAtIndex(i), process_infos.GetProcessNameLengthAtIndex(i)); } diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index ed58ca45d04..f259f2fe200 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -136,9 +136,6 @@ insert-before or insert-after."); int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); const size_t argc = request.GetParsedLine().GetArgumentCount(); const char *arg = nullptr; @@ -151,13 +148,9 @@ insert-before or insert-after."); } if (request.GetCursorIndex() == setting_var_idx) { // Attempting to complete setting variable name - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); } else { arg = request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()); @@ -174,12 +167,7 @@ insert-before or insert-after."); m_interpreter.GetDebugger().GetPropertyValue( &m_exe_ctx, setting_var_name, false, error)); if (value_sp) { - bool word_complete = request.GetWordComplete(); - value_sp->AutoComplete(m_interpreter, completion_str.c_str(), - request.GetMatchStartPoint(), - request.GetMaxReturnElements(), - word_complete, request.GetMatches()); - request.SetWordComplete(word_complete); + value_sp->AutoComplete(m_interpreter, request); } } } @@ -281,17 +269,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -355,17 +335,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -451,19 +423,10 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - // Attempting to complete variable name - bool word_complete = request.GetWordComplete(); if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -575,19 +538,11 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); // Attempting to complete variable name if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -683,19 +638,11 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); // Attempting to complete variable name if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -796,19 +743,11 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); // Attempting to complete variable name if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -898,19 +837,11 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); // Attempting to complete variable name if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -987,19 +918,11 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()), - request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); // Attempting to complete variable name if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index fc25fb37d4d..a9062c14b36 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -198,17 +198,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex())); - completion_str.erase(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -1815,18 +1807,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - // Arguments are the standard module completer. - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex())); - completion_str.erase(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( - GetCommandInterpreter(), CommandCompletions::eModuleCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + GetCommandInterpreter(), CommandCompletions::eModuleCompletion, request, + nullptr); return request.GetMatches().GetSize(); } }; @@ -1865,18 +1848,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - // Arguments are the standard source file completer. - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex())); - completion_str.erase(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSourceFileCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } }; @@ -2416,17 +2390,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex())); - completion_str.erase(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } @@ -4018,17 +3984,9 @@ public: int HandleArgumentCompletion( CompletionRequest &request, OptionElementVector &opt_element_vector) override { - std::string completion_str( - request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex())); - completion_str.erase(request.GetCursorCharPosition()); - - bool word_complete = request.GetWordComplete(); CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), request.GetMatchStartPoint(), - request.GetMaxReturnElements(), nullptr, word_complete, - request.GetMatches()); - request.SetWordComplete(word_complete); + request, nullptr); return request.GetMatches().GetSize(); } |