Skip to content

Commit 049b2d4

Browse files
committed
[clangd] Fix Dex initialization
This patch sets URI schemes of Dex to SymbolCollector's default schemes in case callers tried to pass empty list of schemes. This was the case for initialization in Clangd main and was a reason of incorrect behavior. Also, it fixes a bug with missed `continue;` after spotting invalid URI scheme conversion. llvm-svn: 341552
1 parent 38895a0 commit 049b2d4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clang-tools-extra/clangd/index/dex/DexIndex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ std::vector<std::unique_ptr<Iterator>> createFileProximityIterators(
5959
"scheme. fuzzyFind request will ignore it.",
6060
Path);
6161
llvm::consumeError(PathURI.takeError());
62+
continue;
6263
}
6364
const auto PathProximityURIs = generateProximityURIs(PathURI->toString());
6465
for (const auto &ProximityURI : PathProximityURIs)

clang-tools-extra/clangd/index/dex/DexIndex.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "../Index.h"
2424
#include "../MemIndex.h"
25+
#include "../SymbolCollector.h"
2526
#include "Iterator.h"
2627
#include "Token.h"
2728
#include "Trigram.h"
@@ -40,8 +41,14 @@ class DexIndex : public SymbolIndex {
4041
public:
4142
// All symbols must outlive this index.
4243
template <typename Range>
43-
DexIndex(Range &&Symbols, llvm::ArrayRef<std::string> URISchemes)
44-
: URISchemes(URISchemes) {
44+
DexIndex(Range &&Symbols, llvm::ArrayRef<std::string> Schemes)
45+
: URISchemes(Schemes) {
46+
// If Schemes don't contain any items, fall back to SymbolCollector's
47+
// default URI schemes.
48+
if (URISchemes.empty()) {
49+
SymbolCollector::Options Opts;
50+
URISchemes = Opts.URISchemes;
51+
}
4552
for (auto &&Sym : Symbols)
4653
this->Symbols.push_back(&Sym);
4754
buildIndex();
@@ -90,7 +97,7 @@ class DexIndex : public SymbolIndex {
9097
llvm::DenseMap<Token, PostingList> InvertedIndex;
9198
std::shared_ptr<void> KeepAlive; // poor man's move-only std::any
9299

93-
const std::vector<std::string> URISchemes;
100+
std::vector<std::string> URISchemes;
94101
};
95102

96103
/// Returns Search Token for a number of parent directories of given Path.

0 commit comments

Comments
 (0)