Reimplemented the code that backed the "settings" in lldb. There were many issues with the previous implementation:
- no setting auto completion
- very manual and error prone way of getting/setting variables
- tons of code duplication
- useless instance names for processes, threads
Now settings can easily be defined like option values. The new settings makes use of the "OptionValue" classes so we can re-use the option value code that we use to set settings in command options. No more instances, just "does the right thing".
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@162366 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp
index dbeb564..bb8b8aa 100644
--- a/source/Commands/CommandCompletions.cpp
+++ b/source/Commands/CommandCompletions.cpp
@@ -405,15 +405,30 @@
bool &word_complete,
StringList &matches)
{
- lldb::UserSettingsControllerSP root_settings = Debugger::GetSettingsController();
- Args partial_setting_name_pieces = UserSettingsController::BreakNameIntoPieces (partial_setting_name);
-
- return UserSettingsController::CompleteSettingsNames (root_settings,
- partial_setting_name_pieces,
- word_complete,
- matches);
-
- //return matches.GetSize();
+ // Cache the full setting name list
+ static StringList g_property_names;
+ if (g_property_names.GetSize() == 0)
+ {
+ // Generate the full setting name list on demand
+ lldb::OptionValuePropertiesSP properties_sp (interpreter.GetDebugger().GetValueProperties());
+ if (properties_sp)
+ {
+ StreamString strm;
+ properties_sp->DumpValue(NULL, strm, OptionValue::eDumpOptionName);
+ const std::string &str = strm.GetString();
+ g_property_names.SplitIntoLines(str.c_str(), str.size());
+ }
+ }
+
+ size_t exact_matches_idx = SIZE_MAX;
+ const size_t num_matches = g_property_names.AutoComplete (partial_setting_name, matches, exact_matches_idx);
+// return UserSettingsController::CompleteSettingsNames (root_settings,
+// partial_setting_name_pieces,
+// word_complete,
+// matches);
+//
+ word_complete = exact_matches_idx != SIZE_MAX;
+ return num_matches;
}