[clang-tools-extra] e030de7 - [clangd] Pass file when possible to resolve URI.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 17 06:39:31 PST 2021
Author: Haojian Wu
Date: 2021-02-17T15:33:50+01:00
New Revision: e030de7e5a28de1bcc337ede445600f8d282d252
URL: https://github.com/llvm/llvm-project/commit/e030de7e5a28de1bcc337ede445600f8d282d252
DIFF: https://github.com/llvm/llvm-project/commit/e030de7e5a28de1bcc337ede445600f8d282d252.diff
LOG: [clangd] Pass file when possible to resolve URI.
Some URI scheme needs the hint path to do a correct resolution, we pass
one of the open files as hint path.
This is not perfect, and it might not work for opening files across
project, but it would fix a bug with our internal scheme.
in the long run, removing URIs from all the index internals is a more proper fix.
Differential Revision: https://reviews.llvm.org/D96844
Added:
Modified:
clang-tools-extra/clangd/index/MemIndex.cpp
clang-tools-extra/clangd/index/dex/Dex.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/index/MemIndex.cpp b/clang-tools-extra/clangd/index/MemIndex.cpp
index a578ed2da140..e2a8eb7f8e3f 100644
--- a/clang-tools-extra/clangd/index/MemIndex.cpp
+++ b/clang-tools-extra/clangd/index/MemIndex.cpp
@@ -112,9 +112,11 @@ void MemIndex::relations(
llvm::unique_function<IndexContents(llvm::StringRef) const>
MemIndex::indexedFiles() const {
return [this](llvm::StringRef FileURI) {
- auto Path = URI::resolve(FileURI);
+ if (Files.empty())
+ return IndexContents::None;
+ auto Path = URI::resolve(FileURI, Files.begin()->first());
if (!Path) {
- llvm::consumeError(Path.takeError());
+ vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
return IndexContents::None;
}
return Files.contains(*Path) ? IdxContents : IndexContents::None;
diff --git a/clang-tools-extra/clangd/index/dex/Dex.cpp b/clang-tools-extra/clangd/index/dex/Dex.cpp
index 8552fa3b5174..a6a8f23cab4c 100644
--- a/clang-tools-extra/clangd/index/dex/Dex.cpp
+++ b/clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -316,9 +316,11 @@ void Dex::relations(
llvm::unique_function<IndexContents(llvm::StringRef) const>
Dex::indexedFiles() const {
return [this](llvm::StringRef FileURI) {
- auto Path = URI::resolve(FileURI);
+ if (Files.empty())
+ return IndexContents::None;
+ auto Path = URI::resolve(FileURI, Files.begin()->first());
if (!Path) {
- llvm::consumeError(Path.takeError());
+ vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
return IndexContents::None;
}
return Files.contains(*Path) ? IdxContents : IndexContents::None;
More information about the cfe-commits
mailing list