Skip to content

Commit 753e4a9

Browse files
committed
fix(ci): ignore quoted Swift event constants
1 parent 122a5fd commit 753e4a9

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

scripts/check-protocol-event-coverage.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ export function extractSwiftHandledEvents(source, constants = new Map()) {
196196
const label = SWIFT_CASE_LABEL_RE.exec(line);
197197
if (label) {
198198
pushStringLiterals(label[1], sink);
199-
for (const reference of label[1].matchAll(SWIFT_QUALIFIED_CONSTANT_RE)) {
199+
const constantReferences = sanitizeLineForBraces(label[1]);
200+
for (const reference of constantReferences.matchAll(SWIFT_QUALIFIED_CONSTANT_RE)) {
200201
const value = constants.get(reference[1]);
201202
if (value) {
202203
sink.push(value);

test/scripts/check-protocol-event-coverage.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,27 @@ describe("extractSwiftHandledEvents", () => {
109109

110110
expect([...constants]).toEqual([["ApprovalBridge.requestedKind", "exec.approval.requested"]]);
111111
});
112+
113+
it("does not resolve qualified constants inside quoted case labels", () => {
114+
const constants = extractSwiftStaticStringConstants(`
115+
enum ApprovalBridge {
116+
static let requestedKind = "exec.approval.requested"
117+
}
118+
`);
119+
const handled = extractSwiftHandledEvents(
120+
`
121+
switch evt.event {
122+
case "ApprovalBridge.requestedKind":
123+
return .approval
124+
default:
125+
return nil
126+
}
127+
`,
128+
constants,
129+
);
130+
131+
expect(handled).toEqual(new Set(["ApprovalBridge.requestedKind"]));
132+
});
112133
});
113134

114135
describe("extractKotlinHandledEvents", () => {

0 commit comments

Comments
 (0)