Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Sources/SymbolKit/SymbolGraph/Symbol/KindIdentifier.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2021 Apple Inc. and the Swift project authors
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See https://swift.org/LICENSE.txt for license information
Expand All @@ -23,6 +23,8 @@ extension SymbolGraph.Symbol {
case `func`
case `operator`
case `init`
case ivar
case macro
case method
case property
case `protocol`
Expand Down Expand Up @@ -53,6 +55,8 @@ extension SymbolGraph.Symbol {
case .func: return "func"
case .operator: return "func.op"
case .`init`: return "init"
case .ivar: return "ivar"
case .macro: return "macro"
case .method: return "method"
case .property: return "property"
case .protocol: return "protocol"
Expand Down Expand Up @@ -86,6 +90,8 @@ extension SymbolGraph.Symbol {
case "func": return .func
case "func.op": return .operator
case "init": return .`init`
case "ivar": return .ivar
case "macro": return .macro
case "method": return .method
case "property": return .property
case "protocol": return .protocol
Expand Down
12 changes: 11 additions & 1 deletion Tests/SymbolKitTests/SymbolGraph/Symbol/SymbolKindTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2021 Apple Inc. and the Swift project authors
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -91,4 +91,14 @@ class SymbolKindTests: XCTestCase {
XCTAssertEqual(kind.displayName, "Function")
}
}

/// Make sure that all the cases added to `KindIdentifier` can parse back as themselves
/// when their `identifier` string is given back to the `.init(identifier:)` initializer.
func testKindIdentifierRoundtrip() throws {
for identifier in SymbolGraph.Symbol.KindIdentifier.allCases {
let parsed = SymbolGraph.Symbol.KindIdentifier(identifier: identifier.identifier)

XCTAssertEqual(identifier, parsed)
}
}
}