@@ -3181,6 +3181,21 @@ class CompileTrackingConsumer final : public trace::TraceConsumer {
3181
3181
};
3182
3182
} // end anonymous namespace
3183
3183
3184
+ static Optional<UIdent> getUIDForOperationKind (trace::OperationKind OpKind) {
3185
+ static UIdent CompileOperationIndexSource (" source.compile.operation.index-source" );
3186
+ static UIdent CompileOperationCodeCompletion (" source.compile.operation.code-completion" );
3187
+ switch (OpKind) {
3188
+ case trace::OperationKind::PerformSema:
3189
+ return None;
3190
+ case trace::OperationKind::IndexSource:
3191
+ return CompileOperationIndexSource;
3192
+ case trace::OperationKind::CodeCompletion:
3193
+ return CompileOperationCodeCompletion;
3194
+ default :
3195
+ llvm_unreachable (" Unknown operation kind" );
3196
+ }
3197
+ }
3198
+
3184
3199
void CompileTrackingConsumer::operationStarted (
3185
3200
uint64_t OpId, trace::OperationKind OpKind,
3186
3201
const trace::SwiftInvocation &Inv, const trace::StringPairs &OpArgs) {
@@ -3193,7 +3208,9 @@ void CompileTrackingConsumer::operationStarted(
3193
3208
Dict.set (KeyNotification, CompileWillStartUID);
3194
3209
Dict.set (KeyCompileID, std::to_string (OpId));
3195
3210
Dict.set (KeyFilePath, Inv.Args .PrimaryFile );
3196
- // FIXME: OperationKind
3211
+ if (auto OperationUID = getUIDForOperationKind (OpKind)) {
3212
+ Dict.set (KeyCompileOperation, OperationUID.getValue ());
3213
+ }
3197
3214
Dict.set (KeyCompilerArgsString, Inv.Args .Arguments );
3198
3215
sourcekitd::postNotification (RespBuilder.createResponse ());
3199
3216
}
@@ -3209,6 +3226,9 @@ void CompileTrackingConsumer::operationFinished(
3209
3226
auto Dict = RespBuilder.getDictionary ();
3210
3227
Dict.set (KeyNotification, CompileDidFinishUID);
3211
3228
Dict.set (KeyCompileID, std::to_string (OpId));
3229
+ if (auto OperationUID = getUIDForOperationKind (OpKind)) {
3230
+ Dict.set (KeyCompileOperation, OperationUID.getValue ());
3231
+ }
3212
3232
auto DiagArray = Dict.setArray (KeyDiagnostics);
3213
3233
for (const auto &DiagInfo : Diagnostics) {
3214
3234
fillDictionaryForDiagnosticInfo (DiagArray.appendDictionary (), DiagInfo);
0 commit comments