|
26 | 26 | #include "index/CanonicalIncludes.h"
|
27 | 27 | #include "index/FileIndex.h"
|
28 | 28 | #include "index/Merge.h"
|
29 |
| -#include "index/StdLib.h" |
30 | 29 | #include "refactor/Rename.h"
|
31 | 30 | #include "refactor/Tweak.h"
|
32 | 31 | #include "support/Cancellation.h"
|
@@ -60,39 +59,16 @@ namespace {
|
60 | 59 | // Update the FileIndex with new ASTs and plumb the diagnostics responses.
|
61 | 60 | struct UpdateIndexCallbacks : public ParsingCallbacks {
|
62 | 61 | UpdateIndexCallbacks(FileIndex *FIndex,
|
63 |
| - ClangdServer::Callbacks *ServerCallbacks, |
64 |
| - const ThreadsafeFS &TFS, AsyncTaskRunner *Tasks) |
65 |
| - : FIndex(FIndex), ServerCallbacks(ServerCallbacks), TFS(TFS), |
66 |
| - Tasks(Tasks) {} |
| 62 | + ClangdServer::Callbacks *ServerCallbacks) |
| 63 | + : FIndex(FIndex), ServerCallbacks(ServerCallbacks) {} |
67 | 64 |
|
68 |
| - void onPreambleAST(PathRef Path, llvm::StringRef Version, |
69 |
| - const CompilerInvocation &CI, ASTContext &Ctx, |
| 65 | + void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx, |
70 | 66 | Preprocessor &PP,
|
71 | 67 | const CanonicalIncludes &CanonIncludes) override {
|
72 |
| - // If this preamble uses a standard library we haven't seen yet, index it. |
73 |
| - if (FIndex) |
74 |
| - if (auto Loc = Stdlib.add(*CI.getLangOpts(), PP.getHeaderSearchInfo())) |
75 |
| - indexStdlib(CI, std::move(*Loc)); |
76 |
| - |
77 | 68 | if (FIndex)
|
78 | 69 | FIndex->updatePreamble(Path, Version, Ctx, PP, CanonIncludes);
|
79 | 70 | }
|
80 | 71 |
|
81 |
| - void indexStdlib(const CompilerInvocation &CI, StdLibLocation Loc) { |
82 |
| - auto Task = [this, LO(*CI.getLangOpts()), Loc(std::move(Loc)), |
83 |
| - CI(std::make_unique<CompilerInvocation>(CI))]() mutable { |
84 |
| - IndexFileIn IF; |
85 |
| - IF.Symbols = indexStandardLibrary(std::move(CI), Loc, TFS); |
86 |
| - if (Stdlib.isBest(LO)) |
87 |
| - FIndex->updatePreamble(std::move(IF)); |
88 |
| - }; |
89 |
| - if (Tasks) |
90 |
| - // This doesn't have a semaphore to enforce -j, but it's rare. |
91 |
| - Tasks->runAsync("IndexStdlib", std::move(Task)); |
92 |
| - else |
93 |
| - Task(); |
94 |
| - } |
95 |
| - |
96 | 72 | void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {
|
97 | 73 | if (FIndex)
|
98 | 74 | FIndex->updateMain(Path, AST);
|
@@ -127,9 +103,6 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
|
127 | 103 | private:
|
128 | 104 | FileIndex *FIndex;
|
129 | 105 | ClangdServer::Callbacks *ServerCallbacks;
|
130 |
| - const ThreadsafeFS &TFS; |
131 |
| - StdLibSet Stdlib; |
132 |
| - AsyncTaskRunner *Tasks; |
133 | 106 | };
|
134 | 107 |
|
135 | 108 | class DraftStoreFS : public ThreadsafeFS {
|
@@ -181,15 +154,12 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
|
181 | 154 | Transient(Opts.ImplicitCancellation ? TUScheduler::InvalidateOnUpdate
|
182 | 155 | : TUScheduler::NoInvalidation),
|
183 | 156 | DirtyFS(std::make_unique<DraftStoreFS>(TFS, DraftMgr)) {
|
184 |
| - if (Opts.AsyncThreadsCount != 0) |
185 |
| - IndexTasks.emplace(); |
186 | 157 | // Pass a callback into `WorkScheduler` to extract symbols from a newly
|
187 | 158 | // parsed file and rebuild the file index synchronously each time an AST
|
188 | 159 | // is parsed.
|
189 |
| - WorkScheduler.emplace(CDB, TUScheduler::Options(Opts), |
190 |
| - std::make_unique<UpdateIndexCallbacks>( |
191 |
| - DynamicIdx.get(), Callbacks, TFS, |
192 |
| - IndexTasks ? IndexTasks.getPointer() : nullptr)); |
| 160 | + WorkScheduler.emplace( |
| 161 | + CDB, TUScheduler::Options(Opts), |
| 162 | + std::make_unique<UpdateIndexCallbacks>(DynamicIdx.get(), Callbacks)); |
193 | 163 | // Adds an index to the stack, at higher priority than existing indexes.
|
194 | 164 | auto AddIndex = [&](SymbolIndex *Idx) {
|
195 | 165 | if (this->Index != nullptr) {
|
@@ -1005,9 +975,6 @@ ClangdServer::blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds) {
|
1005 | 975 | // and we're blocking the main thread.
|
1006 | 976 | if (!WorkScheduler->blockUntilIdle(timeoutSeconds(TimeoutSeconds)))
|
1007 | 977 | return false;
|
1008 |
| - // TUScheduler is the only thing that starts background indexing work. |
1009 |
| - if (IndexTasks && !IndexTasks->wait(timeoutSeconds(TimeoutSeconds))) |
1010 |
| - return false; |
1011 | 978 |
|
1012 | 979 | // Unfortunately we don't have strict topological order between the rest of
|
1013 | 980 | // the components. E.g. CDB broadcast triggers backrgound indexing.
|
|
0 commit comments