This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Introduce scoring mechanism for SignatureInformations.
ClosedPublic

Authored by kadircet on Aug 10 2018, 1:45 AM.

Diff Detail

Event Timeline

kadircet created this revision.Aug 10 2018, 1:45 AM
ilya-biryukov added inline comments.Aug 10 2018, 5:24 AM
clangd/CodeComplete.cpp
706

Maybe use vector<ScoredSignature>, followed by std::sort at the end?

Or is there any functionality that we can reuse from the priority queue?

clangd/Quality.h
170

Maybe set some default value to avoid UB if someone forgets to set it?

172

Maybe write a direct comparison here instead of evaluate?
Having floating scores makes sense for completion, where lot's of different signals from multiple sources are taken into account and clients have to rescore on the client side.
Not so much for SignatureHelp, where we have all required information to compare the signatures is on clangd side and clients won't need to rescore.

A comparison operator should be easier to reason about, though.

kadircet updated this revision to Diff 160097.Aug 10 2018, 6:10 AM
kadircet marked 3 inline comments as done.
  • Resolve discussions.
ilya-biryukov accepted this revision.Aug 10 2018, 7:10 AM

Thanks! LGTM with a few NITs

clangd/CodeComplete.cpp
693

NIT: Maybe make it a function with a descriptive name, e.g. hasBetterSignature?
We could call it in a lambda, should make the code even clearer.

729

NIT: remove braces around the single-statement loop body

This revision is now accepted and ready to land.Aug 10 2018, 7:10 AM
kadircet updated this revision to Diff 160306.Aug 13 2018, 1:34 AM
kadircet marked 2 inline comments as done.
  • Rebase & Resolve discussions.
  • Resolve discussions.
This revision was automatically updated to reflect the committed changes.