Skip to content

Commit 781284a

Browse files
committed
implement more of the conforming types feature
1 parent a7d89e0 commit 781284a

File tree

57 files changed

+1002
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1002
-664
lines changed

Sources/SwiftinitPages/Sections/GroupSections.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ struct GroupSections
5656
extension GroupSections
5757
{
5858
init(_ context:IdentifiablePageContext<Unidoc.Scalar>,
59-
organizing groups:/*consuming*/ [Unidoc.Group],
59+
organizing groups:/*consuming*/ [Unidoc.AnyGroup],
6060
vertex:borrowing Unidoc.DeclVertex? = nil,
6161
bias:Unidoc.Scalar? = nil,
6262
mode:Mode? = nil)
6363
{
64-
let container:Unidoc.Group.ID?
64+
let container:Unidoc.Group?
6565
let generics:Generics
6666
if let vertex:Unidoc.DeclVertex = copy vertex
6767
{
@@ -89,7 +89,7 @@ extension GroupSections
8989
var extensions:[(Unidoc.ExtensionGroup, Partisanship, Genericness)] = []
9090
var curated:Set<Unidoc.Scalar> = [self.context.id]
9191

92-
for group:Unidoc.Group in groups
92+
for group:Unidoc.AnyGroup in groups
9393
{
9494
switch group
9595
{
@@ -233,7 +233,7 @@ extension GroupSections:HTML.OutputStreamable
233233

234234
$0[.ul]
235235
{
236-
for member:Unidoc.VertexLink in group.members
236+
for member:Unidoc.TopicMember in group.members
237237
{
238238
switch member
239239
{

Sources/SwiftinitPages/Surfaces/Swiftinit.VertexEndpoint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protocol _SwiftinitVertexEndpoint:Mongo.SingleOutputEndpoint
2222
static
2323
func response(
2424
vertex:consuming Unidoc.AnyVertex,
25-
groups:consuming [Unidoc.Group],
25+
groups:consuming [Unidoc.AnyGroup],
2626
tree:consuming Unidoc.TypeTree?,
2727
with context:IdentifiableResponseContext) throws -> HTTP.ServerResponse
2828
}
@@ -86,7 +86,7 @@ extension Swiftinit.VertexEndpoint where Self:HTTP.ServerEndpoint
8686
context.outlines += $0.outlines
8787
}
8888

89-
let groups:[Unidoc.Group] = principal.groups
89+
let groups:[Unidoc.AnyGroup] = principal.groups
9090
let tree:Unidoc.TypeTree? = principal.tree
9191

9292
let canonical:CanonicalVersion? = .init(principal: consume principal)

Sources/SwiftinitPages/Surfaces/Vertices/Swiftinit.BlogEndpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extension Swiftinit.BlogEndpoint:Swiftinit.VertexEndpoint, HTTP.ServerEndpoint
2828
public static
2929
func response(
3030
vertex:consuming Unidoc.AnyVertex,
31-
groups:consuming [Unidoc.Group],
31+
groups:consuming [Unidoc.AnyGroup],
3232
tree:consuming Unidoc.TypeTree?,
3333
with context:IdentifiableResponseContext) throws -> HTTP.ServerResponse
3434
{

Sources/SwiftinitPages/Surfaces/Vertices/Swiftinit.DocsEndpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension Swiftinit.DocsEndpoint:Swiftinit.VertexEndpoint, HTTP.ServerEndpoint
2929
public static
3030
func response(
3131
vertex:consuming Unidoc.AnyVertex,
32-
groups:consuming [Unidoc.Group],
32+
groups:consuming [Unidoc.AnyGroup],
3333
tree:consuming Unidoc.TypeTree?,
3434
with context:IdentifiableResponseContext) throws -> HTTP.ServerResponse
3535
{

Sources/SwiftinitPages/Surfaces/Vertices/Swiftinit.StatsEndpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension Swiftinit.StatsEndpoint:Swiftinit.VertexEndpoint, HTTP.ServerEndpoint
2929
public static
3030
func response(
3131
vertex:consuming Unidoc.AnyVertex,
32-
groups:consuming [Unidoc.Group],
32+
groups:consuming [Unidoc.AnyGroup],
3333
tree:consuming Unidoc.TypeTree?,
3434
with context:IdentifiableResponseContext) throws -> HTTP.ServerResponse
3535
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import MongoQL
22
import UnidocRecords
33

4-
extension Unidoc.Group:MongoMasterCodingModel
4+
extension Unidoc.AnyGroup:MongoMasterCodingModel
55
{
66
}

Sources/UnidocDB/Volumes/UnidocDatabase.Groups.AlignLatest.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ extension UnidocDatabase.Groups.AlignLatest:Mongo.UpdateQuery
3939

4040
$0.append
4141
{
42-
$0[Unidoc.Group[.id]] = .init { $0[.gte] = latest.lowerBound }
42+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.gte] = latest.lowerBound }
4343
}
4444
$0.append
4545
{
46-
$0[Unidoc.Group[.id]] = .init { $0[.lte] = latest.upperBound }
46+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.lte] = latest.upperBound }
4747
}
4848
$0.append
4949
{
50-
$0[Unidoc.Group[.realm]] = .init { $0[.ne] = self.realm }
50+
$0[Unidoc.AnyGroup[.realm]] = .init { $0[.ne] = self.realm }
5151
}
5252
}
5353
}
5454
$0[.u] = .init
5555
{
5656
$0[.set] = .init
5757
{
58-
$0[Unidoc.Group[.realm]] = self.realm
58+
$0[Unidoc.AnyGroup[.realm]] = self.realm
5959
}
6060
}
6161
}
@@ -71,37 +71,37 @@ extension UnidocDatabase.Groups.AlignLatest:Mongo.UpdateQuery
7171

7272
$0.append
7373
{
74-
$0[Unidoc.Group[.id]] = .init { $0[.gte] = all.lowerBound }
74+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.gte] = all.lowerBound }
7575
}
7676
$0.append
7777
{
78-
$0[Unidoc.Group[.id]] = .init { $0[.lte] = all.upperBound }
78+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.lte] = all.upperBound }
7979
}
8080
$0.append
8181
{
8282
$0[.or] = .init
8383
{
8484
$0.append
8585
{
86-
$0[Unidoc.Group[.id]] = .init { $0[.lt] = latest.lowerBound }
86+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.lt] = latest.lowerBound }
8787
}
8888
$0.append
8989
{
90-
$0[Unidoc.Group[.id]] = .init { $0[.gt] = latest.upperBound }
90+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.gt] = latest.upperBound }
9191
}
9292
}
9393
}
9494
$0.append
9595
{
96-
$0[Unidoc.Group[.realm]] = .init { $0[.exists] = true }
96+
$0[Unidoc.AnyGroup[.realm]] = .init { $0[.exists] = true }
9797
}
9898
}
9999
}
100100
$0[.u] = .init
101101
{
102102
$0[.unset] = .init
103103
{
104-
$0[Unidoc.Group[.realm]] = ()
104+
$0[Unidoc.AnyGroup[.realm]] = ()
105105
}
106106
}
107107
}

