Serve definition from reflection provenance chains
reflection::definition_at returns the innermost covering entity's first reflected-declaration link (else its first chain link), with a registered test. The server serves textDocument/definition over a recorded reflection snapshot and now advertises hover and definition whenever a snapshot is loaded, not only with the occurrence observer. A real stdio session resolved the splice site to the reflected declaration range.
This commit is contained in:
1 parent
1f01bcbfd5
commit
7e3ce6fc6c
6 files changed
+109
-9
No files matched your search
@@ -514,3 +514,17 @@ VOID_TEST(Reflection, hover_at_selects_the_innermost_covering_entity) {
|
||||
expect(!hover_at(snapshot, "/p/a.cpp", {9, 0}).has_value());
|
||||
expect(!hover_at(snapshot, "/p/b.cpp", {5, 6}).has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Reflection, definition_at_prefers_the_reflected_declaration) {
|
||||
Snapshot snapshot;
|
||||
Entity node = entity("node");
|
||||
node.name = "node";
|
||||
node.provenance =
|
||||
chain({Origin{.kind = OriginKind::splice, .range = range("/p/a.cpp", 4)},
|
||||
Origin{.kind = OriginKind::reflected_declaration, .range = range("/p/b.hpp", 1)}});
|
||||
require(snapshot.add(std::move(node)));
|
||||
const auto target = definition_at(snapshot, "/p/a.cpp", {4, 1});
|
||||
require(target.has_value());
|
||||
expect(target->path == "/p/b.hpp" && target->line == 1);
|
||||
expect(!definition_at(snapshot, "/p/a.cpp", {9, 0}).has_value());
|
||||
}
|
||||
Reference in new issue
Block a user