diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-08-15 13:14:10 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-08-15 13:14:10 +0000 |
commit | 2fc20f652cd848abdbfc40b6ae7fc0b0b403ea7d (patch) | |
tree | 44d036fe01586ba334cff331edceca798c93799c /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | dc23c832f4f7e5ae8204acfe800bdb611525c8bd (diff) | |
download | bcm5719-llvm-2fc20f652cd848abdbfc40b6ae7fc0b0b403ea7d.tar.gz bcm5719-llvm-2fc20f652cd848abdbfc40b6ae7fc0b0b403ea7d.zip |
[lldb][NFC] Refactor remaining completion logic to use CompletionRequests
This patch moves the remaining completion functions from the
old completion API (that used several variables) to just
passing a single CompletionRequest.
This is for the most part a simple change as we just replace
the old arguments with a single CompletionRequest argument.
There are a few places where I had to create new CompletionRequests
in the called functions as CompletionRequests itself are immutable
and don't expose their internal match list anymore. This means that
if a function wanted to change the CompletionRequest or directly
access the result list, we need to work around this by creating
a new CompletionRequest and a temporary match/description list.
Preparation work for rdar://53769355
llvm-svn: 369000
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 114316ab264..86cca78241e 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1814,18 +1814,16 @@ int CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) { return num_command_matches; } -int CommandInterpreter::HandleCompletion(const char *current_line, - const char *cursor, - const char *last_char, - StringList &matches, - StringList &descriptions) { - - llvm::StringRef command_line(current_line, last_char - current_line); +int CommandInterpreter::HandleCompletion(CompletionRequest &orig_request) { + // Start a new subrequest we can modify. CompletionResult result; - CompletionRequest request(command_line, cursor - current_line, result); + CompletionRequest request(orig_request.GetRawLine(), + orig_request.GetRawCursorPos(), result); // Don't complete comments, and if the line we are completing is just the // history repeat character, substitute the appropriate history line. const char *first_arg = request.GetParsedLine().GetArgumentAtIndex(0); + StringList matches, descriptions; + if (first_arg) { if (first_arg[0] == m_comment_char) return 0; @@ -1872,6 +1870,8 @@ int CommandInterpreter::HandleCompletion(const char *current_line, matches.InsertStringAtIndex(0, common_prefix.c_str()); descriptions.InsertStringAtIndex(0, ""); } + // Add completion to original request. + orig_request.AddCompletions(matches, descriptions); return num_command_matches; } |