[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 7 06:49:26 PDT 2018


sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, mgrang, jkorous, MaskRay, ioeric, mgorny, klimek.

Code completion scoring was embedded in CodeComplete.cpp, which is bad:

- awkward to test. The mechanisms (extracting info from index/sema) can be unit-tested well, the policy (scoring) should be quantitatively measured. Neither was easily possible, and debugging was hard. The intermediate signal struct makes this easier.
- hard to reuse. This is a bug in workspaceSymbols: it just presents the results in the index order, which is not sorted in practice, it needs to rank them! Also, index implementations care about scoring (both query-dependent and independent) in order to truncate result lists appropriately.

The main yak shaved here is the build() function that had 3 variants across
unit tests is unified in TestTU.h (rather than adding a 4th variant).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524

Files:
  clangd/CMakeLists.txt
  clangd/CodeComplete.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/QualityTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h
  unittests/clangd/XRefsTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46524.145458.patch
Type: text/x-patch
Size: 39332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180507/d0c0db4d/attachment-0001.bin>


More information about the cfe-commits mailing list