@@ -81,13 +81,6 @@ class AutomaticSwiftShield: Protector {
81
81
}
82
82
let name = data. name
83
83
let usr = data. usr
84
- let kind = data. kind
85
-
86
- if let type = self . sourceKit. referenceType ( kind: kind) , type == . enum && name. hasSuffix ( " CodingKeys " ) {
87
- obfuscationData. excludedEnums. insert ( self . usrWithoutSuffix ( usr) )
88
- return
89
- }
90
-
91
84
obfuscationData. usrDict. insert ( usr)
92
85
if dict. getString ( . receiverId) == nil {
93
86
obfuscationData. usrRelationDict [ usr] = variant
@@ -137,8 +130,7 @@ extension AutomaticSwiftShield {
137
130
private func getNameData( from dict: SourceKitdResponse . Dictionary ,
138
131
obfuscationData: ObfuscationData ) -> ( name: String ,
139
132
usr: String ,
140
- obfuscatedName: String ,
141
- kind: String ) ? {
133
+ obfuscatedName: String ) ? {
142
134
let kind = dict. getUID ( . kindId) . asString
143
135
guard sourceKit. declarationType ( for: kind) != nil else {
144
136
return nil
@@ -150,18 +142,9 @@ extension AutomaticSwiftShield {
150
142
guard let protected = obfuscationData. obfuscationDict [ name] else {
151
143
let newName = String . random ( length: self . protectedClassNameSize, excluding: obfuscationData. allObfuscatedNames)
152
144
obfuscationData. obfuscationDict [ name] = newName
153
- return ( name, usr, newName, kind )
145
+ return ( name, usr, newName)
154
146
}
155
- return ( name, usr, protected, kind)
156
- }
157
-
158
- private func usrWithoutSuffix( _ usr: String ) -> String {
159
- let lastIndex = usr. lastIndex ( of: " _ " )
160
- if let index = lastIndex {
161
- let usrPrefix = usr [ ..< index]
162
- return String ( usrPrefix)
163
- }
164
- return usr
147
+ return ( name, usr, protected)
165
148
}
166
149
167
150
func findReferencesInIndexed( obfuscationData: AutomaticObfuscationData ) {
@@ -182,11 +165,17 @@ extension AutomaticSwiftShield {
182
165
return
183
166
}
184
167
168
+ if type == . enum && name. hasSuffix ( " CodingKeys " ) {
169
+ obfuscationData. excludedEnums. insert ( usr)
170
+ return
171
+ }
185
172
186
173
if type == . enumelement {
187
- let usrPrefix = self . usrWithoutSuffix ( usr)
188
- if obfuscationData. excludedEnums. contains ( usrPrefix) {
189
- return
174
+ for exclusion in obfuscationData. excludedEnums {
175
+ // Enum element belongs to excluded enum
176
+ if usr. hasPrefix ( exclusion) {
177
+ return
178
+ }
190
179
}
191
180
}
192
181
0 commit comments