feat(daemon): list workspace members without evaluating them
This commit is contained in:
1 parent
8f68ec56e9
commit
ca9ad1158a
8 files changed
+102
-2
No files matched your search
@@ -950,6 +950,32 @@ std::string graph_project(const DaemonOptions &options, std::string_view profile
|
||||
",\"graph\":" + Util::json_quote(rendered) + '}';
|
||||
}
|
||||
|
||||
// Lists declared workspace members without evaluating their build descriptions.
|
||||
std::string workspace_members_project(const DaemonOptions &options) {
|
||||
JsonValue::Object object;
|
||||
object.emplace("ok", JsonValue{true});
|
||||
object.emplace("op", JsonValue{std::string{"workspace_members"}});
|
||||
if (!Config::is_workspace_root(options.project_root)) {
|
||||
object.emplace("workspace", JsonValue{false});
|
||||
object.emplace("members", JsonValue{JsonValue::Array{}});
|
||||
return serialize_response(JsonValue{std::move(object)});
|
||||
}
|
||||
auto members = evaluate_workspace_members(options);
|
||||
if (!members) {
|
||||
return error_response(members.error());
|
||||
}
|
||||
JsonValue::Array member_array;
|
||||
for (const auto &member : *members) {
|
||||
JsonValue::Object entry;
|
||||
entry.emplace("name", JsonValue{member.name});
|
||||
entry.emplace("path", JsonValue{member.path.string()});
|
||||
member_array.emplace_back(std::move(entry));
|
||||
}
|
||||
object.emplace("workspace", JsonValue{true});
|
||||
object.emplace("members", JsonValue{std::move(member_array)});
|
||||
return serialize_response(JsonValue{std::move(object)});
|
||||
}
|
||||
|
||||
// Returns bounded compile_commands entries from the active compilation database, optionally
|
||||
// filtered by a path suffix. Editor extensions use this instead of parsing the file themselves.
|
||||
std::string compdb_entries_project(const DaemonOptions &options, std::string_view file_filter,
|
||||
@@ -1439,6 +1465,9 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
if (*name == "editor_status") {
|
||||
return {editor_status_project(options), false};
|
||||
}
|
||||
if (*name == "workspace_members") {
|
||||
return {workspace_members_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