[Lldb-commits] [lldb] r369252 - [lldb][NFC] Use CompletionRequest in Variable::AutoComplete
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 19 04:49:43 PDT 2019
Author: teemperor
Date: Mon Aug 19 04:49:43 2019
New Revision: 369252
URL: http://llvm.org/viewvc/llvm-project?rev=369252&view=rev
Log:
[lldb][NFC] Use CompletionRequest in Variable::AutoComplete
Modified:
lldb/trunk/source/Symbol/Variable.cpp
Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=369252&r1=369251&r2=369252&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Mon Aug 19 04:49:43 2019
@@ -488,24 +488,21 @@ static void PrivateAutoComplete(
StackFrame *frame, llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete);
+ const CompilerType &compiler_type, CompletionRequest &request);
static void PrivateAutoCompleteMembers(
StackFrame *frame, const std::string &partial_member_name,
llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete);
+ const CompilerType &compiler_type, CompletionRequest &request);
static void PrivateAutoCompleteMembers(
StackFrame *frame, const std::string &partial_member_name,
llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete) {
+ const CompilerType &compiler_type, CompletionRequest &request) {
// We are in a type parsing child members
const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
@@ -515,9 +512,9 @@ static void PrivateAutoCompleteMembers(
CompilerType base_class_type =
compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
- PrivateAutoCompleteMembers(
- frame, partial_member_name, partial_path, prefix_path,
- base_class_type.GetCanonicalType(), matches, word_complete);
+ PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
+ prefix_path,
+ base_class_type.GetCanonicalType(), request);
}
}
@@ -528,9 +525,9 @@ static void PrivateAutoCompleteMembers(
CompilerType vbase_class_type =
compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
- PrivateAutoCompleteMembers(
- frame, partial_member_name, partial_path, prefix_path,
- vbase_class_type.GetCanonicalType(), matches, word_complete);
+ PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
+ prefix_path,
+ vbase_class_type.GetCanonicalType(), request);
}
}
@@ -551,9 +548,9 @@ static void PrivateAutoCompleteMembers(
frame, partial_path,
prefix_path + member_name, // Anything that has been resolved
// already will be in here
- member_compiler_type.GetCanonicalType(), matches, word_complete);
+ member_compiler_type.GetCanonicalType(), request);
} else {
- matches.AppendString((prefix_path + member_name).str());
+ request.AddCompletion((prefix_path + member_name).str());
}
}
}
@@ -564,8 +561,7 @@ static void PrivateAutoComplete(
StackFrame *frame, llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete) {
+ const CompilerType &compiler_type, CompletionRequest &request) {
// printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
// '%s'\n", prefix_path.c_str(), partial_path.c_str());
std::string remaining_partial_path;
@@ -586,15 +582,15 @@ static void PrivateAutoComplete(
case eTypeClassReference:
case eTypeClassTypedef:
case eTypeClassVector: {
- matches.AppendString(prefix_path.str());
- word_complete = matches.GetSize() == 1;
+ request.AddCompletion(prefix_path.str());
+ request.SetWordComplete(true);
} break;
case eTypeClassClass:
case eTypeClassStruct:
case eTypeClassUnion:
if (prefix_path.str().back() != '.')
- matches.AppendString((prefix_path + ".").str());
+ request.AddCompletion((prefix_path + ".").str());
break;
case eTypeClassObjCObject:
@@ -604,10 +600,10 @@ static void PrivateAutoComplete(
case eTypeClassPointer: {
bool omit_empty_base_classes = true;
if (compiler_type.GetNumChildren(omit_empty_base_classes, nullptr) > 0)
- matches.AppendString((prefix_path + "->").str());
+ request.AddCompletion((prefix_path + "->").str());
else {
- matches.AppendString(prefix_path.str());
- word_complete = true;
+ request.AddCompletion(prefix_path.str());
+ request.SetWordComplete(true);
}
} break;
}
@@ -621,7 +617,7 @@ static void PrivateAutoComplete(
const size_t num_variables = variable_list->GetSize();
for (size_t i = 0; i < num_variables; ++i) {
Variable *variable = variable_list->GetVariableAtIndex(i).get();
- matches.AppendString(variable->GetName().AsCString());
+ request.AddCompletion(variable->GetName().AsCString());
}
}
}
@@ -632,14 +628,14 @@ static void PrivateAutoComplete(
case '*':
if (prefix_path.str().empty()) {
PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
- matches, word_complete);
+ request);
}
break;
case '&':
if (prefix_path.isTriviallyEmpty()) {
PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
- compiler_type, matches, word_complete);
+ compiler_type, request);
}
break;
@@ -651,14 +647,14 @@ static void PrivateAutoComplete(
CompilerType pointee_type(compiler_type.GetPointeeType());
if (partial_path.size() > 2 && partial_path[2]) {
// If there is more after the "->", then search deeper
- PrivateAutoComplete(
- frame, partial_path.substr(2), prefix_path + "->",
- pointee_type.GetCanonicalType(), matches, word_complete);
+ PrivateAutoComplete(frame, partial_path.substr(2),
+ prefix_path + "->",
+ pointee_type.GetCanonicalType(), request);
} else {
// Nothing after the "->", so list all members
PrivateAutoCompleteMembers(
frame, std::string(), std::string(), prefix_path + "->",
- pointee_type.GetCanonicalType(), matches, word_complete);
+ pointee_type.GetCanonicalType(), request);
}
} break;
default:
@@ -676,14 +672,13 @@ static void PrivateAutoComplete(
if (partial_path.size() > 1 && partial_path[1]) {
// If there is more after the ".", then search deeper
PrivateAutoComplete(frame, partial_path.substr(1),
- prefix_path + ".", compiler_type, matches,
- word_complete);
+ prefix_path + ".", compiler_type, request);
} else {
// Nothing after the ".", so list all members
PrivateAutoCompleteMembers(frame, std::string(), partial_path,
prefix_path + ".", compiler_type,
- matches, word_complete);
+ request);
}
break;
default:
@@ -709,8 +704,7 @@ static void PrivateAutoComplete(
if (compiler_type.IsValid()) {
PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
- prefix_path, compiler_type, matches,
- word_complete);
+ prefix_path, compiler_type, request);
} else if (frame) {
// We haven't found our variable yet
const bool get_file_globals = true;
@@ -739,13 +733,12 @@ static void PrivateAutoComplete(
frame, remaining_partial_path,
prefix_path + token, // Anything that has been resolved
// already will be in here
- variable_compiler_type.GetCanonicalType(), matches,
- word_complete);
+ variable_compiler_type.GetCanonicalType(), request);
} else {
- matches.AppendString((prefix_path + variable_name).str());
+ request.AddCompletion((prefix_path + variable_name).str());
}
} else if (remaining_partial_path.empty()) {
- matches.AppendString((prefix_path + variable_name).str());
+ request.AddCompletion((prefix_path + variable_name).str());
}
}
}
@@ -760,12 +753,8 @@ size_t Variable::AutoComplete(const Exec
CompletionRequest &request) {
CompilerType compiler_type;
- bool word_complete = false;
- StringList matches;
PrivateAutoComplete(exe_ctx.GetFramePtr(), request.GetCursorArgumentPrefix(),
- "", compiler_type, matches, word_complete);
- request.SetWordComplete(word_complete);
- request.AddCompletions(matches);
+ "", compiler_type, request);
return request.GetNumberOfMatches();
}
More information about the lldb-commits
mailing list