@@ -10,17 +10,20 @@ public final class Symbol {
1010 public let context : [ Contextual ]
1111 public let declaration : [ Token ]
1212 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 }
1417
1518 public private( set) lazy var `extension` : Extension ? = context. compactMap { $0 as? Extension } . first
1619 public private( set) lazy var conditions : [ CompilationCondition ] = context. compactMap { $0 as? CompilationCondition }
1720
18- init ( api: API , context: [ Contextual ] , declaration: [ Token ] , documentation: Documentation ? , sourceLocation : SourceLocation ? ) {
21+ init ( api: API , context: [ Contextual ] , declaration: [ Token ] , documentation: Documentation ? , sourceRange : SourceRange ? ) {
1922 self . api = api
2023 self . context = context
2124 self . declaration = declaration
2225 self . documentation = documentation
23- self . sourceLocation = sourceLocation
26+ self . sourceRange = sourceRange
2427 }
2528
2629 public var name : String {
@@ -114,8 +117,8 @@ public final class Symbol {
114117extension Symbol : Equatable {
115118 public static func == ( lhs: Symbol , rhs: Symbol ) -> Bool {
116119 guard lhs. documentation == rhs. documentation,
117- lhs. sourceLocation == rhs. sourceLocation
118- else { return false }
120+ lhs. sourceRange == rhs. sourceRange
121+ else { return false }
119122
120123 guard lhs. context. count == rhs. context. count else { return false }
121124 for (lc, rc) in zip ( lhs. context, rhs. context) {
@@ -170,8 +173,8 @@ extension Symbol: Equatable {
170173
171174extension Symbol : Comparable {
172175 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
175178 } else {
176179 return lhs. name < rhs. name
177180 }
@@ -183,7 +186,7 @@ extension Symbol: Comparable {
183186extension Symbol : Hashable {
184187 public func hash( into hasher: inout Hasher ) {
185188 hasher. combine ( documentation)
186- hasher. combine ( sourceLocation )
189+ hasher. combine ( sourceRange )
187190 switch api {
188191 case let api as AssociatedType :
189192 hasher. combine ( api)
@@ -225,7 +228,7 @@ extension Symbol: Codable {
225228 private enum CodingKeys : String , CodingKey {
226229 case declaration
227230 case documentation
228- case sourceLocation
231+ case sourceRange
229232
230233 case associatedType
231234 case `case`
@@ -282,9 +285,9 @@ extension Symbol: Codable {
282285
283286 let declaration = try container. decodeIfPresent ( [ Token ] . self, forKey: . declaration)
284287 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 )
286289
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 )
288291 }
289292
290293 public func encode( to encoder: Encoder ) throws {
@@ -323,6 +326,6 @@ extension Symbol: Codable {
323326 }
324327
325328 try container. encode ( documentation, forKey: . documentation)
326- try container. encode ( sourceLocation , forKey: . sourceLocation )
329+ try container. encode ( sourceRange , forKey: . sourceRange )
327330 }
328331}
0 commit comments