Native VBS and CMake builds of the server and every registered suite: protocol and document sync, VBS/compdb providers, stock GCC diagnostics (including in-process default profile preparation), the stock occurrence observer and hover/definition, the bounded Scheduler, C++ module graph, scan and artifact cache with real CMI production, the context-aware symbol index with schema-2 snapshot migration, navigation and guarded rename, reflection provenance with splice-origin extraction, index-backed completion and signature help, live GCC worker control with a registered DAP suite, and the Neovim and VS Code clients. VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced from the versioned patches and verified stepping reflection/template code with projected values 17/34 and 41/82.
94 lines
3.7 KiB
C++
94 lines
3.7 KiB
C++
#pragma once
|
|
|
|
#include <Void/LanguageServer/Build/Providers.hpp>
|
|
#include <Void/System/TempDir.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
|
|
#include <fstream>
|
|
|
|
namespace provider_test {
|
|
namespace fs = std::filesystem;
|
|
namespace Build = Void::LanguageServer::Build;
|
|
namespace Protocol = Void::LanguageServer::Protocol;
|
|
using Protocol::Json;
|
|
|
|
inline Json str(std::string_view text) { return Json{std::string{text}}; }
|
|
|
|
inline void write_bytes(const fs::path &path, std::string_view bytes) {
|
|
fs::create_directories(path.parent_path());
|
|
std::ofstream file(path, std::ios::binary);
|
|
file << bytes;
|
|
file.close();
|
|
Void::Testing::require(file.good());
|
|
}
|
|
|
|
inline void write_json(const fs::path &path, const Json &json) {
|
|
auto bytes = Protocol::serialize_json(json);
|
|
Void::Testing::require(bytes.has_value());
|
|
write_bytes(path, *bytes);
|
|
}
|
|
|
|
struct Fixture {
|
|
Void::FileSystem::TempDir tmp{"vls_build_provider_"};
|
|
fs::path root = fs::canonical(tmp.path());
|
|
fs::path build = root / "out", selector = root / ".vbs/editor_selection.json";
|
|
fs::path source = root / "main.cpp", compdb = root / "compile_commands.json";
|
|
Build::ProviderScope scope{.workspace = {root, "test-editor"}};
|
|
static constexpr std::string_view first = "0123456789abcdef", second = "fedcba9876543210";
|
|
|
|
Fixture() {
|
|
fs::create_directories(build);
|
|
write_bytes(source, "int main() {}\n");
|
|
}
|
|
void bind() {
|
|
auto pinned = Build::bind_provider_scope(scope);
|
|
Void::Testing::require(pinned.has_value());
|
|
scope = std::move(*pinned);
|
|
}
|
|
Json::Array rows() const {
|
|
Json::Array entries;
|
|
for (auto flag : {"-DVALUE=1", "-DVALUE=2"}) {
|
|
entries.push_back(Json{Json::Object{
|
|
{"directory", str(root.string())},
|
|
{"file", str("main.cpp")},
|
|
{"output", str("main.o")},
|
|
{"arguments", Json{Json::Array{str("c++"), str("-std=c++26"), str(flag), str("-c"),
|
|
str("main.cpp"), str("-o"), str("main.o")}}}}});
|
|
}
|
|
return entries;
|
|
}
|
|
fs::path editor(std::string_view slug = "debug") const {
|
|
return build / "profiles" / slug / "editor";
|
|
}
|
|
fs::path database(std::string_view id = first, std::string_view slug = "debug") const {
|
|
return editor(slug) / "generations" / id / "compile_commands.json";
|
|
}
|
|
Json::Object selection(std::string_view id = first, std::string_view profile = "debug") const {
|
|
return {{"schema_version", Json{std::int64_t{1}}},
|
|
{"ticket", Json{std::int64_t{7}}},
|
|
{"selected_profile", str(profile)},
|
|
{"selected_build_root", str(build.string())},
|
|
{"selected_generation_id", str(id)},
|
|
{"selected_compdb_path", str(database(id).string())},
|
|
{"managed_root_alias_active", Json{false}},
|
|
{"root_alias_warning", str("")}};
|
|
}
|
|
Json::Object valid_status(std::string_view id = first,
|
|
std::string_view profile = "debug") const {
|
|
return {{"schema_version", Json{std::int64_t{1}}},
|
|
{"profile", str(profile)},
|
|
{"generation_id", str(id)},
|
|
{"status", str("valid")},
|
|
{"diagnostic", str("")},
|
|
{"compdb_path", str(database(id).string())},
|
|
{"entry_count", Json{std::int64_t{2}}},
|
|
{"readiness_warnings", Json{Json::Array{str("generated input pending")}}}};
|
|
}
|
|
void publish(std::string_view id = first) const {
|
|
write_json(database(id), Json{rows()});
|
|
write_json(editor() / "status.json", Json{valid_status(id)});
|
|
write_json(selector, Json{selection(id)});
|
|
}
|
|
};
|
|
} // namespace provider_test
|