forked from OSchip/llvm-project
[clangd] Get rid of Decls parameter in indexMainDecls. NFC
It's already available in ParsedAST. llvm-svn: 342473
This commit is contained in:
parent
6a39d32e66
commit
764f461f9c
|
@ -83,7 +83,7 @@ std::unique_ptr<ParsingCallbacks> makeUpdateCallbacks(FileIndex *FIndex) {
|
|||
}
|
||||
|
||||
void onMainAST(PathRef Path, ParsedAST &AST) override {
|
||||
FIndex->updateMain(Path, AST, AST.getLocalTopLevelDecls());
|
||||
FIndex->updateMain(Path, AST);
|
||||
}
|
||||
};
|
||||
return llvm::make_unique<CB>(FIndex);
|
||||
|
|
|
@ -65,10 +65,9 @@ indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
|
|||
}
|
||||
|
||||
std::pair<SymbolSlab, RefSlab>
|
||||
indexMainDecls(ParsedAST &AST, llvm::ArrayRef<Decl *> TopLevelDecls,
|
||||
llvm::ArrayRef<std::string> URISchemes) {
|
||||
indexMainDecls(ParsedAST &AST, llvm::ArrayRef<std::string> URISchemes) {
|
||||
return indexSymbols(AST.getASTContext(), AST.getPreprocessorPtr(),
|
||||
TopLevelDecls,
|
||||
AST.getLocalTopLevelDecls(),
|
||||
/*IsIndexMainAST=*/true, URISchemes);
|
||||
}
|
||||
|
||||
|
@ -163,9 +162,8 @@ void FileIndex::updatePreamble(PathRef Path, ASTContext &AST,
|
|||
PreambleIndex.reset(PreambleSymbols.buildMemIndex());
|
||||
}
|
||||
|
||||
void FileIndex::updateMain(PathRef Path, ParsedAST &AST,
|
||||
llvm::ArrayRef<Decl *> TopLevelDecls) {
|
||||
auto Contents = indexMainDecls(AST, TopLevelDecls, URISchemes);
|
||||
void FileIndex::updateMain(PathRef Path, ParsedAST &AST) {
|
||||
auto Contents = indexMainDecls(AST, URISchemes);
|
||||
MainFileSymbols.update(
|
||||
Path, llvm::make_unique<SymbolSlab>(std::move(Contents.first)),
|
||||
llvm::make_unique<RefSlab>(std::move(Contents.second)));
|
||||
|
|
|
@ -73,9 +73,9 @@ public:
|
|||
void updatePreamble(PathRef Path, ASTContext &AST,
|
||||
std::shared_ptr<Preprocessor> PP);
|
||||
|
||||
/// Update symbols from main file \p Path with symbols in \p TopLevelDecls.
|
||||
void updateMain(PathRef Path, ParsedAST &AST,
|
||||
llvm::ArrayRef<Decl *> TopLevelDecls);
|
||||
/// Update symbols and references from main file \p Path with
|
||||
/// `indexMainDecls`.
|
||||
void updateMain(PathRef Path, ParsedAST &AST);
|
||||
|
||||
private:
|
||||
std::vector<std::string> URISchemes;
|
||||
|
@ -106,12 +106,12 @@ private:
|
|||
std::unique_ptr<SymbolIndex> MergedIndex; // Merge preamble and main index.
|
||||
};
|
||||
|
||||
/// Retrieves symbols and refs of \p Decls in \p AST.
|
||||
/// Retrieves symbols and refs of local top level decls in \p AST (i.e.
|
||||
/// `AST.getLocalTopLevelDecls()`).
|
||||
/// Exposed to assist in unit tests.
|
||||
/// If URISchemes is empty, the default schemes in SymbolCollector will be used.
|
||||
std::pair<SymbolSlab, RefSlab>
|
||||
indexMainDecls(ParsedAST &AST, llvm::ArrayRef<Decl *> Decls,
|
||||
llvm::ArrayRef<std::string> URISchemes = {});
|
||||
indexMainDecls(ParsedAST &AST, llvm::ArrayRef<std::string> URISchemes = {});
|
||||
|
||||
/// Idex declarations from \p AST and macros from \p PP that are declared in
|
||||
/// included headers.
|
||||
|
|
|
@ -314,14 +314,14 @@ TEST(FileIndexTest, Refs) {
|
|||
Test.Code = MainCode.code();
|
||||
Test.Filename = "test.cc";
|
||||
auto AST = Test.build();
|
||||
Index.updateMain(Test.Filename, AST, AST.getLocalTopLevelDecls());
|
||||
Index.updateMain(Test.Filename, AST);
|
||||
// Add test2.cc
|
||||
TestTU Test2;
|
||||
Test2.HeaderCode = HeaderCode;
|
||||
Test2.Code = MainCode.code();
|
||||
Test2.Filename = "test2.cc";
|
||||
AST = Test2.build();
|
||||
Index.updateMain(Test2.Filename, AST, AST.getLocalTopLevelDecls());
|
||||
Index.updateMain(Test2.Filename, AST);
|
||||
|
||||
EXPECT_THAT(getRefs(Index.index(), Foo.ID),
|
||||
RefsAre({AllOf(RefRange(MainCode.range("foo")),
|
||||
|
|
|
@ -244,7 +244,7 @@ TEST(MergeIndexTest, Refs) {
|
|||
Test.Code = Test1Code.code();
|
||||
Test.Filename = "test.cc";
|
||||
auto AST = Test.build();
|
||||
Dyn.updateMain(Test.Filename, AST, AST.getLocalTopLevelDecls());
|
||||
Dyn.updateMain(Test.Filename, AST);
|
||||
|
||||
// Build static index for test.cc.
|
||||
Test.HeaderCode = HeaderCode;
|
||||
|
@ -252,8 +252,7 @@ TEST(MergeIndexTest, Refs) {
|
|||
Test.Filename = "test.cc";
|
||||
auto StaticAST = Test.build();
|
||||
// Add stale refs for test.cc.
|
||||
StaticIndex.updateMain(Test.Filename, StaticAST,
|
||||
StaticAST.getLocalTopLevelDecls());
|
||||
StaticIndex.updateMain(Test.Filename, StaticAST);
|
||||
|
||||
// Add refs for test2.cc
|
||||
Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
|
||||
|
@ -262,8 +261,7 @@ TEST(MergeIndexTest, Refs) {
|
|||
Test2.Code = Test2Code.code();
|
||||
Test2.Filename = "test2.cc";
|
||||
StaticAST = Test2.build();
|
||||
StaticIndex.updateMain(Test2.Filename, StaticAST,
|
||||
StaticAST.getLocalTopLevelDecls());
|
||||
StaticIndex.updateMain(Test2.Filename, StaticAST);
|
||||
|
||||
RefsRequest Request;
|
||||
Request.IDs = {Foo.ID};
|
||||
|
|
|
@ -51,7 +51,7 @@ SymbolSlab TestTU::headerSymbols() const {
|
|||
// FIXME: This should return a FileIndex with both preamble and main index.
|
||||
std::unique_ptr<SymbolIndex> TestTU::index() const {
|
||||
auto AST = build();
|
||||
auto Content = indexMainDecls(AST, AST.getLocalTopLevelDecls());
|
||||
auto Content = indexMainDecls(AST);
|
||||
return MemIndex::build(std::move(Content.first), std::move(Content.second));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue