Skip to content

Commit 67a2fe4

Browse files
committed
Fix up compile operation kind
- `key.compile_operation` instead of `key.compileoperation` - Make the operation kind optional (nothing emitted for perform sema)
1 parent 40759df commit 67a2fe4

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

test/SourceKit/CompileNotifications/arg-parsing.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// ARG_PARSE_0: key.notification: source.notification.compile-will-start
55
// ARG_PARSE_0: key.compileid: [[CID1:".*"]]
66
// ARG_PARSE_0: key.compilerargs-string: "{{.*}}.swift -no-such-arg"
7-
// ARG_PARSE_0: key.compileoperation: source.compile.operation.code-completion
7+
// ARG_PARSE_0: key.compile_operation: source.compile.operation.code-completion
88
// ARG_PARSE_0: }
99
// ARG_PARSE_0: {
1010
// ARG_PARSE_0: key.notification: source.notification.compile-did-finish
@@ -16,7 +16,7 @@
1616
// ARG_PARSE_0: }
1717
// ARG_PARSE_0: ]
1818
// ARG_PARSE_0: key.compileid: [[CID1]]
19-
// ARG_PARSE_0: key.compileoperation: source.compile.operation.code-completion
19+
// ARG_PARSE_0: key.compile_operation: source.compile.operation.code-completion
2020
// ARG_PARSE_0: }
2121
// ARG_PARSE_0-NOT: compile-will-start
2222
// ARG_PARSE_0-NOT: compile-did-finish
@@ -27,7 +27,6 @@
2727
// ARG_PARSE_1: key.notification: source.notification.compile-will-start
2828
// ARG_PARSE_1: key.compileid: [[CID1:".*"]]
2929
// ARG_PARSE_1: key.compilerargs-string: "{{.*}}.swift -no-such-arg"
30-
// ARG_PARSE_1: key.compileoperation: source.compile.operation.perform-sema
3130
// ARG_PARSE_1: }
3231
// ARG_PARSE_1: {
3332
// ARG_PARSE_1: key.notification: source.notification.compile-did-finish
@@ -39,7 +38,6 @@
3938
// ARG_PARSE_1: }
4039
// ARG_PARSE_1: ]
4140
// ARG_PARSE_1: key.compileid: [[CID1]]
42-
// ARG_PARSE_1: key.compileoperation: source.compile.operation.perform-sema
4341
// ARG_PARSE_1: }
4442
// ARG_PARSE_1-NOT: compile-will-start
4543
// ARG_PARSE_1-NOT: compile-did-finish

test/SourceKit/CompileNotifications/code-completion.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// COMPILE_1: key.notification: source.notification.compile-will-start,
44
// COMPILE_1: key.filepath: "{{.*}}SOURCE_DIR{{.*}}code-completion.swift",
55
// COMPILE_1: key.compileid: [[CID1:".*"]]
6-
// COMPILE_1: key.compileoperation: source.compile.operation.code-completion
6+
// COMPILE_1: key.compile_operation: source.compile.operation.code-completion
77
// COMPILE_1: }
88
// COMPILE_1: {
99
// COMPILE_1: key.notification: source.notification.compile-did-finish,
1010
// COMPILE_1: key.compileid: [[CID1]]
11-
// COMPILE_1: key.compileoperation: source.compile.operation.code-completion
11+
// COMPILE_1: key.compile_operation: source.compile.operation.code-completion
1212
// COMPILE_1: }
1313
// COMPILE_1-NOT: compile-will-start
1414
// COMPILE_1-NOT: compile-did-finish

test/SourceKit/CompileNotifications/cursor-info.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
// COMPILE_1: key.notification: source.notification.compile-will-start,
44
// COMPILE_1: key.filepath: "SOURCE_DIR{{.*}}cursor-info.swift",
55
// COMPILE_1: key.compileid: [[CID1:".*"]]
6-
// COMPILE_1: key.compileoperation: source.compile.operation.perform-sema
76
// COMPILE_1: }
87
// COMPILE_1: {
98
// COMPILE_1: key.notification: source.notification.compile-did-finish,
109
// COMPILE_1: key.compileid: [[CID1]]
11-
// COMPILE_1: key.compileoperation: source.compile.operation.perform-sema
1210
// COMPILE_1: }
1311
// COMPILE_1: <empty cursor info; internal diagnostic: "Unable to resolve cursor info.">
1412
// COMPILE_1-NOT: compile-will-start