Sources/UnidocDB/Volumes/UnidocDatabase.Groups.ClearLatest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ extension UnidocDatabase.Groups.ClearLatest:Mongo.UpdateQuery
3535
{
3636
$0.append
3737
{
38-
$0[Unidoc.Group[.id]] = .init { $0[.gte] = range.lowerBound }
38+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.gte] = range.lowerBound }
3939
}
4040
$0.append
4141
{
42-
$0[Unidoc.Group[.id]] = .init { $0[.lte] = range.upperBound }
42+
$0[Unidoc.AnyGroup[.id]] = .init { $0[.lte] = range.upperBound }
4343
}
4444
$0.append
4545
{
46-
$0[Unidoc.Group[.realm]] = .init { $0[.exists] = true }
46+
$0[Unidoc.AnyGroup[.realm]] = .init { $0[.exists] = true }
4747
}
4848
}
4949
}
5050
$0[.u] = .init
5151
{
5252
$0[.unset] = .init
5353
{
54-
$0[Unidoc.Group[.realm]] = ()
54+
$0[Unidoc.AnyGroup[.realm]] = ()
5555
}
5656
}
5757
}

Sources/UnidocDB/Volumes/UnidocDatabase.Groups.swift

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,32 @@ extension UnidocDatabase.Groups
2323
let indexRealm:Mongo.CollectionIndex = .init("Realm",
2424
unique: true)
2525
{
26-
$0[Unidoc.Group[.id]] = (+)
27-
$0[Unidoc.Group[.realm]] = (+)
26+
$0[Unidoc.AnyGroup[.id]] = (+)
27+
$0[Unidoc.AnyGroup[.realm]] = (+)
2828
}
2929

3030
public static
3131
let indexScopeRealm:Mongo.CollectionIndex = .init("ScopeRealm",
3232
unique: false)
3333
{
34-
$0[Unidoc.Group[.scope]] = (+)
35-
$0[Unidoc.Group[.realm]] = (+)
34+
$0[Unidoc.AnyGroup[.layer]] = (+)
35+
$0[Unidoc.AnyGroup[.scope]] = (+)
36+
$0[Unidoc.AnyGroup[.realm]] = (+)
3637
}
3738

