Serve reflection hover from a recorded snapshot
Per the user's decision, the launcher accepts --reflection-snapshot and the server parses the versioned snapshot at startup. reflection::hover_at selects the innermost entity whose provenance covers a position and returns its bounded virtual view; hover falls back to it after compiler occurrence hover, converting the client position because reflection columns are bytes. Registered reflection tests grew to 25 cases, and a real stdio session returned the Markdown view with source links inside the recorded range and null outside it.
This commit is contained in:
1 parent
62d6ad01e8
commit
7acbfc4029
11 files changed
+148
-9
No files matched your search
@@ -311,6 +311,7 @@ VOID_TEST(Reflection, virtual_view_renders_entity_and_members) {
|
||||
VOID_TEST(Reflection, virtual_view_links_source_ranges) {
|
||||
Snapshot snapshot;
|
||||
Entity inner = entity("inner");
|
||||
inner.name = "inner";
|
||||
inner.provenance =
|
||||
chain({Origin{.kind = OriginKind::spelling, .range = range("/p/inner.cpp", 5)}});
|
||||
Entity outer = entity("outer", {member("child", reference("inner"))});
|
||||
@@ -494,3 +495,22 @@ VOID_TEST(Reflection, hover_and_locations_expose_source_links) {
|
||||
require(bounded.size() == 1);
|
||||
expect(bounded.front().line == 4);
|
||||
}
|
||||
|
||||
VOID_TEST(Reflection, hover_at_selects_the_innermost_covering_entity) {
|
||||
Snapshot snapshot;
|
||||
Entity outer = entity("outer");
|
||||
outer.name = "outer";
|
||||
outer.provenance = chain({Origin{.kind = OriginKind::splice, .range = range("/p/a.cpp", 2)}});
|
||||
outer.provenance.origins.front().range->endCharacter = 40;
|
||||
Entity inner = entity("inner");
|
||||
inner.name = "inner";
|
||||
inner.provenance = chain({Origin{.kind = OriginKind::splice, .range = range("/p/a.cpp", 5)}});
|
||||
inner.provenance.origins.front().range->endCharacter = 12;
|
||||
require(snapshot.add(std::move(outer)));
|
||||
require(snapshot.add(std::move(inner)));
|
||||
const auto selected = hover_at(snapshot, "/p/a.cpp", {5, 6});
|
||||
require(selected.has_value());
|
||||
expect(selected->markup.find("inner : int") != std::string::npos);
|
||||
expect(!hover_at(snapshot, "/p/a.cpp", {9, 0}).has_value());
|
||||
expect(!hover_at(snapshot, "/p/b.cpp", {5, 6}).has_value());
|
||||
}
|
||||
Reference in new issue
Block a user