Skip to content

Commit 11d347c

Browse files
simplify lookupIdentifier using allCases lookup
1 parent c3d58db commit 11d347c

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

Sources/SymbolKit/SymbolGraph/Symbol/Symbol.swift

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -391,28 +391,7 @@ extension SymbolGraph.Symbol {
391391
/// - Parameter identifier: The identifier string to check.
392392
/// - Returns: The matching `KindIdentifier` case, or `nil` if there was no match.
393393
private static func lookupIdentifier(identifier: String) -> KindIdentifier? {
394-
switch identifier {
395-
case "associatedtype" : return .associatedtype
396-
case "class" : return .class
397-
case "deinit" : return .deinit
398-
case "enum" : return .enum
399-
case "enum.case" : return .case
400-
case "func" : return .func
401-
case "func.op" : return .operator
402-
case "init" : return .`init`
403-
case "method" : return .method
404-
case "property" : return .property
405-
case "protocol" : return .protocol
406-
case "struct" : return .struct
407-
case "subscript" : return .subscript
408-
case "type.method" : return .typeMethod
409-
case "type.property" : return .typeProperty
410-
case "type.subscript" : return .typeSubscript
411-
case "typealias" : return .typealias
412-
case "var" : return .var
413-
case "module" : return .module
414-
default : return nil
415-
}
394+
allCases.first(where: { $0.identifier == identifier })
416395
}
417396

418397
/// Strips the first component of the given identifier string, so that (for example) `"swift.func"` will return `"func"`.

0 commit comments

Comments
 (0)