3839
public static
3940
let indexScope:Mongo.CollectionIndex = .init("Scope",
4041
unique: true)
4142
{
42-
$0[Unidoc.Group[.scope]] = (+)
43-
$0[Unidoc.Group[.id]] = (+)
43+
$0[Unidoc.AnyGroup[.layer]] = (+)
44+
$0[Unidoc.AnyGroup[.scope]] = (+)
45+
$0[Unidoc.AnyGroup[.id]] = (+)
4446
}
4547
}
4648
extension UnidocDatabase.Groups:Mongo.CollectionModel
4749
{
4850
public
49-
typealias Element = Unidoc.Group
51+
typealias Element = Unidoc.AnyGroup
5052

5153
@inlinable public static
5254
var name:Mongo.Collection { "VolumeGroups" }
@@ -76,22 +78,32 @@ extension UnidocDatabase.Groups
7678
}
7779
documents:
7880
{
79-
$0 += groups.polygons.lazy.map(Unidoc.Group.polygonal(_:))
80-
$0 += groups.topics.lazy.map(Unidoc.Group.topic(_:))
81+
$0 += groups.polygons.lazy.map(Unidoc.AnyGroup.polygonal(_:))
82+
$0 += groups.topics.lazy.map(Unidoc.AnyGroup.topic(_:))
8183

8284
guard
8385
let realm:Unidoc.Realm
8486
else
8587
{
86-
$0 += groups.extensions.lazy.map(Unidoc.Group.extension(_:))
88+
$0 += groups.conformers.lazy.map(Unidoc.AnyGroup.conformers(_:))
89+
$0 += groups.extensions.lazy.map(Unidoc.AnyGroup.extension(_:))
8790
return
8891
}
8992

90-
for e:Unidoc.ExtensionGroup in groups.extensions
93+
for group:Unidoc.ConformerGroup in groups.conformers
9194
{
92-
$0[Unidoc.Group.CodingKey.self]
95+
$0[Unidoc.AnyGroup.CodingKey.self]
9396
{
94-
Unidoc.Group.extension(e).encode(to: &$0)
97+
Unidoc.AnyGroup.conformers(group).encode(to: &$0)
98+
99+
$0[.realm] = realm
100+
}
101+
}
102+
for group:Unidoc.ExtensionGroup in groups.extensions
103+
{
104+
$0[Unidoc.AnyGroup.CodingKey.self]
105+
{
106+
Unidoc.AnyGroup.extension(group).encode(to: &$0)
95107

96108
$0[.realm] = realm
97109
}

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,27 @@ extension Unidoc.Linker.TreeMapper
6363
{
6464
mutating
6565
func register(foreign:Unidoc.Scalar,
66+
with context:borrowing Unidoc.Linker,
67+
as index:Int) -> Unidoc.ForeignVertex?
68+
{
69+
{
70+
if case nil = $0
71+
{
72+
let vertex:Unidoc.ForeignVertex = Self.create(foreign: foreign,
73+
with: context,
74+
as: index)
75+
$0 = (vertex.shoot, vertex.flags)
76+
return vertex
77+
}
78+
else
79+
{
80+
return nil
81+
}
82+
} (&self.foreign[foreign])
83+
}
84+
85+
private static
86+
func create(foreign:Unidoc.Scalar,
6687
with context:borrowing Unidoc.Linker,
6788
as index:Int) -> Unidoc.ForeignVertex
6889
{
@@ -88,7 +109,7 @@ extension Unidoc.Linker.TreeMapper
88109
/// Our policy for hashing out-of-package types is to hash if the type uses a
89110
/// hash suffix in its home package, even if the type would not require any
90111
/// disambiguation in this package.
91-
let vertex:Unidoc.ForeignVertex = .init(id: context.current.id + index * .foreign,
112+
return .init(id: context.current.id + index * .foreign,
92113
extendee: foreign,
93114
scope: snapshot.scope(of: node).map { context.expand($0) } ?? [],
94115
flags: .init(
@@ -98,10 +119,6 @@ extension Unidoc.Linker.TreeMapper
98119
route: decl.route),
99120
stem: .decl(namespace, decl.path, orientation: decl.phylum.orientation),
100121
hash: .init(hashing: "\(symbol)"))
101-
102-
self.foreign[foreign] = (vertex.shoot, vertex.flags)
103-
104-
return vertex
105122
}
106123
}
107124
extension Unidoc.Linker.TreeMapper

0 commit comments

Comments
 (0)