test/SourceKit/CompileNotifications/edits.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
// COMPILE_1: {
55
// COMPILE_1: key.notification: source.notification.compile-will-start,
66
// COMPILE_1: key.compileid: [[CID1:".*"]]
7-
// COMPILE_1: key.compileoperation: source.compile.operation.perform-sema
87
// COMPILE_1: }
98
// COMPILE_1: {
109
// COMPILE_1: key.notification: source.notification.compile-did-finish,
1110
// COMPILE_1: key.compileid: [[CID1]]
12-
// COMPILE_1: key.compileoperation: source.compile.operation.perform-sema
1311
// COMPILE_1: }
1412
// COMPILE_1-NOT: compile-will-start
1513
// COMPILE_1-NOT: compile-did-finish
@@ -21,32 +19,26 @@
2119
// COMPILE_3: {
2220
// COMPILE_3: key.notification: source.notification.compile-will-start,
2321
// COMPILE_3: key.compileid: [[CID1:".*"]]
24-
// COMPILE_3: key.compileoperation: source.compile.operation.perform-sema
2522
// COMPILE_3: }
2623
// COMPILE_3: {
2724
// COMPILE_3: key.notification: source.notification.compile-did-finish,
2825
// COMPILE_3: key.compileid: [[CID1]]
29-
// COMPILE_3: key.compileoperation: source.compile.operation.perform-sema
3026
// COMPILE_3: }
3127
// COMPILE_3: {
3228
// COMPILE_3: key.notification: source.notification.compile-will-start,
3329
// COMPILE_3: key.compileid: [[CID2:".*"]]
34-
// COMPILE_3: key.compileoperation: source.compile.operation.perform-sema
3530
// COMPILE_3: }
3631
// COMPILE_3: {
3732
// COMPILE_3: key.notification: source.notification.compile-did-finish,
3833
// COMPILE_3: key.compileid: [[CID2]]
39-
// COMPILE_3: key.compileoperation: source.compile.operation.perform-sema
4034
// COMPILE_3: }
4135
// COMPILE_3: {
4236
// COMPILE_3: key.notification: source.notification.compile-will-start,
4337
// COMPILE_3: key.compileid: [[CID3:".*"]]
44-
// COMPILE_3: key.compileoperation: source.compile.operation.perform-sema
4538
// COMPILE_3: }
4639
// COMPILE_3: {
4740
// COMPILE_3: key.notification: source.notification.compile-did-finish,
4841
// COMPILE_3: key.compileid: [[CID3]]
49-
// COMPILE_3: key.compileoperation: source.compile.operation.perform-sema
5042
// COMPILE_3: }
5143
// COMPILE_3-NOT: compile-will-start
5244
// COMPILE_3-NOT: compile-did-finish

tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,19 +3181,18 @@ class CompileTrackingConsumer final : public trace::TraceConsumer {
31813181
};
31823182
} // end anonymous namespace
31833183

3184-
static UIdent getUIDForOperationKind(trace::OperationKind OpKind) {
3185-
static UIdent CompileOperationPerformSema("source.compile.operation.perform-sema");
3184+
static Optional<UIdent> getUIDForOperationKind(trace::OperationKind OpKind) {
31863185
static UIdent CompileOperationIndexSource("source.compile.operation.index-source");
31873186
static UIdent CompileOperationCodeCompletion("source.compile.operation.code-completion");
31883187
switch (OpKind) {
31893188
case trace::OperationKind::PerformSema:
3190-
return CompileOperationPerformSema;
3189+
return None;
31913190
case trace::OperationKind::IndexSource:
31923191
return CompileOperationIndexSource;
31933192
case trace::OperationKind::CodeCompletion:
31943193
return CompileOperationCodeCompletion;
31953194
case trace::OperationKind::All:
3196-
return CompileOperationPerformSema;
3195+
return None;
31973196
}
31983197
}
31993198

@@ -3209,7 +3208,9 @@ void CompileTrackingConsumer::operationStarted(
32093208
Dict.set(KeyNotification, CompileWillStartUID);
32103209
Dict.set(KeyCompileID, std::to_string(OpId));
32113210
Dict.set(KeyFilePath, Inv.Args.PrimaryFile);
3212-
Dict.set(KeyCompileOperation, getUIDForOperationKind(OpKind));
3211+
if (auto OperationUID = getUIDForOperationKind(OpKind)) {
3212+
Dict.set(KeyCompileOperation, OperationUID.getValue());
3213+
}
32133214
Dict.set(KeyCompilerArgsString, Inv.Args.Arguments);
32143215
sourcekitd::postNotification(RespBuilder.createResponse());
32153216
}
@@ -3225,7 +3226,9 @@ void CompileTrackingConsumer::operationFinished(
32253226
auto Dict = RespBuilder.getDictionary();
32263227
Dict.set(KeyNotification, CompileDidFinishUID);
32273228
Dict.set(KeyCompileID, std::to_string(OpId));
3228-
Dict.set(KeyCompileOperation, getUIDForOperationKind(OpKind));
3229+
if (auto OperationUID = getUIDForOperationKind(OpKind)) {
3230+
Dict.set(KeyCompileOperation, OperationUID.getValue());
3231+
}
32293232
auto DiagArray = Dict.setArray(KeyDiagnostics);
32303233
for (const auto &DiagInfo : Diagnostics) {
32313234
fillDictionaryForDiagnosticInfo(DiagArray.appendDictionary(), DiagInfo);

utils/gyb_sourcekit_support/UIDs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def __init__(self, internal_name, external_name):
182182
KEY('CompletionCheckDependencyInterval',
183183
'key.completion_check_dependency_interval'),
184184
KEY('AnnotatedTypename', 'key.annotated.typename'),
185-
KEY('CompileOperation', 'key.compileoperation'),
185+
KEY('CompileOperation', 'key.compile_operation'),
186186
]
187187

188188

0 commit comments

Comments
 (0)