Skip to content

Commit 89fc130

Browse files
authored
sourcekitd: duplicate sourcekitd UIDs should fail the build. (swiftlang#14796)
This ensures we can safely add new UIDs.
1 parent 92ace24 commit 89fc130

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def.gyb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
%{
22
# -*- mode: Python -*-
3-
from gyb_sourcekit_support.UIDs import UID_KEYS
4-
from gyb_sourcekit_support.UIDs import UID_REQUESTS
5-
from gyb_sourcekit_support.UIDs import UID_KINDS
3+
from gyb_sourcekit_support import *
4+
assert check_uid_duplication(), "Found UID duplication"
65
# Ignore the following admonition; it applies to the resulting .def file only
76
}%
87
//// Automatically Generated From ProtocolUIDs.def.gyb.

utils/gyb_sourcekit_support/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@
1414
# utils/gyb_sourcekit_support/ directory as a module.
1515
#
1616
# ----------------------------------------------------------------------------
17+
from UIDs import UID_KEYS
18+
from UIDs import UID_KINDS
19+
from UIDs import UID_REQUESTS
20+
21+
22+
def check_uid_duplication():
23+
all_external_names = [K.externalName for K in UID_KEYS] + \
24+
[R.externalName for R in UID_REQUESTS] + \
25+
[K.externalName for K in UID_KINDS]
26+
return len(all_external_names) == len(set(all_external_names))

0 commit comments

Comments
 (0)