[clangd] Incorporate transitive #includes into code complete proximity scoring.
authorSam McCall <sam.mccall@gmail.com>
Tue, 3 Jul 2018 08:09:29 +0000 (08:09 +0000)
committerSam McCall <sam.mccall@gmail.com>
Tue, 3 Jul 2018 08:09:29 +0000 (08:09 +0000)
commit3f0243fdafaa7207fa6ade486e1bb9b99d2c4140
tree370b8271f4c8701b309c077f419ecc57e2623f31
parenta0a52bf195821a49a6920084a6ddb5139d9fa3fe
[clangd] Incorporate transitive #includes into code complete proximity scoring.

Summary:
We now compute a distance from the main file to the symbol header, which
is a weighted count of:
 - some number of #include traversals from source file --> included file
 - some number of FS traversals from file --> parent directory
 - some number of FS traversals from parent directory --> child file/dir
This calculation is performed in the appropriate URI scheme.

This means we'll get some proximity boost from header files in main-file
contexts, even when these are in different directory trees.

This extended file proximity model is not yet incorporated in the index
interface/implementation.

Reviewers: ioeric

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, cfe-commits

Differential Revision: https://reviews.llvm.org/D48441

llvm-svn: 336177
17 files changed:
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdUnit.cpp
clang-tools-extra/clangd/ClangdUnit.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/FileDistance.cpp [new file with mode: 0644]
clang-tools-extra/clangd/FileDistance.h [new file with mode: 0644]
clang-tools-extra/clangd/Headers.cpp
clang-tools-extra/clangd/Headers.h
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/Quality.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/unittests/clangd/CMakeLists.txt
clang-tools-extra/unittests/clangd/FileDistanceTests.cpp [new file with mode: 0644]
clang-tools-extra/unittests/clangd/HeadersTests.cpp
clang-tools-extra/unittests/clangd/QualityTests.cpp