Skip to content

Commit 1b8799e

Browse files
committed
Add @GraphContentBuilder<NodeID> to graph content body
1 parent 962016a commit 1b8799e

14 files changed

+60
-42
lines changed

Sources/Grape/Contents/AnyGraphContent.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ public struct AnyGraphContent<NodeID: Hashable>: GraphContent {
99
self.storage = storage
1010
}
1111

12+
1213
@inlinable
1314
public var body: _IdentifiableNever<NodeID> {
14-
fatalError()
15+
_IdentifiableNever<_>()
1516
}
1617

1718
@inlinable

Sources/Grape/Contents/CompositedGraphContent.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Grape/Contents/GraphContent.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public protocol GraphContent<NodeID> {
99
func _attachToGraphRenderingContext(_ context: inout _GraphRenderingContext<NodeID>)
1010

1111
@inlinable
12+
@GraphContentBuilder<NodeID>
1213
var body: Body { get }
1314
}
1415

Sources/Grape/Contents/LinkMark.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ public struct LinkMark<NodeID: Hashable>: GraphContent & Identifiable {
55

66
@inlinable
77
public var body: _IdentifiableNever<NodeID> {
8-
fatalError()
8+
_IdentifiableNever<_>()
99
}
10+
1011
// public enum LabelDisplayStrategy {
1112
// case auto
1213
// case specified(Bool)

Sources/Grape/Contents/ModifiedGraphContent.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ extension ModifiedGraphContent: GraphContent {
5050
modifier._exit(&context)
5151
}
5252

53-
@inlinable
53+
54+
@inlinable
5455
public var body: _IdentifiableNever<NodeID> {
55-
fatalError()
56+
_IdentifiableNever<_>()
5657
}
5758
}

Sources/Grape/Contents/NodeMark.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public struct NodeMark<NodeID: Hashable>: GraphContent, Identifiable, Equatable
1515

1616
@inlinable
1717
public var body: _IdentifiableNever<NodeID> {
18-
fatalError()
18+
_IdentifiableNever<_>()
1919
}
20-
20+
2121
@inlinable
2222
public func _attachToGraphRenderingContext(_ context: inout _GraphRenderingContext<NodeID>) {
2323
context.nodeOperations.append(

Sources/Grape/Contents/_ArrayGraphContent.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ where C: GraphContent {
1313
self.storage = storage
1414
}
1515

16+
1617
@inlinable
1718
public var body: _IdentifiableNever<NodeID> {
18-
fatalError()
19+
_IdentifiableNever<_>()
1920
}
2021

2122
@inlinable

Sources/Grape/Contents/_ConditionalGraphContent.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ where C1: GraphContent, C2: GraphContent, C1.NodeID == C2.NodeID {
1818
self.storage = storage
1919
}
2020

21-
@inlinable
21+
22+
@inlinable
2223
public var body: _IdentifiableNever<NodeID> {
23-
fatalError()
24+
_IdentifiableNever<_>()
2425
}
2526

2627
@inlinable

Sources/Grape/Contents/_EmptyGraphContent.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
struct _EmptyGraphContent<NodeID: Hashable>: GraphContent {
33
@inlinable
44
public init() {
5-
5+
66
}
77
@inlinable
88
public func _attachToGraphRenderingContext(_ context: inout _GraphRenderingContext<NodeID>) {
9-
9+
1010
}
1111

12-
@inlinable
12+
@inlinable
1313
public var body: _IdentifiableNever<NodeID> {
14-
fatalError()
14+
_IdentifiableNever<_>()
1515
}
16-
}
16+
}

Sources/Grape/Contents/_IdentifiableNever.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
public enum _IdentifiableNever<ID: Hashable> { }
1+
public enum _IdentifiableNever<ID: Hashable> {
2+
@usableFromInline
3+
internal init() {
4+
fatalError()
5+
}
6+
}
7+
8+
9+
@inlinable
10+
public func _fatalError<ID>(of identityType: ID) -> _IdentifiableNever<ID> where ID: Hashable {
11+
_IdentifiableNever<ID>()
12+
}
213

314
extension _IdentifiableNever: GraphContent {
415
public typealias NodeID = ID
516

617
@inlinable
718
public var body: Self {
8-
fatalError()
19+
_IdentifiableNever<ID>()
920
}
1021

1122
@inlinable

0 commit comments

Comments
 (0)