You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 09939af
Browse filesBrowse the repository at this point in the historyBrowse files
hover: the card is rendered from the model, never sliced from the file
Reported: "most hover results are a copy of the source range, not a reconstructed rendering — no copy-paste display
allowed; redo the hover rendering modelled on Rust, especially for generics."
**The code block is now generated by one module.** `cpp_code_analysis::sema::render` takes a `DeclFact` (and the
declaration's node when the declaring file is at hand) and rebuilds the item:
```text
template <typename T, typename Alloc = int>
class Box As written here: `Box<int>`
```
* a **type** is parsed from the recorded spelling and printed by `Type`'s own writer — `std::vector<std::string> &`
becomes `std::vector<std::string>&`, `char *` becomes `char*`, `typename` disappears;
* a **parameter list** is parsed: types canonical, names kept, defaults summarised (`= 2`, `= npos`, `= …` for an
expression), a pack's `...` said once;
* a **template head** is rebuilt from the declaration's parameters — `class`/`typename` as written, non-type parameters
by type, defaults, packs — with the fact's names as the fallback when the syntax is not at hand;
* a **class** says the keyword its node kind carries (`class`/`struct`/`union`/`enum`/`enum class`), its bases, and the
reflection annotation above it (`UCLASS(Blueprintable)`, from the fact, not the text);
* an **alias** is `using X = Y;`, a **variable** keeps `static`/`constexpr`/`const`/`volatile`, an **enumerator** shows
the folded number, a **namespace** its name.
Deleted from hover: `declaration_text`, `the_template_head_before`, `the_declarations_start`, `slice_lines`,
`signature_line`, `the_trailing_clause`, `spells_a_signature`, `MAX_HOVER_LINES`. The card, the overload list and the
member list all print `render::an_item` / `render::a_line`, so the three cannot disagree.
**Generics.** A member of a known specialization is rendered **instantiated** — the member list substitutes the class's
arguments, so `put(const T& value) const &` on a `Box<int>` reads `put(const int& value) const &` (measured). A class
template's card shows its own head plus `As written here: \`Box<int>\``.
**Parser fixes found while rendering it.** `CppTemplateParam::is_type_param` searched direct tokens only (the keyword
lives under the parameter's specifier sequence), so every type parameter was read as a non-type one;
`CppTemplateParam::get_name` had no answer for a type parameter (`typename T` has no declarator), so the head rendered
`template <typename, typename>`. Both are subtree searches now.
**Fact-level repairs the card needed.** `element_type`'s alias target kept its `typename` (`parse_type_spelling`);
`qualified_from_the_index` took the first fact *named* like the class — a constructor — giving
`std::shared_ptr::shared_ptr`; `members_of` never retried the qualified spelling for a bare name; `finish_a_nested_name`
could not follow a head that is another class (`__shared_ptr<T>::element_type`); an unresolved pointee was returned as a
class name. Each has a test, and `shared_ptr` on a hand-written fixture now resolves `p->identifier()`.
Tests: nine renderer tests (function, template head with kinds/defaults, non-type parameter and pack, class keywords,
alias, variable qualifiers, parameter parsing, type printing), the hover integration tests, and the reported hovers.
`reported_hover` now expects the canonical `Fn&& fn`; the anonymous-struct card asserts it does **not** echo the struct's
body; `a_hover_names_the_instantiation_and_never_invents_a_void` keeps its own names.
The remaining work — `type_of` losing its shape match (the `shared_ptr` root cause), the two readings, and the gaps this
pass found — is written down in `docs/hover-render.md`.
0 commit comments