Fixes #188479. `apropos` was previously only looking at the "name" of the setting, which is the final part of what I as a user think of as the "name" as in the "platform.plugin.something.something-else" form. That that form is in fact the "qualified name". In this change, I've extended apropos to look in the paths of settings, that is the part of the settings name isn't the final name. For example, "qemu-user" will now show a "path" as a result, which you can then look up with "settings list". (the alternative was to apply the search to the qualified name of all settings, but this would result in a lot of results for top level things like "platform") This is the new behaviour: ``` (lldb) apropos qemu-user No commands found pertaining to 'qemu-user'. Try 'help' to see a complete list of debugger commands. The following settings paths may relate to 'qemu-user': platform.plugin.qemu-user (use 'settings list <path>' to show settings with a given path) ``` Then users can do: ``` (lldb) settings list platform.plugin.qemu-user 'platform.plugin.qemu-user' variables: <...> ``` And this is what it looks like for a more common term: ``` (lldb) apropos platform The following commands may relate to 'platform': platform -- Commands to manage and create platforms. <...> The following settings paths may relate to 'platform': platform.plugin.remote-android <...> (use 'settings list <path>' to show settings with a given path) The following settings variables may relate to 'platform': target.auto-install-main-executable -- Always install the main executable when connected to a remote platform. <...> ``` It does not list any `platform.<...>` in the "The following settings" section. The results for settings names are the same as before. Along the way, I fixed a bug in DumpQualifiedName where properties that were groups of other properties would end up putting their name on the end of the qualified name twice.
98 lines
3.2 KiB
C++
98 lines
3.2 KiB
C++
//===-- UserSettingsController.cpp ----------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Core/UserSettingsController.h"
|
|
|
|
#include "lldb/Interpreter/OptionValueProperties.h"
|
|
#include "lldb/Utility/Status.h"
|
|
#include "lldb/Utility/Stream.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace lldb_private {
|
|
class CommandInterpreter;
|
|
}
|
|
namespace lldb_private {
|
|
class ConstString;
|
|
}
|
|
namespace lldb_private {
|
|
class ExecutionContext;
|
|
}
|
|
namespace lldb_private {
|
|
class Property;
|
|
}
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
Properties::Properties() = default;
|
|
|
|
Properties::Properties(const lldb::OptionValuePropertiesSP &collection_sp)
|
|
: m_collection_sp(collection_sp) {}
|
|
|
|
Properties::~Properties() = default;
|
|
|
|
lldb::OptionValueSP
|
|
Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
|
|
llvm::StringRef path, Status &error) const {
|
|
return m_collection_sp->GetSubValue(exe_ctx, path, error);
|
|
}
|
|
|
|
Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
|
|
VarSetOperationType op,
|
|
llvm::StringRef path,
|
|
llvm::StringRef value) {
|
|
return m_collection_sp->SetSubValue(exe_ctx, op, path, value);
|
|
}
|
|
|
|
void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx,
|
|
Stream &strm, uint32_t dump_mask,
|
|
bool is_json) {
|
|
if (is_json) {
|
|
llvm::json::Value json = m_collection_sp->ToJSON(exe_ctx);
|
|
strm << llvm::formatv("{0:2}", json);
|
|
} else
|
|
m_collection_sp->DumpValue(exe_ctx, strm, dump_mask);
|
|
}
|
|
|
|
void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
|
|
Stream &strm) const {
|
|
strm.PutCString("Top level variables:\n\n");
|
|
|
|
return m_collection_sp->DumpAllDescriptions(interpreter, strm);
|
|
}
|
|
|
|
Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
|
|
Stream &strm,
|
|
llvm::StringRef property_path,
|
|
uint32_t dump_mask, bool is_json) {
|
|
return m_collection_sp->DumpPropertyValue(exe_ctx, strm, property_path,
|
|
dump_mask, is_json);
|
|
}
|
|
|
|
void Properties::Apropos(
|
|
llvm::StringRef keyword, std::vector<const Property *> &matching_properties,
|
|
std::vector<const Property *> &matching_property_paths) const {
|
|
m_collection_sp->Apropos(keyword, matching_properties,
|
|
matching_property_paths);
|
|
}
|
|
|
|
llvm::StringRef Properties::GetExperimentalSettingsName() {
|
|
static constexpr llvm::StringLiteral g_experimental("experimental");
|
|
return g_experimental;
|
|
}
|
|
|
|
bool Properties::IsSettingExperimental(llvm::StringRef setting) {
|
|
if (setting.empty())
|
|
return false;
|
|
|
|
llvm::StringRef experimental = GetExperimentalSettingsName();
|
|
size_t dot_pos = setting.find_first_of('.');
|
|
return setting.take_front(dot_pos) == experimental;
|
|
}
|