@@ -10,16 +10,18 @@ public final class Interface {
10
10
self . imports = imports
11
11
self . symbols = symbols
12
12
13
- self . symbolsGroupedByIdentifier = Dictionary ( grouping: symbols, by: { $0. id } )
14
- self . symbolsGroupedByQualifiedName = Dictionary ( grouping: symbols, by: { $0. id. description } )
15
- self . topLevelSymbols = symbols. filter { $0. api is Type || $0. id. pathComponents. isEmpty }
13
+ let symbolsGroupedByIdentifier = Dictionary ( grouping: symbols, by: { $0. id } )
14
+ let symbolsGroupedByQualifiedName = Dictionary ( grouping: symbols, by: { $0. id. description } )
15
+
16
+ self . symbolsGroupedByIdentifier = symbolsGroupedByIdentifier
17
+ self . symbolsGroupedByQualifiedName = symbolsGroupedByQualifiedName
18
+ self . topLevelSymbols = symbols. filter { $0. api is Type || $0. id. context. isEmpty }
16
19
17
20
self . relationships = {
18
21
let extensionsByExtendedType : [ String : [ Extension ] ] = Dictionary ( grouping: symbols. flatMap { $0. context. compactMap { $0 as? Extension } } , by: { $0. extendedType } )
19
22
20
23
var relationships : Set < Relationship > = [ ]
21
24
for symbol in symbols {
22
-
23
25
let lastDeclarationScope = symbol. context. last ( where: { $0 is Extension || $0 is Symbol } )
24
26
25
27
if let container = lastDeclarationScope as? Symbol {
@@ -40,8 +42,7 @@ public final class Interface {
40
42
}
41
43
42
44
if let `extension` = lastDeclarationScope as? Extension {
43
- if let extended = symbols. first ( where: { $0. api is Type && $0. id. matches ( `extension`. extendedType) } ) {
44
-
45
+ for extended in symbolsGroupedByIdentifier. named ( `extension`. extendedType, resolvingTypealiases: true ) {
45
46
let predicate : Relationship . Predicate
46
47
switch extended. api {
47
48
case is Protocol :
@@ -66,7 +67,7 @@ public final class Interface {
66
67
inheritedTypeNames = Set ( inheritedTypeNames. flatMap { $0. split ( separator: " & " ) . map { $0. trimmingCharacters ( in: . whitespaces) } } )
67
68
68
69
for name in inheritedTypeNames {
69
- let inheritedTypes = symbols . filter ( { ( $0. api is Class || $0. api is Protocol ) && $0. id. description == name } )
70
+ let inheritedTypes = symbolsGroupedByIdentifier . named ( name , resolvingTypealiases : true ) . filter ( { ( $0. api is Class || $0. api is Protocol ) && $0. id. description == name } )
70
71
if inheritedTypes. isEmpty {
71
72
let inherited = Symbol ( api: Unknown ( name: name) , context: [ ] , declaration: [ ] , documentation: nil , sourceRange: nil )
72
73
relationships. insert ( Relationship ( subject: symbol, predicate: . conformsTo, object: inherited) )
@@ -115,7 +116,6 @@ public final class Interface {
115
116
}
116
117
117
118
return classClusters
118
-
119
119
}
120
120
121
121
public let relationships : [ Relationship ]
0 commit comments