File tree Expand file tree Collapse file tree 4 files changed +16
-1
lines changed Expand file tree Collapse file tree 4 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,8 @@ ClangdServer::Options::operator TUScheduler::Options() const {
139
139
ClangdServer::ClangdServer (const GlobalCompilationDatabase &CDB,
140
140
const ThreadsafeFS &TFS, const Options &Opts,
141
141
Callbacks *Callbacks)
142
- : ConfigProvider(Opts.ConfigProvider), TFS(TFS), ServerCallbacks(Callbacks),
142
+ : ConfigProvider(Opts.ConfigProvider), CDB(CDB), TFS(TFS),
143
+ ServerCallbacks(Callbacks),
143
144
DynamicIdx(Opts.BuildDynamicSymbolIndex
144
145
? new FileIndex(Opts.HeavyweightDynamicSymbolIndex,
145
146
Opts.CollectMainFileRefs)
@@ -870,6 +871,7 @@ Context ClangdServer::createProcessingContext(PathRef File) const {
870
871
LLVM_NODISCARD bool
871
872
ClangdServer::blockUntilIdleForTest (llvm::Optional<double > TimeoutSeconds) {
872
873
return WorkScheduler.blockUntilIdle (timeoutSeconds (TimeoutSeconds)) &&
874
+ CDB.blockUntilIdle (timeoutSeconds (TimeoutSeconds)) &&
873
875
(!BackgroundIdx ||
874
876
BackgroundIdx->blockUntilIdleForTest (TimeoutSeconds));
875
877
}
Original file line number Diff line number Diff line change @@ -362,6 +362,7 @@ class ClangdServer {
362
362
Context createProcessingContext (PathRef) const ;
363
363
config::Provider *ConfigProvider = nullptr ;
364
364
365
+ const GlobalCompilationDatabase &CDB;
365
366
const ThreadsafeFS &TFS;
366
367
Callbacks *ServerCallbacks = nullptr ;
367
368
mutable std::mutex ConfigDiagnosticsMu;
Original file line number Diff line number Diff line change @@ -636,5 +636,11 @@ tooling::CompileCommand DelegatingCDB::getFallbackCommand(PathRef File) const {
636
636
return Base->getFallbackCommand (File);
637
637
}
638
638
639
+ bool DelegatingCDB::blockUntilIdle (Deadline D) const {
640
+ if (!Base)
641
+ return true ;
642
+ return Base->blockUntilIdle (D);
643
+ }
644
+
639
645
} // namespace clangd
640
646
} // namespace clang
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ class GlobalCompilationDatabase {
51
51
// / Clangd should treat the results as unreliable.
52
52
virtual tooling::CompileCommand getFallbackCommand (PathRef File) const ;
53
53
54
+ // / If the CDB does any asynchronous work, wait for it to complete.
55
+ // / For use in tests.
56
+ virtual bool blockUntilIdle (Deadline D) const { return true ; }
57
+
54
58
using CommandChanged = Event<std::vector<std::string>>;
55
59
// / The callback is notified when files may have new compile commands.
56
60
// / The argument is a list of full file paths.
@@ -75,6 +79,8 @@ class DelegatingCDB : public GlobalCompilationDatabase {
75
79
76
80
tooling::CompileCommand getFallbackCommand (PathRef File) const override ;
77
81
82
+ bool blockUntilIdle (Deadline D) const override ;
83
+
78
84
private:
79
85
const GlobalCompilationDatabase *Base;
80
86
std::unique_ptr<GlobalCompilationDatabase> BaseOwner;
You can’t perform that action at this time.
0 commit comments