feat(daemon): report editor configuration file presence
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 12s

This commit is contained in:
faumaray committed 2026-12-03 23:34:42 +03:00
1 parent ca9ad1158a
commit ba682e8bd1
8 files changed
+127 -2

No files matched your search

+34
View File
@@ -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()) {
+8
View File
@@ -1567,6 +1567,8 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
request_json = R"({"op":"editor_status"})";
} else if (sub == "workspace_members") {
request_json = R"({"op":"workspace_members"})";
} else if (sub == "ide_configs") {
request_json = R"({"op":"ide_configs"})";
} else if (sub == "compdb_entries") {
request_json =
std::format(R"({{"op":"compdb_entries","limit":{}{}}})", opts.limit_arg,
@@ -2690,6 +2692,9 @@ int main(int argc, char **argv) {
auto &daemon_ide_status_cmd =
daemon_ide_cmd.subcommand("status", "Report the active editor selection and compdb state");
configure_daemon_common(daemon_ide_status_cmd);
auto &daemon_ide_configs_cmd =
daemon_ide_cmd.subcommand("configs", "Report which editor configuration files exist");
configure_daemon_common(daemon_ide_configs_cmd);
auto &daemon_ide_poll_cmd = daemon_ide_cmd.subcommand(
"poll", "Poll pending project file changes (editor extension protocol)");
configure_daemon_common(daemon_ide_poll_cmd);
@@ -2831,6 +2836,9 @@ int main(int argc, char **argv) {
} else if (daemon_sub == "workspace" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "members") {
daemon_sub = "workspace_members";
} else if (daemon_sub == "ide" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "configs") {
daemon_sub = "ide_configs";
}
return execute_daemon_command(daemon_sub, daemon_opts);
}