| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library source_span.file; | 5 library source_span.file; |
| 6 | 6 |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
| 9 | 9 |
| 10 import 'location.dart'; | 10 import 'location.dart'; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 /// Unlike the base [SourceSpan], [FileSpan] lazily computes its line and column | 239 /// Unlike the base [SourceSpan], [FileSpan] lazily computes its line and column |
| 240 /// values based on its offset and the contents of [file]. [FileSpan.message] is | 240 /// values based on its offset and the contents of [file]. [FileSpan.message] is |
| 241 /// also able to provide more context then [SourceSpan.message], and | 241 /// also able to provide more context then [SourceSpan.message], and |
| 242 /// [FileSpan.union] will return a [FileSpan] if possible. | 242 /// [FileSpan.union] will return a [FileSpan] if possible. |
| 243 /// | 243 /// |
| 244 /// A [FileSpan] can be created using [SourceFile.span]. | 244 /// A [FileSpan] can be created using [SourceFile.span]. |
| 245 abstract class FileSpan implements SourceSpanWithContext { | 245 abstract class FileSpan implements SourceSpanWithContext { |
| 246 /// The [file] that [this] belongs to. | 246 /// The [file] that [this] belongs to. |
| 247 SourceFile get file; | 247 SourceFile get file; |
| 248 | 248 |
| 249 FileLocation get start; |
| 250 FileLocation get end; |
| 251 |
| 249 /// Returns a new span that covers both [this] and [other]. | 252 /// Returns a new span that covers both [this] and [other]. |
| 250 /// | 253 /// |
| 251 /// Unlike [union], [other] may be disjoint from [this]. If it is, the text | 254 /// Unlike [union], [other] may be disjoint from [this]. If it is, the text |
| 252 /// between the two will be covered by the returned span. | 255 /// between the two will be covered by the returned span. |
| 253 FileSpan expand(FileSpan other); | 256 FileSpan expand(FileSpan other); |
| 254 } | 257 } |
| 255 | 258 |
| 256 /// The implementation of [FileSpan]. | 259 /// The implementation of [FileSpan]. |
| 257 /// | 260 /// |
| 258 /// This is split into a separate class so that `is _FileSpan` checks can be run | 261 /// This is split into a separate class so that `is _FileSpan` checks can be run |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 var start = math.min(this._start, other._start); | 349 var start = math.min(this._start, other._start); |
| 347 var end = math.max(this._end, other._end); | 350 var end = math.max(this._end, other._end); |
| 348 return new _FileSpan(file, start, end); | 351 return new _FileSpan(file, start, end); |
| 349 } else { | 352 } else { |
| 350 var start = math.min(this._start, other.start.offset); | 353 var start = math.min(this._start, other.start.offset); |
| 351 var end = math.max(this._end, other.end.offset); | 354 var end = math.max(this._end, other.end.offset); |
| 352 return new _FileSpan(file, start, end); | 355 return new _FileSpan(file, start, end); |
| 353 } | 356 } |
| 354 } | 357 } |
| 355 } | 358 } |
| OLD | NEW |