feat(daemon): report editor configuration file presence
This commit is contained in:
1 parent
ca9ad1158a
commit
ba682e8bd1
8 files changed
+127
-2
No files matched your search
@@ -950,6 +950,37 @@ std::string graph_project(const DaemonOptions &options, std::string_view profile
|
||||
",\"graph\":" + Util::json_quote(rendered) + '}';
|
||||
}
|
||||
|
||||
// Reports which editor configuration files are present for the project.
|
||||
std::string ide_configs_project(const DaemonOptions &options) {
|
||||
struct ConfigEntry {
|
||||
std::string_view editor;
|
||||
std::string_view relative_path;
|
||||
};
|
||||
constexpr ConfigEntry entries[] = {
|
||||
{"clangd", ".clangd"},
|
||||
{"vscode", ".vscode/tasks.json"},
|
||||
{"zed", ".zed/tasks.json"},
|
||||
{"clion", ".idea/customTargets.xml"},
|
||||
};
|
||||
|
||||
JsonValue::Array configs;
|
||||
for (const auto &entry : entries) {
|
||||
std::error_code ec;
|
||||
const bool exists = std::filesystem::exists(options.project_root / entry.relative_path, ec);
|
||||
JsonValue::Object item;
|
||||
item.emplace("editor", JsonValue{std::string{entry.editor}});
|
||||
item.emplace("path", JsonValue{std::string{entry.relative_path}});
|
||||
item.emplace("exists", JsonValue{exists});
|
||||
configs.emplace_back(std::move(item));
|
||||
}
|
||||
|
||||
JsonValue::Object object;
|
||||
object.emplace("ok", JsonValue{true});
|
||||
object.emplace("op", JsonValue{std::string{"ide_configs"}});
|
||||
object.emplace("configs", JsonValue{std::move(configs)});
|
||||
return serialize_response(JsonValue{std::move(object)});
|
||||
}
|
||||
|
||||
// Lists declared workspace members without evaluating their build descriptions.
|
||||
std::string workspace_members_project(const DaemonOptions &options) {
|
||||
JsonValue::Object object;
|
||||
@@ -1468,6 +1499,9 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
if (*name == "workspace_members") {
|
||||
return {workspace_members_project(options), false};
|
||||
}
|
||||
if (*name == "ide_configs") {
|
||||
return {ide_configs_project(options), false};
|
||||
}
|
||||
if (*name == "compdb_entries") {
|
||||
std::string file_filter;
|
||||
if (const auto entry = object->find("file"); entry != object->end()) {
|
||||
|
||||
Reference in new issue
Block a user