@@ -95,40 +95,65 @@ public class Module: Codable {
95
95
public init ( name: String = " Anonymous " , sourceFiles: [ SourceFile ] ) {
96
96
self . name = name
97
97
self . sourceFiles = sourceFiles
98
- self . symbols = sourceFiles. flatMap { $0. symbols } . filter { $0. isPublic }
98
+ self . symbols = sourceFiles. flatMap { $0. symbols }
99
+ . filter { $0. isPublic }
100
+ . sorted ( )
99
101
}
100
102
101
103
// MARK: -
102
104
103
105
public func members( of symbol: Symbol ) -> [ Symbol ] {
104
- return relationshipsByObject [ symbol. id] ? . filter { $0. predicate == . memberOf } . map { $0. subject } ?? [ ]
106
+ return relationshipsByObject [ symbol. id] ?
107
+ . filter { $0. predicate == . memberOf }
108
+ . map { $0. subject }
109
+ . sorted ( ) ?? [ ]
105
110
}
106
111
107
112
public func requirements( of symbol: Symbol ) -> [ Symbol ] {
108
- return relationshipsByObject [ symbol. id] ? . filter { $0. predicate == . requirementOf } . map { $0. subject } ?? [ ]
113
+ return relationshipsByObject [ symbol. id] ?
114
+ . filter { $0. predicate == . requirementOf }
115
+ . map { $0. subject }
116
+ . sorted ( ) ?? [ ]
109
117
}
110
118
111
119
public func optionalRequirements( of symbol: Symbol ) -> [ Symbol ] {
112
- return relationshipsByObject [ symbol. id] ? . filter { $0. predicate == . optionalRequirementOf } . map { $0. subject } ?? [ ]
120
+ return relationshipsByObject [ symbol. id] ?
121
+ . filter { $0. predicate == . optionalRequirementOf }
122
+ . map { $0. subject }
123
+ . sorted ( ) ?? [ ]
113
124
}
114
125
115
126
public func typesInherited( by symbol: Symbol ) -> [ Symbol ] {
116
- return relationshipsBySubject [ symbol. id] ? . filter { $0. predicate == . inheritsFrom } . map { $0. object } . sorted ( ) ?? [ ]
127
+ return relationshipsBySubject [ symbol. id] ?
128
+ . filter { $0. predicate == . inheritsFrom }
129
+ . map { $0. object }
130
+ . sorted ( ) ?? [ ]
117
131
}
118
132
119
133
public func typesInheriting( from symbol: Symbol ) -> [ Symbol ] {
120
- return relationshipsByObject [ symbol. id] ? . filter { $0. predicate == . inheritsFrom } . map { $0. subject } . sorted ( ) ?? [ ]
134
+ return relationshipsByObject [ symbol. id] ?
135
+ . filter { $0. predicate == . inheritsFrom }
136
+ . map { $0. subject }
137
+ . sorted ( ) ?? [ ]
121
138
}
122
139
123
140
public func typesConformed( by symbol: Symbol ) -> [ Symbol ] {
124
- return relationshipsBySubject [ symbol. id] ? . filter { $0. predicate == . conformsTo } . map { $0. object } . sorted ( ) ?? [ ]
141
+ return relationshipsBySubject [ symbol. id] ?
142
+ . filter { $0. predicate == . conformsTo }
143
+ . map { $0. object }
144
+ . sorted ( ) ?? [ ]
125
145
}
126
146
127
147
public func typesConforming( to symbol: Symbol ) -> [ Symbol ] {
128
- return relationshipsByObject [ symbol. id] ? . filter { $0. predicate == . conformsTo } . map { $0. subject } . sorted ( ) ?? [ ]
148
+ return relationshipsByObject [ symbol. id] ?
149
+ . filter { $0. predicate == . conformsTo }
150
+ . map { $0. subject }
151
+ . sorted ( ) ?? [ ]
129
152
}
130
153
131
154
public func conditionalCounterparts( of symbol: Symbol ) -> [ Symbol ] {
132
- return symbolsByIdentifier [ symbol. id] ? . filter { $0 != symbol } ?? [ ]
155
+ return symbolsByIdentifier [ symbol. id] ?
156
+ . filter { $0 != symbol }
157
+ . sorted ( ) ?? [ ]
133
158
}
134
159
}
0 commit comments