[clang-tools-extra] r341552 - [clangd] Fix Dex initialization
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 6 08:10:10 PDT 2018
Author: omtcyfz
Date: Thu Sep 6 08:10:10 2018
New Revision: 341552
URL: http://llvm.org/viewvc/llvm-project?rev=341552&view=rev
Log:
[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.
Modified:
clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp
clang-tools-extra/trunk/clangd/index/dex/DexIndex.h
Modified: clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp?rev=341552&r1=341551&r2=341552&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp Thu Sep 6 08:10:10 2018
@@ -59,6 +59,7 @@ std::vector<std::unique_ptr<Iterator>> c
"scheme. fuzzyFind request will ignore it.",
Path);
llvm::consumeError(PathURI.takeError());
+ continue;
}
const auto PathProximityURIs = generateProximityURIs(PathURI->toString());
for (const auto &ProximityURI : PathProximityURIs)
Modified: clang-tools-extra/trunk/clangd/index/dex/DexIndex.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/DexIndex.h?rev=341552&r1=341551&r2=341552&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/dex/DexIndex.h (original)
+++ clang-tools-extra/trunk/clangd/index/dex/DexIndex.h Thu Sep 6 08:10:10 2018
@@ -22,6 +22,7 @@
#include "../Index.h"
#include "../MemIndex.h"
+#include "../SymbolCollector.h"
#include "Iterator.h"
#include "Token.h"
#include "Trigram.h"
@@ -40,8 +41,14 @@ class DexIndex : public SymbolIndex {
public:
// All symbols must outlive this index.
template <typename Range>
- DexIndex(Range &&Symbols, llvm::ArrayRef<std::string> URISchemes)
- : URISchemes(URISchemes) {
+ DexIndex(Range &&Symbols, llvm::ArrayRef<std::string> Schemes)
+ : URISchemes(Schemes) {
+ // If Schemes don't contain any items, fall back to SymbolCollector's
+ // default URI schemes.
+ if (URISchemes.empty()) {
+ SymbolCollector::Options Opts;
+ URISchemes = Opts.URISchemes;
+ }
for (auto &&Sym : Symbols)
this->Symbols.push_back(&Sym);
buildIndex();
@@ -90,7 +97,7 @@ private:
llvm::DenseMap<Token, PostingList> InvertedIndex;
std::shared_ptr<void> KeepAlive; // poor man's move-only std::any
- const std::vector<std::string> URISchemes;
+ std::vector<std::string> URISchemes;
};
/// Returns Search Token for a number of parent directories of given Path.
More information about the cfe-commits
mailing list