Skip to content

Commit 68febd3

Browse files
committed
separate Unidoc.Group.ID more cleanly from Unidoc.Scalar
1 parent d7c507e commit 68febd3

23 files changed

+150
-184
lines changed

Sources/SwiftinitPages/Sections/GroupSections.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension GroupSections
116116
case .polygon(let group):
117117
guard
118118
let first:Unidoc.Scalar = group.members.first,
119-
let plane:SymbolGraph.Plane = .of(first.citizen)
119+
let plane:SymbolGraph.Plane = first.plane
120120
else
121121
{
122122
continue

Sources/SymbolGraphs/Grouping/SymbolGraph.AutogroupPlane.swift

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

Sources/SymbolGraphs/Grouping/SymbolGraph.ExtensionPlane.swift

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

Sources/SymbolGraphs/Grouping/SymbolGraph.TopicPlane.swift

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

Sources/SymbolGraphs/Planes/SymbolGraph.Plane.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ extension SymbolGraph
1313
//
1414
// These were once used alongside the vertex planes, but we don’t mix them anymore
1515
// and arguably they shouldn’t be in the same enum at all.
16+
@available(*, unavailable)
1617
case autogroup = 0xC0_000000
18+
@available(*, unavailable)
1719
case `extension` = 0xC2_000000
20+
@available(*, unavailable)
1821
case topic = 0xC3_000000
1922

2023
// Used to identify vertices generated by the linker; never appear in a symbol graph.

Sources/UnidocLinker/Curation/Unidoc.Counter.swift

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

Sources/UnidocLinker/Curation/Unidoc.Linker.TreeMapper.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@ extension Unidoc.Linker
2222
private
2323
var trees:[Unidoc.Scalar: TreeMembers]
2424

25-
private
26-
var next:Unidoc.Counter<SymbolGraph.ForeignPlane>
27-
2825
init(zone:Unidoc.Edition)
2926
{
3027
self.foreign = [:]
3128
self.local = [:]
3229
self.trees = [:]
33-
34-
self.next = .init(zone: zone)
3530
}
3631
}
3732
}
@@ -68,7 +63,8 @@ extension Unidoc.Linker.TreeMapper
6863
{
6964
mutating
7065
func register(foreign:Unidoc.Scalar,
71-
with context:borrowing Unidoc.Linker) -> Unidoc.ForeignVertex
66+
with context:borrowing Unidoc.Linker,
67+
as index:Int) -> Unidoc.ForeignVertex
7268
{
7369
guard
7470
let snapshot:Unidoc.Linker.Graph = context[foreign.package]
@@ -92,7 +88,7 @@ extension Unidoc.Linker.TreeMapper
9288
/// Our policy for hashing out-of-package types is to hash if the type uses a
9389
/// hash suffix in its home package, even if the type would not require any
9490
/// disambiguation in this package.
95-
let vertex:Unidoc.ForeignVertex = .init(id: self.next.id(),
91+
let vertex:Unidoc.ForeignVertex = .init(id: context.current.id + index * .foreign,
9692
extendee: foreign,
9793
scope: snapshot.scope(of: node).map { context.expand($0) } ?? [],
9894
flags: .init(
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
extension Unidoc.Linker.Tables
2+
{
3+
struct Counter
4+
{
5+
private
6+
var index:Int
7+
8+
init()
9+
{
10+
self.index = 0
11+
}
12+
}
13+
}
14+
extension Unidoc.Linker.Tables.Counter
15+
{
16+
mutating
17+
func callAsFunction() -> Int
18+
{
19+
defer { self.index += 1 }
20+
return self.index
21+
}
22+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import UnidocRecords
2+
3+
extension Unidoc.Linker.Tables
4+
{
5+
struct Next
6+
{
7+
private
8+
var polygons:Counter
9+
private
10+
var topics:Counter
11+
private
12+
let base:Unidoc.Edition
13+
14+
init(base:Unidoc.Edition)
15+
{
16+
self.polygons = .init()
17+
self.topics = .init()
18+
self.base = base
19+
}
20+
}
21+
}
22+
extension Unidoc.Linker.Tables.Next
23+
{
24+
mutating
25+
func polygon() -> Unidoc.Group.ID
26+
{
27+
self.base[group: self.polygons() * .polygon]
28+
}
29+
30+
mutating
31+
func topic() -> Unidoc.Group.ID
32+
{
33+
self.base[group: self.topics() * .topic]
34+
}
35+
}

Sources/UnidocLinker/Sema/Unidoc.Linker.Tables.swift

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ extension Unidoc.Linker
3535
var groupContainingMember:[Int32: Unidoc.Group.ID]
3636

3737
private
38-
var next:
39-
(
40-
polygon:Unidoc.Counter<SymbolGraph.AutogroupPlane>,
41-
topic:Unidoc.Counter<SymbolGraph.TopicPlane>
42-
)
38+
var next:Next
4339

4440
private(set)
4541
var extensions:Extensions
@@ -63,8 +59,7 @@ extension Unidoc.Linker
6359
self.extensionContainingNested = extensions.byNested()
6460
self.groupContainingMember = [:]
6561

66-
self.next.polygon = .init(zone: self.context.current.id)
67-
self.next.topic = .init(zone: self.context.current.id)
62+
self.next = .init(base: self.context.current.id)
6863

6964
self.extensions = extensions
7065
self.articles = []
@@ -144,7 +139,7 @@ extension Unidoc.Linker.Tables
144139
mutating
145140
func linkProducts() -> [Unidoc.ProductVertex]
146141
{
147-
var productPolygon:Unidoc.Group.Polygon = .init(id: self.next.polygon.id(),
142+
var productPolygon:Unidoc.Group.Polygon = .init(id: self.next.polygon(),
148143
scope: self.current.id.global)
149144

150145
var products:[Unidoc.ProductVertex] = []
@@ -188,7 +183,7 @@ extension Unidoc.Linker.Tables
188183

189184
// Create a synthetic topic containing all the cultures. This will become a “See Also”
190185
// for their module pages, unless they belong to a custom topic group.
191-
let culturePolygon:Unidoc.Group.Polygon = .init(id: self.next.polygon.id(),
186+
let culturePolygon:Unidoc.Group.Polygon = .init(id: self.next.polygon(),
192187
scope: self.current.id.global,
193188
members: self.current.cultures.indices.sorted
194189
{
@@ -335,8 +330,8 @@ extension Unidoc.Linker.Tables
335330
continue
336331
}
337332

338-
// Create top-level autogroup.
339-
self.groups.polygons.append(.init(id: self.next.polygon.id(),
333+
// Create top-level polygon.
334+
self.groups.polygons.append(.init(id: self.next.polygon(),
340335
scope: namespace.culture,
341336
members: self.context.sort(lexically: consume miscellaneous)))
342337
}
@@ -363,7 +358,7 @@ extension Unidoc.Linker.Tables
363358
{
364359
for topic:SymbolGraph.Topic in topics
365360
{
366-
var record:Unidoc.Group.Topic = .init(id: self.next.topic.id(),
361+
var record:Unidoc.Group.Topic = .init(id: self.next.topic(),
367362
culture: namespace.culture,
368363
scope: owner)
369364

0 commit comments

Comments
 (0)