Persist record signatures and list observed overloads
SymbolRecord carries the optional compiler signature and the snapshot schema moves to 3; restore accepts schemas 1-3, verifies the digest for 3 and persists the upgrade. Registered index tests cover signature persistence, a schema-2 migration keeping records and oversized rejection. Signature help merges every observed signature for the name (document occurrences and index) with the compiler-selected one first; a real stdio session with two called overloads returned both labels. This is a candidate list, not overload resolution.
This commit is contained in:
1 parent
816c38da1e
commit
a5b9f34c9e
7 files changed
+113
-13
No files matched your search
@@ -396,6 +396,8 @@ struct EditorDiagnostics::State {
|
||||
record.definition =
|
||||
location_of(occurrence.definition, *occurrence.definition_file);
|
||||
record.provenance = "stock-observer";
|
||||
if (!occurrence.signature.empty())
|
||||
record.signature = occurrence.signature;
|
||||
facts.records.push_back(std::move(record));
|
||||
}
|
||||
symbols.publish(facts);
|
||||
@@ -1710,7 +1712,26 @@ Json EditorDiagnostics::signature_help(std::string_view uri, Documents::Position
|
||||
}
|
||||
if (!match)
|
||||
return Json{nullptr};
|
||||
const std::vector<std::string> signatures{match->signature};
|
||||
// The compiler-selected signature stays first; other observed overloads of
|
||||
// the same name follow as candidates. The index never proves visibility, so
|
||||
// this is not overload resolution.
|
||||
std::vector<std::string> signatures{match->signature};
|
||||
const auto consider = [&signatures](const std::string &candidate) {
|
||||
if (candidate.empty() || signatures.size() == 8)
|
||||
return;
|
||||
if (std::ranges::find(signatures, candidate) == signatures.end())
|
||||
signatures.push_back(candidate);
|
||||
};
|
||||
for (const auto &fact : *facts)
|
||||
if (fact.name == match->name)
|
||||
consider(fact.signature);
|
||||
{
|
||||
std::lock_guard lock{s.mutex};
|
||||
if (const auto generation = s.symbols.current())
|
||||
for (const auto &record : generation->symbols())
|
||||
if (record.name == match->name && record.signature)
|
||||
consider(*record.signature);
|
||||
}
|
||||
const auto help = features::signature::build(signatures, snapshot->text, *offset);
|
||||
if (help.signatures.empty())
|
||||
return Json{nullptr};
|
||||
|
||||
Reference in new issue
Block a user