Serve references from reflection provenance chains
reflection::references_at joins the selected entity's links with every origin elsewhere naming the same entity, deduplicated and bounded, with a registered test. The server serves textDocument/references over a recorded reflection snapshot and advertises referencesProvider when one is loaded. A real stdio session returned the splice and the reflected declaration ranges.
This commit is contained in:
1 parent
5f41870a75
commit
98ddf08eaf
6 files changed
+122
-3
No files matched your search
@@ -528,3 +528,29 @@ VOID_TEST(Reflection, definition_at_prefers_the_reflected_declaration) {
|
||||
expect(target->path == "/p/b.hpp" && target->line == 1);
|
||||
expect(!definition_at(snapshot, "/p/a.cpp", {9, 0}).has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Reflection, references_at_collects_every_link_of_one_entity) {
|
||||
Snapshot snapshot;
|
||||
Entity first = entity("first");
|
||||
first.provenance = chain(
|
||||
{Origin{.kind = OriginKind::splice, .range = range("/p/a.cpp", 4), .entity = "shared"},
|
||||
Origin{.kind = OriginKind::reflected_declaration,
|
||||
.range = range("/p/b.hpp", 1),
|
||||
.entity = "shared"}});
|
||||
Entity second = entity("second");
|
||||
second.provenance = chain(
|
||||
{Origin{.kind = OriginKind::splice, .range = range("/p/c.cpp", 8), .entity = "shared"}});
|
||||
Entity unrelated = entity("unrelated");
|
||||
unrelated.provenance = chain(
|
||||
{Origin{.kind = OriginKind::splice, .range = range("/p/d.cpp", 2), .entity = "other"}});
|
||||
require(snapshot.add(std::move(first)));
|
||||
require(snapshot.add(std::move(second)));
|
||||
require(snapshot.add(std::move(unrelated)));
|
||||
const auto result = references_at(snapshot, "/p/a.cpp", {4, 1});
|
||||
require(result.size() == 3);
|
||||
expect(result[0].path == "/p/a.cpp");
|
||||
expect(result[1].path == "/p/b.hpp");
|
||||
expect(result[2].path == "/p/c.cpp");
|
||||
expect(references_at(snapshot, "/p/a.cpp", {4, 1}, 1).size() == 1);
|
||||
expect(references_at(snapshot, "/p/a.cpp", {9, 0}).empty());
|
||||
}
|
||||
Reference in new issue
Block a user