Implement the VLS roadmap on the native VBS build
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.
This commit is contained in:
1 parent
ca04975d54
commit
da8003f6d4
310 files changed
+47552
-480
No files matched your search
@@ -0,0 +1,183 @@
|
||||
#include <vls/navigation/Navigation.hpp>
|
||||
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
using namespace vls::navigation;
|
||||
using Void::Testing::expect;
|
||||
using Void::Testing::require;
|
||||
|
||||
Location location(std::string path, std::uint32_t line) {
|
||||
return {std::move(path), Range{{line, 0}, {line, 4}}};
|
||||
}
|
||||
|
||||
Fact fact(std::string name, std::optional<Location> definition, std::string context,
|
||||
std::string source, std::uint32_t line, bool editable = true) {
|
||||
return {Binding{std::move(name), std::move(definition)},
|
||||
std::move(context),
|
||||
std::move(source),
|
||||
"content-1",
|
||||
Range{{line, 0}, {line, 4}},
|
||||
editable,
|
||||
"gcc"};
|
||||
}
|
||||
|
||||
FactSet set(std::vector<Fact> facts, bool complete = true) {
|
||||
FactSet result;
|
||||
result.facts = std::move(facts);
|
||||
result.contexts = {{"debug:unit", complete, complete ? "" : "system headers"}};
|
||||
for (const auto &item : result.facts)
|
||||
result.current_sources[item.source] = item.content;
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
VOID_TEST(Navigation, resolves_unique_binding) {
|
||||
const auto facts = set({fact("f", std::nullopt, "debug:unit", "/project/unit.cpp", 3)});
|
||||
const auto binding = binding_at(facts, "/project/unit.cpp", {3, 1});
|
||||
require(binding.has_value());
|
||||
expect(binding->name == "f");
|
||||
expect(!binding_at(facts, "/project/unit.cpp", {9, 0}).has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, distinguishes_same_spelling_by_definition) {
|
||||
const auto first = location("/project/a.hpp", 1), second = location("/project/b.hpp", 2);
|
||||
const auto facts = set({fact("f", first, "debug:a", "/project/a.cpp", 3),
|
||||
fact("f", second, "debug:b", "/project/b.cpp", 3)});
|
||||
const auto a = binding_at(facts, "/project/a.cpp", {3, 0});
|
||||
const auto b = binding_at(facts, "/project/b.cpp", {3, 0});
|
||||
require(a.has_value() && b.has_value());
|
||||
expect(a->definition == first && b->definition == second && !(a == b));
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, ambiguous_overlapping_bindings_are_not_resolved_by_order) {
|
||||
const auto facts =
|
||||
set({fact("f", location("/project/a.hpp", 1), "debug:a", "/project/u.cpp", 3),
|
||||
fact("f", location("/project/b.hpp", 1), "debug:b", "/project/u.cpp", 3)});
|
||||
const auto binding = binding_at(facts, "/project/u.cpp", {3, 0});
|
||||
require(!binding.has_value());
|
||||
expect(binding.error() == Refusal::ambiguous_binding);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, references_are_deduplicated_and_sorted) {
|
||||
const auto definition = location("/project/a.hpp", 1);
|
||||
const auto facts = set({fact("f", definition, "debug:a", "/project/a.cpp", 5),
|
||||
fact("f", definition, "debug:a", "/project/a.cpp", 5),
|
||||
fact("f", definition, "debug:b", "/project/b.cpp", 2)});
|
||||
const auto binding = Binding{"f", definition};
|
||||
const auto result = references(facts, binding);
|
||||
require(result.coverage_complete && !result.truncated);
|
||||
require(result.locations.size() == 2);
|
||||
expect(result.locations[0] == (Location{"/project/a.cpp", {{5, 0}, {5, 4}}}));
|
||||
expect(result.locations[1].path == "/project/b.cpp");
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, references_report_incomplete_coverage) {
|
||||
const auto facts = set({fact("f", std::nullopt, "debug:unit", "/project/unit.cpp", 3)}, false);
|
||||
const auto result = references(facts, Binding{"f", std::nullopt});
|
||||
expect(!result.coverage_complete);
|
||||
expect(result.incomplete_contexts == std::vector<std::string>{"debug:unit"});
|
||||
expect(result.locations.size() == 1);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, references_truncate) {
|
||||
std::vector<Fact> facts;
|
||||
for (std::uint32_t line = 0; line != 5; ++line)
|
||||
facts.push_back(fact("f", std::nullopt, "debug:unit", "/project/unit.cpp", line));
|
||||
const auto result = references(set(std::move(facts)), Binding{"f", std::nullopt}, 2);
|
||||
expect(result.locations.size() == 2 && result.truncated);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_is_ready_for_one_transactional_file) {
|
||||
const auto definition = location("/project/a.hpp", 1);
|
||||
const auto facts = set({fact("f", definition, "debug:a", "/project/a.cpp", 5),
|
||||
fact("f", definition, "debug:b", "/project/b.cpp", 2)});
|
||||
const auto plan = prepare_rename(facts, "/project/a.cpp", {5, 0}, "renamed", true);
|
||||
require(plan.ready());
|
||||
require(plan.edits.size() == 2);
|
||||
expect(plan.edits[0].path == "/project/a.cpp" && plan.edits[0].replacement == "renamed");
|
||||
expect(plan.edits[1].path == "/project/b.cpp");
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_refuses_incomplete_coverage) {
|
||||
const auto facts = set({fact("f", std::nullopt, "debug:unit", "/project/unit.cpp", 3)}, false);
|
||||
const auto plan = prepare_rename(facts, "/project/unit.cpp", {3, 0}, "renamed", true);
|
||||
expect(plan.refusal == Refusal::incomplete_coverage && !plan.ready());
|
||||
expect(plan.detail.contains("system headers"));
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_refuses_a_stale_source) {
|
||||
auto facts = set({fact("f", std::nullopt, "debug:unit", "/project/unit.cpp", 3)});
|
||||
facts.current_sources["/project/unit.cpp"] = "content-2";
|
||||
const auto plan = prepare_rename(facts, "/project/unit.cpp", {3, 0}, "renamed", true);
|
||||
expect(plan.refusal == Refusal::stale_source);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_refuses_a_non_editable_origin) {
|
||||
const auto facts =
|
||||
set({fact("f", std::nullopt, "debug:unit", "/toolchain/header.hpp", 3, false)});
|
||||
const auto plan = prepare_rename(facts, "/toolchain/header.hpp", {3, 0}, "renamed", true);
|
||||
expect(plan.refusal == Refusal::non_editable_origin);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_refuses_multi_file_without_a_transaction) {
|
||||
const auto definition = location("/project/a.hpp", 1);
|
||||
const auto facts = set({fact("f", definition, "debug:a", "/project/a.cpp", 5),
|
||||
fact("f", definition, "debug:b", "/project/b.cpp", 2)});
|
||||
expect(prepare_rename(facts, "/project/a.cpp", {5, 0}, "renamed", false).refusal ==
|
||||
Refusal::multi_file_without_transaction);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_refuses_invalid_generated_and_unchanged_names) {
|
||||
const auto facts = set({fact("f", std::nullopt, "debug:unit", "/project/unit.cpp", 3)});
|
||||
expect(prepare_rename(facts, "/project/unit.cpp", {3, 0}, "1bad", true).refusal ==
|
||||
Refusal::invalid_name);
|
||||
expect(prepare_rename(facts, "/project/unit.cpp", {3, 0}, "f$generated", true).refusal ==
|
||||
Refusal::invalid_name);
|
||||
expect(prepare_rename(facts, "/project/unit.cpp", {3, 0}, "f", true).refusal ==
|
||||
Refusal::unchanged_name);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_refuses_an_unknown_binding) {
|
||||
const auto facts = set({fact("f", std::nullopt, "debug:unit", "/project/unit.cpp", 3)});
|
||||
expect(prepare_rename(facts, "/project/unit.cpp", {9, 0}, "renamed", true).refusal ==
|
||||
Refusal::unknown_binding);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, references_and_rename_cover_other_contexts) {
|
||||
const auto definition = location("/project/shared.hpp", 1);
|
||||
auto facts = set({fact("f", definition, "debug:a", "/project/a.cpp", 5),
|
||||
fact("f", definition, "debug:b", "/project/b.cpp", 2)});
|
||||
facts.contexts.push_back({"debug:b", true, ""});
|
||||
const auto binding = Binding{"f", definition};
|
||||
const auto result = references(facts, binding);
|
||||
expect(result.coverage_complete && result.locations.size() == 2);
|
||||
const auto plan = prepare_rename(facts, "/project/a.cpp", {5, 0}, "renamed", true);
|
||||
require(plan.ready());
|
||||
expect(plan.edits.size() == 2);
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, rename_refuses_when_another_context_is_incomplete) {
|
||||
const auto definition = location("/project/shared.hpp", 1);
|
||||
auto facts = set({fact("f", definition, "debug:a", "/project/a.cpp", 5),
|
||||
fact("f", definition, "debug:b", "/project/b.cpp", 2)});
|
||||
facts.contexts.push_back({"debug:b", false, "system headers"});
|
||||
const auto plan = prepare_rename(facts, "/project/a.cpp", {5, 0}, "renamed", true);
|
||||
expect(plan.refusal == Refusal::incomplete_coverage);
|
||||
expect(plan.detail.contains("debug:b"));
|
||||
}
|
||||
|
||||
VOID_TEST(Navigation, other_context_same_spelling_binding_is_not_renamed) {
|
||||
const auto first = location("/project/a.hpp", 1), second = location("/project/b.hpp", 2);
|
||||
auto facts = set({fact("f", first, "debug:a", "/project/a.cpp", 5),
|
||||
fact("f", second, "debug:b", "/project/b.cpp", 2)});
|
||||
facts.contexts.push_back({"debug:b", true, ""});
|
||||
const auto plan = prepare_rename(facts, "/project/a.cpp", {5, 0}, "renamed", true);
|
||||
require(plan.ready());
|
||||
expect(plan.edits.size() == 1 && plan.edits[0].path == "/project/a.cpp");
|
||||
}
|
||||
Reference in new issue
Block a user