diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-07-03 08:09:29 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-07-03 08:09:29 +0000 |
| commit | 3f0243fdafaa7207fa6ade486e1bb9b99d2c4140 (patch) | |
| tree | 370b8271f4c8701b309c077f419ecc57e2623f31 /clang-tools-extra/clangd/XRefs.cpp | |
| parent | a0a52bf195821a49a6920084a6ddb5139d9fa3fe (diff) | |
| download | bcm5719-llvm-3f0243fdafaa7207fa6ade486e1bb9b99d2c4140.tar.gz bcm5719-llvm-3f0243fdafaa7207fa6ade486e1bb9b99d2c4140.zip | |
[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
Diffstat (limited to 'clang-tools-extra/clangd/XRefs.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/XRefs.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp index 92fe8d268b2..6cc661a20bc 100644 --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -230,13 +230,10 @@ llvm::Optional<SymbolID> getSymbolID(const Decl *D) { std::vector<Location> findDefinitions(ParsedAST &AST, Position Pos, const SymbolIndex *Index) { const SourceManager &SourceMgr = AST.getASTContext().getSourceManager(); - SourceLocation SourceLocationBeg = - getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID()); std::vector<Location> Result; // Handle goto definition for #include. - for (auto &Inc : AST.getInclusions()) { - Position Pos = sourceLocToPosition(SourceMgr, SourceLocationBeg); + for (auto &Inc : AST.getIncludeStructure().MainFileIncludes) { if (!Inc.Resolved.empty() && Inc.R.contains(Pos)) Result.push_back(Location{URIForFile{Inc.Resolved}, {}}); } @@ -244,6 +241,8 @@ std::vector<Location> findDefinitions(ParsedAST &AST, Position Pos, return Result; // Identified symbols at a specific position. + SourceLocation SourceLocationBeg = + getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID()); auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg); for (auto Item : Symbols.Macros) { |

