@@ -10,17 +10,20 @@ public final class Symbol {
10
10
public let context : [ Contextual ]
11
11
public let declaration : [ Token ]
12
12
public let documentation : Documentation ?
13
- public let sourceLocation : SourceLocation ?
13
+ public let sourceRange : SourceRange ?
14
+
15
+ @available ( swift, deprecated: 0.0 . 1 , message: " Use sourceRange instead " )
16
+ public var sourceLocation : SourceLocation ? { sourceRange? . start }
14
17
15
18
public private( set) lazy var `extension` : Extension ? = context. compactMap { $0 as? Extension } . first
16
19
public private( set) lazy var conditions : [ CompilationCondition ] = context. compactMap { $0 as? CompilationCondition }
17
20
18
- init ( api: API , context: [ Contextual ] , declaration: [ Token ] , documentation: Documentation ? , sourceLocation : SourceLocation ? ) {
21
+ init ( api: API , context: [ Contextual ] , declaration: [ Token ] , documentation: Documentation ? , sourceRange : SourceRange ? ) {
19
22
self . api = api
20
23
self . context = context
21
24
self . declaration = declaration
22
25
self . documentation = documentation
23
- self . sourceLocation = sourceLocation
26
+ self . sourceRange = sourceRange
24
27
}
25
28
26
29
public var name : String {
@@ -114,8 +117,8 @@ public final class Symbol {
114
117
extension Symbol : Equatable {
115
118
public static func == ( lhs: Symbol , rhs: Symbol ) -> Bool {
116
119
guard lhs. documentation == rhs. documentation,
117
- lhs. sourceLocation == rhs. sourceLocation
118
- else { return false }
120
+ lhs. sourceRange == rhs. sourceRange
121
+ else { return false }
119
122
120
123
guard lhs. context. count == rhs. context. count else { return false }
121
124
for (lc, rc) in zip ( lhs. context, rhs. context) {
@@ -170,8 +173,8 @@ extension Symbol: Equatable {
170
173
171
174
extension Symbol : Comparable {
172
175
public static func < ( lhs: Symbol , rhs: Symbol ) -> Bool {
173
- if let lsl = lhs. sourceLocation , let rsl = rhs. sourceLocation {
174
- return lsl < rsl
176
+ if let lsr = lhs. sourceRange , let rsr = rhs. sourceRange {
177
+ return lsr < rsr
175
178
} else {
176
179
return lhs. name < rhs. name
177
180
}
@@ -183,7 +186,7 @@ extension Symbol: Comparable {
183
186
extension Symbol : Hashable {
184
187
public func hash( into hasher: inout Hasher ) {
185
188
hasher. combine ( documentation)
186
- hasher. combine ( sourceLocation )
189
+ hasher. combine ( sourceRange )
187
190
switch api {
188
191
case let api as AssociatedType :
189
192
hasher. combine ( api)
@@ -225,7 +228,7 @@ extension Symbol: Codable {
225
228
private enum CodingKeys : String , CodingKey {
226
229
case declaration
227
230
case documentation
228
- case sourceLocation
231
+ case sourceRange
229
232
230
233
case associatedType
231
234
case `case`
@@ -282,9 +285,9 @@ extension Symbol: Codable {
282
285
283
286
let declaration = try container. decodeIfPresent ( [ Token ] . self, forKey: . declaration)
284
287
let documentation = try container. decodeIfPresent ( Documentation . self, forKey: . documentation)
285
- let sourceLocation = try container. decodeIfPresent ( SourceLocation . self, forKey: . sourceLocation )
288
+ let sourceRange = try container. decodeIfPresent ( SourceRange . self, forKey: . sourceRange )
286
289
287
- self . init ( api: api, context: [ ] /* TODO */, declaration: declaration ?? [ ] , documentation: documentation, sourceLocation : sourceLocation )
290
+ self . init ( api: api, context: [ ] /* TODO */, declaration: declaration ?? [ ] , documentation: documentation, sourceRange : sourceRange )
288
291
}
289
292
290
293
public func encode( to encoder: Encoder ) throws {
@@ -323,6 +326,6 @@ extension Symbol: Codable {
323
326
}
324
327
325
328
try container. encode ( documentation, forKey: . documentation)
326
- try container. encode ( sourceLocation , forKey: . sourceLocation )
329
+ try container. encode ( sourceRange , forKey: . sourceRange )
327
330
}
328
331
}
0 commit comments