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
+147
-8
No files matched your search
@@ -12,6 +12,7 @@ missing part. Updated December 5, 2026 after semantic tokens and inlay hints.
|
|||||||
| textDocument sync (full + incremental, UTF-8/UTF-16) | document suite, real stdio corpora |
|
| textDocument sync (full + incremental, UTF-8/UTF-16) | document suite, real stdio corpora |
|
||||||
| publishDiagnostics (stock GCC, in-process default profile) | diagnostic suite, stdio corpus |
|
| publishDiagnostics (stock GCC, in-process default profile) | diagnostic suite, stdio corpus |
|
||||||
| textDocument/hover, definition | stock occurrence corpus |
|
| textDocument/hover, definition | stock occurrence corpus |
|
||||||
|
| textDocument/hover over reflection snapshots | recorded-snapshot stdio session |
|
||||||
| textDocument/references, prepareRename, rename | navigation suite, stock corpus refusals |
|
| textDocument/references, prepareRename, rename | navigation suite, stock corpus refusals |
|
||||||
| textDocument/completion (+ completionItem/resolve) | `vls_feature_tests`, real stdio session |
|
| textDocument/completion (+ completionItem/resolve) | `vls_feature_tests`, real stdio session |
|
||||||
| textDocument/signatureHelp | `vls_feature_tests`, real stdio session |
|
| textDocument/signatureHelp | `vls_feature_tests`, real stdio session |
|
||||||
@@ -39,7 +40,6 @@ missing part. Updated December 5, 2026 after semantic tokens and inlay hints.
|
|||||||
| callHierarchy / typeHierarchy | prepare, incomingCalls and outgoingCalls are implemented and served; outgoing calls are verified over stdio now that the observer reports full function extents. Type hierarchy is open. |
|
| callHierarchy / typeHierarchy | prepare, incomingCalls and outgoingCalls are implemented and served; outgoing calls are verified over stdio now that the observer reports full function extents. Type hierarchy is open. |
|
||||||
| Client-side application of server-issued workspace edits | rename and code actions return edits the clients apply directly |
|
| Client-side application of server-issued workspace edits | rename and code actions return edits the clients apply directly |
|
||||||
| Applying multi-file renames through client buffers | plans can be ready; application is client work |
|
| Applying multi-file renames through client buffers | plans can be ready; application is client work |
|
||||||
| `EditorDiagnostics` reflection LSP wiring | the server has no reflection data source |
|
|
||||||
| richer token types | legend is one type (`function`) plus a `declaration` modifier; type tokens need compiler-provided spans |
|
| richer token types | legend is one type (`function`) plus a `declaration` modifier; type tokens need compiler-provided spans |
|
||||||
| textDocument/formatting | no formatter is available; needs a dependency decision |
|
| textDocument/formatting | no formatter is available; needs a dependency decision |
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ ingests occurrence facts after each analysis and the server answers
|
|||||||
Hash.hpp definition through it. Real persistence migrations and cross-file
|
Hash.hpp definition through it. Real persistence migrations and cross-file
|
||||||
rename coverage remain open.
|
rename coverage remain open.
|
||||||
|
|
||||||
Index-backed completion (roadmap 14 first slice) is implemented: `include/vls/features/Completion.hpp`, `src/features/Completion.cpp` and registered `vls_feature_tests` cover prefix extraction, filtering with replacement ranges, label+kind deduplication, deterministic ranking and bounds. `Server.cpp` advertises `completionProvider` and answers `textDocument/completion` from the symbol index through `EditorDiagnostics::completion`; a real stdio session with the stock observer returned `fnv1a64` and `fnv1a64_update` at a real call site. Every result is marked incomplete because the index does not prove visibility. Signature help is now served from the compiler-provided occurrence signature (parameter labels and ranges, active parameter, innermost call selection) and advertised by the server. Document symbols are served from the index by path and document highlights from same-binding occurrence facts; both are advertised and were exercised over stdio with the stock observer. Selection and folding ranges are served from immutable document snapshots with registered bounded cores. Code actions now offer the compiler's own suggested fixes (quickfix) from retained published diagnostics, with SARIF fix decoding bound to the owner snapshot. Semantic tokens encode the proven call occurrences and same-file definition names, the latter with a declaration modifier, under a bounded legend. Inlay hints project parameter types from the occurrence signature at each argument start. Workspace file-operation notifications invalidate dependent index contexts and re-queue open documents. A will-rename request returns the include updates for open documents. Document links resolve quoted includes to existing files without the compiler. Code lenses show index reference counts and the `vls.showReferences` command resolves them to navigation locations. Call hierarchy serves prepare and incoming calls (grouped by enclosing definition or explicitly by file) from the stock call facts. Outgoing calls are served and verified: the stock observer now reports full function extents, so nested calls are attributed to the enclosing definition. Compiler-native completion with visibility proof and deferred detail resolution remain open.
|
Index-backed completion (roadmap 14 first slice) is implemented: `include/vls/features/Completion.hpp`, `src/features/Completion.cpp` and registered `vls_feature_tests` cover prefix extraction, filtering with replacement ranges, label+kind deduplication, deterministic ranking and bounds. `Server.cpp` advertises `completionProvider` and answers `textDocument/completion` from the symbol index through `EditorDiagnostics::completion`; a real stdio session with the stock observer returned `fnv1a64` and `fnv1a64_update` at a real call site. Every result is marked incomplete because the index does not prove visibility. Signature help is now served from the compiler-provided occurrence signature (parameter labels and ranges, active parameter, innermost call selection) and advertised by the server. Document symbols are served from the index by path and document highlights from same-binding occurrence facts; both are advertised and were exercised over stdio with the stock observer. Selection and folding ranges are served from immutable document snapshots with registered bounded cores. Code actions now offer the compiler's own suggested fixes (quickfix) from retained published diagnostics, with SARIF fix decoding bound to the owner snapshot. Semantic tokens encode the proven call occurrences and same-file definition names, the latter with a declaration modifier, under a bounded legend. Inlay hints project parameter types from the occurrence signature at each argument start. Workspace file-operation notifications invalidate dependent index contexts and re-queue open documents. A will-rename request returns the include updates for open documents. Reflection hover is served from a recorded snapshot file selected at launch, with the client position converted through the document snapshot. Document links resolve quoted includes to existing files without the compiler. Code lenses show index reference counts and the `vls.showReferences` command resolves them to navigation locations. Call hierarchy serves prepare and incoming calls (grouped by enclosing definition or explicitly by file) from the stock call facts. Outgoing calls are served and verified: the stock observer now reports full function extents, so nested calls are attributed to the enclosing definition. Compiler-native completion with visibility proof and deferred detail resolution remain open.
|
||||||
|
|
||||||
The reflection provenance representation (roadmap 12 first slice) is
|
The reflection provenance representation (roadmap 12 first slice) is
|
||||||
implemented as a bounded library with a registered suite: innermost-first
|
implemented as a bounded library with a registered suite: innermost-first
|
||||||
|
|||||||
@@ -79,6 +79,26 @@ the upgraded snapshot (keeping `snapshot.prev.json`) and rewrites a legacy
|
|||||||
about 25-30s in a Debug build (it passed VBS at ~27s); the full CMake run then
|
about 25-30s in a Debug build (it passed VBS at ~27s); the full CMake run then
|
||||||
passed 18/18.
|
passed 18/18.
|
||||||
|
|
||||||
|
## December 5 reflection hover from a recorded snapshot
|
||||||
|
|
||||||
|
Per the user's decision, `EditorDiagnostics` reflection data now comes from a
|
||||||
|
recorded snapshot file: the launcher accepts `--reflection-snapshot PATH`
|
||||||
|
(absolute existing file, requires a workspace root) and the server parses it
|
||||||
|
with the versioned `reflection::Snapshot::parse` at startup.
|
||||||
|
`reflection::hover_at` selects the innermost entity whose provenance chain
|
||||||
|
covers a position and returns its bounded virtual view, and the server's hover
|
||||||
|
falls back to it after compiler-occurrence hover (converting the client position
|
||||||
|
through the document snapshot because reflection columns are bytes). A
|
||||||
|
malformed snapshot is ignored rather than served partially.
|
||||||
|
|
||||||
|
Real stdio session with a recorded entity covering `main.cpp:0:8-0:13`:
|
||||||
|
```
|
||||||
|
hover inside: {"contents": {"kind": "markdown", "value": "```text\nReady : Ready\n value : int = 17\n```\n\nSources:\n- `.../main.cpp:0:8`\n"}}
|
||||||
|
hover outside: null
|
||||||
|
```
|
||||||
|
Registered `vls_reflection_tests` grew to 25 cases. All 18 native suites and
|
||||||
|
all 18 CMake tests passed.
|
||||||
|
|
||||||
## December 5 document links for includes
|
## December 5 document links for includes
|
||||||
|
|
||||||
`include/vls/features/DocumentLinks.hpp` resolves quoted include directives
|
`include/vls/features/DocumentLinks.hpp` resolves quoted include directives
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <Void/LanguageServer/Documents/DocumentStore.hpp>
|
#include <Void/LanguageServer/Documents/DocumentStore.hpp>
|
||||||
#include <vls/Framing.hpp>
|
#include <vls/Framing.hpp>
|
||||||
#include <vls/WorkspaceSession.hpp>
|
#include <vls/WorkspaceSession.hpp>
|
||||||
|
#include <vls/reflection/Provenance.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
@@ -35,6 +36,7 @@ class Server {
|
|||||||
Void::LanguageServer::Documents::DocumentStore documents_;
|
Void::LanguageServer::Documents::DocumentStore documents_;
|
||||||
WorkspaceSession workspace_;
|
WorkspaceSession workspace_;
|
||||||
std::unique_ptr<semantic::EditorDiagnostics> diagnostics_;
|
std::unique_ptr<semantic::EditorDiagnostics> diagnostics_;
|
||||||
|
std::shared_ptr<const reflection::Snapshot> reflection_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Thin transport loop shared by the executable and stream-failure unit tests.
|
// Thin transport loop shared by the executable and stream-failure unit tests.
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ struct WorkspaceLaunch {
|
|||||||
std::optional<Void::LanguageServer::Workspace::PartialWorkspaceSettings> user_settings,
|
std::optional<Void::LanguageServer::Workspace::PartialWorkspaceSettings> user_settings,
|
||||||
cli_settings;
|
cli_settings;
|
||||||
std::shared_ptr<const semantic::GccProfile> diagnostics_profile{};
|
std::shared_ptr<const semantic::GccProfile> diagnostics_profile{};
|
||||||
|
// Versioned reflection provenance snapshot served as read-only hover.
|
||||||
|
std::optional<std::filesystem::path> reflection_snapshot;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SemanticDriver {
|
struct SemanticDriver {
|
||||||
|
|||||||
@@ -240,4 +240,14 @@ struct SpliceOrigin {
|
|||||||
// chain for an identity wins and the result stays within the snapshot limits.
|
// chain for an identity wins and the result stays within the snapshot limits.
|
||||||
[[nodiscard]] Snapshot snapshot_from_splices(std::span<const SpliceOrigin>, Limits = Limits{});
|
[[nodiscard]] Snapshot snapshot_from_splices(std::span<const SpliceOrigin>, Limits = Limits{});
|
||||||
|
|
||||||
|
struct Position {
|
||||||
|
std::uint32_t line{}, character{};
|
||||||
|
auto operator<=>(const Position &) const = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Hover for the innermost entity whose provenance chain covers POSITION in
|
||||||
|
// PATH. Ranges are compiler byte columns; an absent match is null rather
|
||||||
|
// than a lexical guess.
|
||||||
|
[[nodiscard]] std::optional<Hover> hover_at(const Snapshot &, std::string_view path, Position,
|
||||||
|
const Limits & = Limits{});
|
||||||
} // namespace vls::reflection
|
} // namespace vls::reflection
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iterator>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -132,6 +134,15 @@ DispatchResult error(const Json &id, std::int64_t code, std::string_view message
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Server::Server(WorkspaceLaunch launch, std::function<bool(std::string)> send) : workspace_(launch) {
|
Server::Server(WorkspaceLaunch launch, std::function<bool(std::string)> send) : workspace_(launch) {
|
||||||
|
if (launch.reflection_snapshot) {
|
||||||
|
std::ifstream stream{*launch.reflection_snapshot, std::ios::binary};
|
||||||
|
std::string bytes{std::istreambuf_iterator<char>{stream}, {}};
|
||||||
|
if (!bytes.empty()) {
|
||||||
|
auto parsed = reflection::Snapshot::parse(bytes);
|
||||||
|
if (parsed)
|
||||||
|
reflection_ = std::make_shared<const reflection::Snapshot>(std::move(*parsed));
|
||||||
|
}
|
||||||
|
}
|
||||||
if (launch.root && launch.diagnostics_profile && send)
|
if (launch.root && launch.diagnostics_profile && send)
|
||||||
diagnostics_ = std::make_unique<semantic::EditorDiagnostics>(
|
diagnostics_ = std::make_unique<semantic::EditorDiagnostics>(
|
||||||
*launch.root, std::move(launch.diagnostics_profile), workspace_, documents_,
|
*launch.root, std::move(launch.diagnostics_profile), workspace_, documents_,
|
||||||
@@ -380,6 +391,44 @@ DispatchResult Server::handle(std::string_view body) {
|
|||||||
diagnostics_ ? diagnostics_->status(*uri)
|
diagnostics_ ? diagnostics_->status(*uri)
|
||||||
: Json{Json::Object{{"state", Json{std::string{"disabled"}}}}});
|
: Json{Json::Object{{"state", Json{std::string{"disabled"}}}}});
|
||||||
}
|
}
|
||||||
|
if (*method == "textDocument/hover" && reflection_) {
|
||||||
|
const auto *uri = as_string(member(member(params, "textDocument"), "uri"));
|
||||||
|
const auto *position = member(params, "position");
|
||||||
|
const auto *line = position ? member(position, "line") : nullptr;
|
||||||
|
const auto *character = position ? member(position, "character") : nullptr;
|
||||||
|
const auto *line_value = line ? std::get_if<std::int64_t>(&line->value) : nullptr;
|
||||||
|
const auto *character_value =
|
||||||
|
character ? std::get_if<std::int64_t>(&character->value) : nullptr;
|
||||||
|
if (!uri || !Void::LanguageServer::Documents::client_uri_key(*uri) || !line_value ||
|
||||||
|
!character_value || *line_value < 0 || *character_value < 0 ||
|
||||||
|
*line_value > Void::LanguageServer::Documents::kMaxPositionValue ||
|
||||||
|
*character_value > Void::LanguageServer::Documents::kMaxPositionValue)
|
||||||
|
return error(id, -32602, "Expected textDocument.uri and a bounded position");
|
||||||
|
const Void::LanguageServer::Documents::Position selected{
|
||||||
|
static_cast<std::uint32_t>(*line_value), static_cast<std::uint32_t>(*character_value)};
|
||||||
|
Json result{nullptr};
|
||||||
|
if (diagnostics_ && diagnostics_->supports_occurrences())
|
||||||
|
result = diagnostics_->hover(*uri, selected);
|
||||||
|
if (std::holds_alternative<std::nullptr_t>(result.value)) {
|
||||||
|
// Reflection ranges are compiler byte columns; convert the client
|
||||||
|
// position through the snapshot before matching.
|
||||||
|
if (const auto document = documents_.snapshot(*uri)) {
|
||||||
|
const auto offset = document->position_to_offset(selected);
|
||||||
|
const auto line_start = document->line_index.line_start_offset(selected.line);
|
||||||
|
if (offset && line_start && *offset >= *line_start) {
|
||||||
|
const auto byte_character = static_cast<std::uint32_t>(*offset - *line_start);
|
||||||
|
if (auto reflected = reflection::hover_at(
|
||||||
|
*reflection_, document->identity.canonical_path.native(),
|
||||||
|
{selected.line, byte_character})) {
|
||||||
|
Json::Object content{{"kind", Json{std::string{"markdown"}}},
|
||||||
|
{"value", Json{reflected->markup}}};
|
||||||
|
result = Json{Json::Object{{"contents", Json{std::move(content)}}}};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return reply(id, "result", std::move(result));
|
||||||
|
}
|
||||||
if (*method == "textDocument/hover" || *method == "textDocument/definition" ||
|
if (*method == "textDocument/hover" || *method == "textDocument/definition" ||
|
||||||
*method == "textDocument/signatureHelp" || *method == "textDocument/documentHighlight") {
|
*method == "textDocument/signatureHelp" || *method == "textDocument/documentHighlight") {
|
||||||
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
||||||
|
|||||||
+14
-5
@@ -15,7 +15,7 @@ namespace Workspace = Void::LanguageServer::Workspace;
|
|||||||
|
|
||||||
struct Options {
|
struct Options {
|
||||||
std::optional<std::string> root, user_file, provider, database, selector, build_root,
|
std::optional<std::string> root, user_file, provider, database, selector, build_root,
|
||||||
producer_cwd, profile, gcc_profile;
|
producer_cwd, profile, gcc_profile, reflection_snapshot;
|
||||||
bool gcc_diagnostics{};
|
bool gcc_diagnostics{};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ std::expected<vls::WorkspaceLaunch, std::string> workspace_launch(const Options
|
|||||||
vls::WorkspaceLaunch launch;
|
vls::WorkspaceLaunch launch;
|
||||||
if (!options.root) {
|
if (!options.root) {
|
||||||
if (options.user_file || options.provider || options.database || options.selector ||
|
if (options.user_file || options.provider || options.database || options.selector ||
|
||||||
options.build_root || options.producer_cwd || options.profile ||
|
options.build_root || options.producer_cwd || options.profile || options.gcc_profile ||
|
||||||
options.gcc_profile || options.gcc_diagnostics)
|
options.gcc_diagnostics || options.reflection_snapshot)
|
||||||
return std::unexpected{"workspace options require --workspace-root"};
|
return std::unexpected{"workspace options require --workspace-root"};
|
||||||
return launch;
|
return launch;
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,13 @@ std::expected<vls::WorkspaceLaunch, std::string> workspace_launch(const Options
|
|||||||
return std::unexpected{!build ? build.error() : producer.error()};
|
return std::unexpected{!build ? build.error() : producer.error()};
|
||||||
launch.build_root = std::move(*build);
|
launch.build_root = std::move(*build);
|
||||||
launch.producer_cwd = std::move(*producer);
|
launch.producer_cwd = std::move(*producer);
|
||||||
|
if (options.reflection_snapshot) {
|
||||||
|
const fs::path snapshot{*options.reflection_snapshot};
|
||||||
|
std::error_code snapshot_error;
|
||||||
|
if (!snapshot.is_absolute() || !fs::is_regular_file(snapshot, snapshot_error))
|
||||||
|
return std::unexpected{"--reflection-snapshot requires an existing absolute file"};
|
||||||
|
launch.reflection_snapshot = snapshot;
|
||||||
|
}
|
||||||
Workspace::SettingsOverrides overrides;
|
Workspace::SettingsOverrides overrides;
|
||||||
overrides.compdb_path = options.database;
|
overrides.compdb_path = options.database;
|
||||||
overrides.vbs_manifest_path = options.selector;
|
overrides.vbs_manifest_path = options.selector;
|
||||||
@@ -70,8 +77,7 @@ std::expected<vls::WorkspaceLaunch, std::string> workspace_launch(const Options
|
|||||||
const bool diagnostics_default =
|
const bool diagnostics_default =
|
||||||
!options.gcc_profile && (!options.provider || *options.provider != "none");
|
!options.gcc_profile && (!options.provider || *options.provider != "none");
|
||||||
if (options.gcc_profile || options.gcc_diagnostics || diagnostics_default) {
|
if (options.gcc_profile || options.gcc_diagnostics || diagnostics_default) {
|
||||||
auto profile = options.gcc_profile
|
auto profile = options.gcc_profile ? vls::semantic::GccProfile::load(*options.gcc_profile)
|
||||||
? vls::semantic::GccProfile::load(*options.gcc_profile)
|
|
||||||
: vls::semantic::GccProfile::prepare("g++");
|
: vls::semantic::GccProfile::prepare("g++");
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
if (options.gcc_profile || options.gcc_diagnostics)
|
if (options.gcc_profile || options.gcc_diagnostics)
|
||||||
@@ -125,6 +131,9 @@ int main(int argc, char **argv) {
|
|||||||
"--gcc-profile", "",
|
"--gcc-profile", "",
|
||||||
"enable stock GCC diagnostics for this workspace using an absolute prepared profile",
|
"enable stock GCC diagnostics for this workspace using an absolute prepared profile",
|
||||||
options.gcc_profile);
|
options.gcc_profile);
|
||||||
|
parser.option("--reflection-snapshot", "",
|
||||||
|
"versioned reflection provenance snapshot served as read-only hover",
|
||||||
|
options.reflection_snapshot);
|
||||||
parser.flag("--gcc-diagnostics", "",
|
parser.flag("--gcc-diagnostics", "",
|
||||||
"prepare stock GCC diagnostics in process from the selected GCC driver "
|
"prepare stock GCC diagnostics in process from the selected GCC driver "
|
||||||
"(enabled by default when a workspace is selected)",
|
"(enabled by default when a workspace is selected)",
|
||||||
|
|||||||
@@ -338,6 +338,33 @@ Hover hover(const Entity &entity, const Expansion &expansion, const Limits &limi
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<Hover> hover_at(const Snapshot &snapshot, std::string_view path, Position position,
|
||||||
|
const Limits &limits) {
|
||||||
|
const Entity *best{};
|
||||||
|
Range best_range{};
|
||||||
|
for (const auto &entity : snapshot.entities()) {
|
||||||
|
for (const auto &origin : entity.provenance.origins) {
|
||||||
|
if (!origin.range || origin.range->path != path)
|
||||||
|
continue;
|
||||||
|
const auto &range = *origin.range;
|
||||||
|
const Position start{range.line, range.character};
|
||||||
|
const Position end{range.endLine, range.endCharacter};
|
||||||
|
if (position < start || end < position)
|
||||||
|
continue;
|
||||||
|
if (!best || start > Position{best_range.line, best_range.character}) {
|
||||||
|
best = &entity;
|
||||||
|
best_range = range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!best)
|
||||||
|
return std::nullopt;
|
||||||
|
const auto expansion = snapshot.expand(best->id);
|
||||||
|
if (!expansion)
|
||||||
|
return std::nullopt;
|
||||||
|
return hover(*best, *expansion, limits);
|
||||||
|
}
|
||||||
|
|
||||||
Snapshot snapshot_from_splices(std::span<const SpliceOrigin> splices, Limits limits) {
|
Snapshot snapshot_from_splices(std::span<const SpliceOrigin> splices, Limits limits) {
|
||||||
Snapshot snapshot{limits};
|
Snapshot snapshot{limits};
|
||||||
const auto range_at = [](std::string_view path, std::uint32_t line, std::uint32_t column) {
|
const auto range_at = [](std::string_view path, std::uint32_t line, std::uint32_t column) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ int main() {
|
|||||||
"DapReplay.deferred_launch_finishes_after_configuration_done"},
|
"DapReplay.deferred_launch_finishes_after_configuration_done"},
|
||||||
Inventory{"vls_provider_tests", 42,
|
Inventory{"vls_provider_tests", 42,
|
||||||
"CommandImport.physical_owners_follow_links_before_parent_components"},
|
"CommandImport.physical_owners_follow_links_before_parent_components"},
|
||||||
Inventory{"vls_reflection_tests", 24, "Reflection.virtual_view_links_source_ranges"},
|
Inventory{"vls_reflection_tests", 25, "Reflection.virtual_view_links_source_ranges"},
|
||||||
Inventory{"vls_trace_tests", 21,
|
Inventory{"vls_trace_tests", 21,
|
||||||
"RecordingTests.retains_values_and_source_across_overwrite_replacement_and_"
|
"RecordingTests.retains_values_and_source_across_overwrite_replacement_and_"
|
||||||
"unlink"},
|
"unlink"},
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ VOID_TEST(Reflection, virtual_view_renders_entity_and_members) {
|
|||||||
VOID_TEST(Reflection, virtual_view_links_source_ranges) {
|
VOID_TEST(Reflection, virtual_view_links_source_ranges) {
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
Entity inner = entity("inner");
|
Entity inner = entity("inner");
|
||||||
|
inner.name = "inner";
|
||||||
inner.provenance =
|
inner.provenance =
|
||||||
chain({Origin{.kind = OriginKind::spelling, .range = range("/p/inner.cpp", 5)}});
|
chain({Origin{.kind = OriginKind::spelling, .range = range("/p/inner.cpp", 5)}});
|
||||||
Entity outer = entity("outer", {member("child", reference("inner"))});
|
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);
|
require(bounded.size() == 1);
|
||||||
expect(bounded.front().line == 4);
|
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