diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectSettings.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.cpp | 239 |
1 files changed, 126 insertions, 113 deletions
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index b1b0ae8bfeb..58dbaee967d 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -133,32 +133,34 @@ insert-before or insert-after."); bool m_global; }; - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); - - const size_t argc = input.GetArgumentCount(); + 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; int setting_var_idx; for (setting_var_idx = 0; setting_var_idx < static_cast<int>(argc); ++setting_var_idx) { - arg = input.GetArgumentAtIndex(setting_var_idx); + arg = request.GetParsedLine().GetArgumentAtIndex(setting_var_idx); if (arg && arg[0] != '-') break; // We found our setting variable name index } - if (cursor_index == setting_var_idx) { + 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(), match_start_point, max_return_elements, - nullptr, word_complete, matches); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); } else { - arg = input.GetArgumentAtIndex(cursor_index); + arg = + request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()); if (arg) { if (arg[0] == '-') { @@ -166,20 +168,23 @@ insert-before or insert-after."); } else { // Complete setting value const char *setting_var_name = - input.GetArgumentAtIndex(setting_var_idx); + request.GetParsedLine().GetArgumentAtIndex(setting_var_idx); Status error; lldb::OptionValueSP value_sp( 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(), - match_start_point, max_return_elements, - word_complete, matches); + request.GetMatchStartPoint(), + request.GetMaxReturnElements(), + word_complete, request.GetMatches()); + request.SetWordComplete(word_complete); } } } } - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: @@ -272,20 +277,21 @@ public: ~CommandObjectSettingsShow() override = default; - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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(), match_start_point, max_return_elements, nullptr, - word_complete, matches); - return matches.GetSize(); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); + return request.GetMatches().GetSize(); } protected: @@ -345,20 +351,21 @@ public: ~CommandObjectSettingsList() override = default; - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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(), match_start_point, max_return_elements, nullptr, - word_complete, matches); - return matches.GetSize(); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); + return request.GetMatches().GetSize(); } protected: @@ -440,22 +447,23 @@ public: ~CommandObjectSettingsRemove() override = default; - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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 - if (cursor_index < 2) + bool word_complete = request.GetWordComplete(); + if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, - nullptr, word_complete, matches); - return matches.GetSize(); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); + return request.GetMatches().GetSize(); } protected: @@ -562,23 +570,24 @@ public: // !WantsRawCommandString. bool WantsCompletion() override { return true; } - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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 (cursor_index < 2) + if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, - nullptr, word_complete, matches); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: @@ -668,23 +677,24 @@ public: // !WantsRawCommandString. bool WantsCompletion() override { return true; } - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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 (cursor_index < 2) + if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, - nullptr, word_complete, matches); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: @@ -779,23 +789,24 @@ public: // !WantsRawCommandString. bool WantsCompletion() override { return true; } - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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 (cursor_index < 2) + if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, - nullptr, word_complete, matches); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: @@ -879,23 +890,24 @@ public: // !WantsRawCommandString. bool WantsCompletion() override { return true; } - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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 (cursor_index < 2) + if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, - nullptr, word_complete, matches); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: @@ -966,23 +978,24 @@ public: ~CommandObjectSettingsClear() override = default; - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override { - std::string completion_str(input.GetArgumentAtIndex(cursor_index), - cursor_char_position); + 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 (cursor_index < 2) + if (request.GetCursorIndex() < 2) CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, - nullptr, word_complete, matches); + completion_str.c_str(), request.GetMatchStartPoint(), + request.GetMaxReturnElements(), nullptr, word_complete, + request.GetMatches()); + request.SetWordComplete(word_complete); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: |