summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/REPL.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-08-15 13:14:10 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-08-15 13:14:10 +0000
commit2fc20f652cd848abdbfc40b6ae7fc0b0b403ea7d (patch)
tree44d036fe01586ba334cff331edceca798c93799c /lldb/source/Expression/REPL.cpp
parentdc23c832f4f7e5ae8204acfe800bdb611525c8bd (diff)
downloadbcm5719-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/Expression/REPL.cpp')
-rw-r--r--lldb/source/Expression/REPL.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index ffcfc1adf5b..d1e7b71e606 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -433,28 +433,28 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
}
}
-int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line,
- const char *cursor, const char *last_char,
- StringList &matches, StringList &descriptions) {
- matches.Clear();
-
- llvm::StringRef line(current_line, cursor - current_line);
-
+int REPL::IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request) {
// Complete an LLDB command if the first character is a colon...
- if (!line.empty() && line[0] == ':') {
+ if (request.GetRawLine().startswith(":")) {
Debugger &debugger = m_target.GetDebugger();
// auto complete LLDB commands
- const char *lldb_current_line = line.substr(1).data();
- return debugger.GetCommandInterpreter().HandleCompletion(
- lldb_current_line, cursor, last_char, matches, descriptions);
+ llvm::StringRef new_line = request.GetRawLine().drop_front();
+ CompletionResult sub_result;
+ CompletionRequest sub_request(new_line, request.GetRawCursorPos() - 1,
+ sub_result);
+ int result = debugger.GetCommandInterpreter().HandleCompletion(sub_request);
+ StringList matches, descriptions;
+ sub_result.GetMatches(matches);
+ sub_result.GetDescriptions(descriptions);
+ request.AddCompletions(matches, descriptions);
+ return result;
}
// Strip spaces from the line and see if we had only spaces
- line = line.ltrim();
- if (line.empty()) {
+ if (request.GetRawLineUntilCursor().trim().empty()) {
// Only spaces on this line, so just indent
- matches.AppendString(m_indent_str);
+ request.AddCompletion(m_indent_str);
return 1;
}
@@ -477,12 +477,13 @@ int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line,
}
}
- if (cursor > current_line) {
- current_code.append("\n");
- current_code.append(current_line, cursor - current_line);
- }
+ current_code.append("\n");
+ current_code += request.GetRawLineUntilCursor();
- return CompleteCode(current_code, matches);
+ StringList matches;
+ int result = CompleteCode(current_code, matches);
+ request.AddCompletions(matches);
+ return result;
}
bool QuitCommandOverrideCallback(void *baton, const char **argv) {
OpenPOWER on IntegriCloud