forked from OSchip/llvm-project
[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
This commit is contained in:
parent
4e127bce2d
commit
e030de7e5a
|
@ -112,9 +112,11 @@ void MemIndex::relations(
|
||||||
llvm::unique_function<IndexContents(llvm::StringRef) const>
|
llvm::unique_function<IndexContents(llvm::StringRef) const>
|
||||||
MemIndex::indexedFiles() const {
|
MemIndex::indexedFiles() const {
|
||||||
return [this](llvm::StringRef FileURI) {
|
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) {
|
if (!Path) {
|
||||||
llvm::consumeError(Path.takeError());
|
vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
|
||||||
return IndexContents::None;
|
return IndexContents::None;
|
||||||
}
|
}
|
||||||
return Files.contains(*Path) ? IdxContents : IndexContents::None;
|
return Files.contains(*Path) ? IdxContents : IndexContents::None;
|
||||||
|
|
|
@ -316,9 +316,11 @@ void Dex::relations(
|
||||||
llvm::unique_function<IndexContents(llvm::StringRef) const>
|
llvm::unique_function<IndexContents(llvm::StringRef) const>
|
||||||
Dex::indexedFiles() const {
|
Dex::indexedFiles() const {
|
||||||
return [this](llvm::StringRef FileURI) {
|
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) {
|
if (!Path) {
|
||||||
llvm::consumeError(Path.takeError());
|
vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
|
||||||
return IndexContents::None;
|
return IndexContents::None;
|
||||||
}
|
}
|
||||||
return Files.contains(*Path) ? IdxContents : IndexContents::None;
|
return Files.contains(*Path) ? IdxContents : IndexContents::None;
|
||||||
|
|
Loading…
Reference in New Issue