@@ -106,6 +106,7 @@ class CompletionInstance {
106
106
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
107
107
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
108
108
DiagnosticConsumer *DiagC,
109
+ std::shared_ptr<std::atomic<bool >> CancellationFlag,
109
110
llvm::function_ref<void (CancellableResult<CompletionInstanceResult>)>
110
111
Callback);
111
112
@@ -119,6 +120,7 @@ class CompletionInstance {
119
120
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
120
121
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
121
122
DiagnosticConsumer *DiagC,
123
+ std::shared_ptr<std::atomic<bool >> CancellationFlag,
122
124
llvm::function_ref<void (CancellableResult<CompletionInstanceResult>)>
123
125
Callback);
124
126
@@ -129,6 +131,14 @@ class CompletionInstance {
129
131
// / In case of failure or cancellation, the callback receives the
130
132
// / corresponding failed or cancelled result.
131
133
// /
134
+ // / If \p CancellationFlag is not \c nullptr, code completion can be cancelled
135
+ // / by setting the flag to \c true.
136
+ // / IMPORTANT: If \p CancellationFlag is not \c nullptr, then completion might
137
+ // / be cancelled in the secon pass that's invoked inside \p Callback.
138
+ // / Therefore, \p Callback MUST check whether completion was cancelled before
139
+ // / interpreting the results, since invalid results may be returned in case
140
+ // / of cancellation.
141
+ // /
132
142
// / NOTE: \p Args is only used for checking the equaity of the invocation.
133
143
// / Since this function assumes that it is already normalized, exact the same
134
144
// / arguments including their order is considered as the same invocation.
@@ -137,6 +147,7 @@ class CompletionInstance {
137
147
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
138
148
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
139
149
DiagnosticConsumer *DiagC,
150
+ std::shared_ptr<std::atomic<bool >> CancellationFlag,
140
151
llvm::function_ref<void (CancellableResult<CompletionInstanceResult>)>
141
152
Callback);
142
153
@@ -155,13 +166,15 @@ class CompletionInstance {
155
166
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
156
167
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
157
168
DiagnosticConsumer *DiagC, ide::CodeCompletionContext &CompletionContext,
169
+ std::shared_ptr<std::atomic<bool >> CancellationFlag,
158
170
llvm::function_ref<void (CancellableResult<CodeCompleteResult>)> Callback);
159
171
160
172
void typeContextInfo (
161
173
swift::CompilerInvocation &Invocation, llvm::ArrayRef<const char *> Args,
162
174
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
163
175
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
164
176
DiagnosticConsumer *DiagC,
177
+ std::shared_ptr<std::atomic<bool >> CancellationFlag,
165
178
llvm::function_ref<void (CancellableResult<TypeContextInfoResult>)>
166
179
Callback);
167
180
@@ -170,6 +183,7 @@ class CompletionInstance {
170
183
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
171
184
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
172
185
DiagnosticConsumer *DiagC, ArrayRef<const char *> ExpectedTypeNames,
186
+ std::shared_ptr<std::atomic<bool >> CancellationFlag,
173
187
llvm::function_ref<void (CancellableResult<ConformingMethodListResults>)>
174
188
Callback);
175
189
};
0 commit comments