Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change KindIdentifier into a struct to handle unknown symbol kinds #7

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
simplify lookupIdentifier using allCases lookup
QuietMisdreavus committed Apr 8, 2022
commit a1339c13a1a936b88988efc5450d2755a4384ab7
25 changes: 1 addition & 24 deletions Sources/SymbolKit/SymbolGraph/Symbol/KindIdentifier.swift
Original file line number Diff line number Diff line change
@@ -72,30 +72,7 @@ extension SymbolGraph.Symbol {
/// - Parameter identifier: The identifier string to check.
/// - Returns: The matching `KindIdentifier` case, or `nil` if there was no match.
private static func lookupIdentifier(identifier: String) -> KindIdentifier? {
switch identifier {
case "associatedtype": return .associatedtype
case "class": return .class
case "deinit": return .deinit
case "enum": return .enum
case "enum.case": return .case
case "func": return .func
case "func.op": return .operator
case "init": return .`init`
case "method": return .method
case "property": return .property
case "protocol": return .protocol
case "snippet": return .snippet
case "snippetGroup": return .snippetGroup
case "struct": return .struct
case "subscript": return .subscript
case "type.method": return .typeMethod
case "type.property": return .typeProperty
case "type.subscript": return .typeSubscript
case "typealias": return .typealias
case "var": return .var
case "module": return .module
default: return nil
}
allCases.first(where: { $0.identifier == identifier })
}

/// Compares the given identifier against the known default symbol kinds, and returns whether it matches one.