Skip to content

Commit 076d5ca

Browse files
Revert "Revert "add ivar and macro to the known symbol kinds" (#24)"
This reverts commit 3cd58e7.
1 parent 3cd58e7 commit 076d5ca

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Sources/SymbolKit/SymbolGraph/Symbol/KindIdentifier.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

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

77
See https://swift.org/LICENSE.txt for license information
@@ -23,6 +23,8 @@ extension SymbolGraph.Symbol {
2323
case `func`
2424
case `operator`
2525
case `init`
26+
case ivar
27+
case macro
2628
case method
2729
case property
2830
case `protocol`
@@ -53,6 +55,8 @@ extension SymbolGraph.Symbol {
5355
case .func: return "func"
5456
case .operator: return "func.op"
5557
case .`init`: return "init"
58+
case .ivar: return "ivar"
59+
case .macro: return "macro"
5660
case .method: return "method"
5761
case .property: return "property"
5862
case .protocol: return "protocol"
@@ -86,6 +90,8 @@ extension SymbolGraph.Symbol {
8690
case "func": return .func
8791
case "func.op": return .operator
8892
case "init": return .`init`
93+
case "ivar": return .ivar
94+
case "macro": return .macro
8995
case "method": return .method
9096
case "property": return .property
9197
case "protocol": return .protocol

Tests/SymbolKitTests/SymbolGraph/Symbol/SymbolKindTests.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

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

77
See https://swift.org/LICENSE.txt for license information
@@ -91,4 +91,14 @@ class SymbolKindTests: XCTestCase {
9191
XCTAssertEqual(kind.displayName, "Function")
9292
}
9393
}
94+
95+
/// Make sure that all the cases added to `KindIdentifier` can parse back as themselves
96+
/// when their `identifier` string is given back to the `.init(identifier:)` initializer.
97+
func testKindIdentifierRoundtrip() throws {
98+
for identifier in SymbolGraph.Symbol.KindIdentifier.allCases {
99+
let parsed = SymbolGraph.Symbol.KindIdentifier(identifier: identifier.identifier)
100+
101+
XCTAssertEqual(identifier, parsed)
102+
}
103+
}
94104
}

0 commit comments

Comments
 (0)