diff options
Diffstat (limited to 'contrib/llvm-project/lldb/source/Core/IOHandler.cpp')
-rw-r--r-- | contrib/llvm-project/lldb/source/Core/IOHandler.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/contrib/llvm-project/lldb/source/Core/IOHandler.cpp b/contrib/llvm-project/lldb/source/Core/IOHandler.cpp index 6cf09aaa7f9d..8c654d9d8a98 100644 --- a/contrib/llvm-project/lldb/source/Core/IOHandler.cpp +++ b/contrib/llvm-project/lldb/source/Core/IOHandler.cpp @@ -18,6 +18,7 @@ #include "lldb/Host/Config.h" #include "lldb/Host/File.h" #include "lldb/Utility/Predicate.h" +#include "lldb/Utility/ReproducerProvider.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" @@ -102,11 +103,11 @@ FILE *IOHandler::GetErrorFILE() { return (m_error_sp ? m_error_sp->GetFile().GetStream() : nullptr); } -FileSP &IOHandler::GetInputFileSP() { return m_input_sp; } +FileSP IOHandler::GetInputFileSP() { return m_input_sp; } -StreamFileSP &IOHandler::GetOutputStreamFileSP() { return m_output_sp; } +StreamFileSP IOHandler::GetOutputStreamFileSP() { return m_output_sp; } -StreamFileSP &IOHandler::GetErrorStreamFileSP() { return m_error_sp; } +StreamFileSP IOHandler::GetErrorStreamFileSP() { return m_error_sp; } bool IOHandler::GetIsInteractive() { return GetInputFileSP() ? GetInputFileSP()->GetIsInteractive() : false; @@ -195,6 +196,14 @@ void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler, } } +llvm::Optional<std::string> +IOHandlerDelegate::IOHandlerSuggestion(IOHandler &io_handler, + llvm::StringRef line) { + return io_handler.GetDebugger() + .GetCommandInterpreter() + .GetAutoSuggestionForCommand(line); +} + void IOHandlerDelegate::IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request) { switch (m_completion) { @@ -258,6 +267,8 @@ IOHandlerEditline::IOHandlerEditline( m_color_prompts); m_editline_up->SetIsInputCompleteCallback(IsInputCompleteCallback, this); m_editline_up->SetAutoCompleteCallback(AutoCompleteCallback, this); + if (debugger.GetUseAutosuggestion() && debugger.GetUseColor()) + m_editline_up->SetSuggestionCallback(SuggestionCallback, this); // See if the delegate supports fixing indentation const char *indent_chars = delegate.IOHandlerGetFixIndentationCharacters(); if (indent_chars) { @@ -430,6 +441,16 @@ int IOHandlerEditline::FixIndentationCallback(Editline *editline, *editline_reader, lines, cursor_position); } +llvm::Optional<std::string> +IOHandlerEditline::SuggestionCallback(llvm::StringRef line, void *baton) { + IOHandlerEditline *editline_reader = static_cast<IOHandlerEditline *>(baton); + if (editline_reader) + return editline_reader->m_delegate.IOHandlerSuggestion(*editline_reader, + line); + + return llvm::None; +} + void IOHandlerEditline::AutoCompleteCallback(CompletionRequest &request, void *baton) { IOHandlerEditline *editline_reader = (IOHandlerEditline *)baton; |