diff options
Diffstat (limited to 'source/Commands/CommandObjectSettings.cpp')
-rw-r--r-- | source/Commands/CommandObjectSettings.cpp | 212 |
1 files changed, 76 insertions, 136 deletions
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp index d42466cd13b1..f259f2fe200d 100644 --- a/source/Commands/CommandObjectSettings.cpp +++ b/source/Commands/CommandObjectSettings.cpp @@ -133,32 +133,27 @@ 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 { + + const size_t argc = request.GetParsedLine().GetArgumentCount(); const char *arg = nullptr; int setting_var_idx; - for (setting_var_idx = 1; setting_var_idx < static_cast<int>(argc); + 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 CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, - nullptr, word_complete, matches); + request, nullptr); } else { - arg = input.GetArgumentAtIndex(cursor_index); + arg = + request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()); if (arg) { if (arg[0] == '-') { @@ -166,24 +161,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) { - value_sp->AutoComplete(m_interpreter, completion_str.c_str(), - match_start_point, max_return_elements, - word_complete, matches); + value_sp->AutoComplete(m_interpreter, request); } } } } - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: - bool DoExecute(const char *command, CommandReturnObject &result) override { + bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) override { Args cmd_args(command); // Process possible options. @@ -220,10 +214,8 @@ protected: if (error.Success()) { // FIXME this is the same issue as the one in commands script import // we could be setting target.load-script-from-symbol-file which would - // cause - // Python scripts to be loaded, which could run LLDB commands - // (e.g. settings set target.process.python-os-plugin-path) and cause a - // crash + // cause Python scripts to be loaded, which could run LLDB commands (e.g. + // settings set target.process.python-os-plugin-path) and cause a crash // if we did not clear the command's exe_ctx first ExecutionContext exe_ctx(m_exe_ctx); m_exe_ctx.Clear(); @@ -274,20 +266,13 @@ 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 { CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, nullptr, - word_complete, matches); - return matches.GetSize(); + request, nullptr); + return request.GetMatches().GetSize(); } protected: @@ -347,20 +332,13 @@ 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 { CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), match_start_point, max_return_elements, nullptr, - word_complete, matches); - return matches.GetSize(); + request, nullptr); + return request.GetMatches().GetSize(); } protected: @@ -442,26 +420,19 @@ 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); - - // Attempting to complete variable name - if (cursor_index < 2) + int HandleArgumentCompletion( + CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + 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(); + request, nullptr); + return request.GetMatches().GetSize(); } protected: - bool DoExecute(const char *command, CommandReturnObject &result) override { + bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) override { result.SetStatus(eReturnStatusSuccessFinishNoResult); Args cmd_args(command); @@ -564,27 +535,21 @@ 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 { // 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); + request, nullptr); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: - bool DoExecute(const char *command, CommandReturnObject &result) override { + bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) override { result.SetStatus(eReturnStatusSuccessFinishNoResult); Args cmd_args(command); @@ -670,27 +635,21 @@ 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 { // 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); + request, nullptr); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: - bool DoExecute(const char *command, CommandReturnObject &result) override { + bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) override { result.SetStatus(eReturnStatusSuccessFinishNoResult); Args cmd_args(command); @@ -781,27 +740,21 @@ 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 { // 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); + request, nullptr); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: - bool DoExecute(const char *command, CommandReturnObject &result) override { + bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) override { result.SetStatus(eReturnStatusSuccessFinishNoResult); Args cmd_args(command); @@ -881,27 +834,21 @@ 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 { // 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); + request, nullptr); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: - bool DoExecute(const char *command, CommandReturnObject &result) override { + bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) override { result.SetStatus(eReturnStatusSuccessFinishNoResult); Args cmd_args(command); const size_t argc = cmd_args.GetArgumentCount(); @@ -920,8 +867,8 @@ protected: return false; } - // Do not perform cmd_args.Shift() since StringRef is manipulating the - // raw character string later on. + // Do not perform cmd_args.Shift() since StringRef is manipulating the raw + // character string later on. // Split the raw command into var_name and value pair. llvm::StringRef raw_str(command); @@ -968,23 +915,16 @@ 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 { // 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); + request, nullptr); - return matches.GetSize(); + return request.GetMatches().GetSize(); } protected: |