Add return-type inlay hints after calls
The bounded inlay-hint core now matches a call's closing parenthesis (nested calls, literals and comments aware) and places a type hint labelled with the compiler's canonical type. EditorDiagnostics emits it for every occurrence independently of parameter signatures. Registered tests cover nested matching, placement, skipped cases and bounds; a real stdio session showed both the parameter and return hints at the fnv1a64 call.
This commit is contained in:
1 parent
0bf5873069
commit
2cced8363d
6 files changed
+135
-7
No files matched your search
@@ -1324,15 +1324,20 @@ Json EditorDiagnostics::inlay_hints(std::string_view uri, Documents::Range range
|
||||
const features::inlay_hints::Range requested{{range.start.line, range.start.character},
|
||||
{range.end.line, range.end.character}};
|
||||
for (const auto &occurrence : *facts) {
|
||||
if (occurrence.use_file.get() != snapshot || occurrence.signature.empty())
|
||||
if (occurrence.use_file.get() != snapshot)
|
||||
continue;
|
||||
const auto use = snapshot->range_to_offsets(occurrence.use);
|
||||
if (!use)
|
||||
continue;
|
||||
const std::vector<std::string> signatures{occurrence.signature};
|
||||
const auto produced = features::inlay_hints::parameter_hints(signatures, snapshot->text,
|
||||
use->second, requested);
|
||||
hints.insert(hints.end(), produced.begin(), produced.end());
|
||||
if (!occurrence.signature.empty()) {
|
||||
const std::vector<std::string> signatures{occurrence.signature};
|
||||
const auto produced = features::inlay_hints::parameter_hints(signatures, snapshot->text,
|
||||
use->second, requested);
|
||||
hints.insert(hints.end(), produced.begin(), produced.end());
|
||||
}
|
||||
if (const auto returned = features::inlay_hints::return_type_hint(
|
||||
snapshot->text, use->second, occurrence.canonical_type, requested))
|
||||
hints.push_back(*returned);
|
||||
}
|
||||
std::ranges::sort(hints);
|
||||
const auto unique = std::ranges::unique(hints);
|
||||
|
||||
Reference in new issue
Block a user