diff options
Diffstat (limited to 'lldb/source/Interpreter/CommandAlias.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandAlias.cpp | 111 |
1 files changed, 110 insertions, 1 deletions
diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index ffdb3e92ad5..eba5cb5d17a 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -85,11 +85,18 @@ CommandAlias::CommandAlias (CommandInterpreter &interpreter, syntax, flags), m_underlying_command_sp(), -m_option_args_sp(new OptionArgVector) +m_option_args_sp(new OptionArgVector), +m_is_dashdash_alias(eLazyBoolCalculate) { if (ProcessAliasOptionsArgs(cmd_sp, options_args, m_option_args_sp)) { m_underlying_command_sp = cmd_sp; + for (int i = 0; + auto cmd_entry = m_underlying_command_sp->GetArgumentEntryAtIndex(i); + i++) + { + m_arguments.push_back(*cmd_entry); + } if (!help || !help[0]) { StreamString sstr; @@ -111,6 +118,64 @@ CommandAlias::WantsRawCommandString() } bool +CommandAlias::WantsCompletion() +{ + if (IsValid()) + return m_underlying_command_sp->WantsCompletion(); + return false; +} + +int +CommandAlias::HandleCompletion (Args &input, + int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + if (IsValid()) + return m_underlying_command_sp->HandleCompletion(input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + word_complete, + matches); + return -1; +} + +int +CommandAlias::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) +{ + if (IsValid()) + return m_underlying_command_sp->HandleArgumentCompletion(input, + cursor_index, + cursor_char_position, + opt_element_vector, + match_start_point, + max_return_elements, + word_complete, + matches); + return -1; +} + +Options* +CommandAlias::GetOptions() +{ + if (IsValid()) + return m_underlying_command_sp->GetOptions(); + return nullptr; +} + +bool CommandAlias::Execute(const char *args_string, CommandReturnObject &result) { llvm_unreachable("CommandAlias::Execute is not to be called"); @@ -149,3 +214,47 @@ CommandAlias::GetAliasExpansion (StreamString &help_string) help_string.Printf ("'"); } + +bool +CommandAlias::IsDashDashCommand () +{ + if (m_is_dashdash_alias == eLazyBoolCalculate) + { + m_is_dashdash_alias = eLazyBoolNo; + if (IsValid()) + { + for (const OptionArgPair& opt_arg : *GetOptionArguments()) + { + if (opt_arg.first == "<argument>" && + opt_arg.second.second == " --") + { + m_is_dashdash_alias = eLazyBoolYes; + break; + } + } + } + } + return (m_is_dashdash_alias == eLazyBoolYes); +} + +// allow CommandAlias objects to provide their own help, but fallback to the info +// for the underlying command if no customization has been provided +const char* +CommandAlias::GetHelp () +{ + if (!m_cmd_help_short.empty()) + return m_cmd_help_short.c_str(); + if (IsValid()) + return m_underlying_command_sp->GetHelp(); + return nullptr; +} + +const char* +CommandAlias::GetHelpLong () +{ + if (!m_cmd_help_long.empty()) + return m_cmd_help_long.c_str(); + if (IsValid()) + return m_underlying_command_sp->GetHelpLong(); + return nullptr; +} |