| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library source_maps.span_wrapper; | |
| 6 | |
| 7 import 'package:source_maps/source_maps.dart'; | |
| 8 import 'package:source_span/source_span.dart' as source_span; | |
| 9 | |
| 10 /// A wrapper that exposes a [source_span.SourceSpan] as a [Span]. | |
| 11 class SpanWrapper extends Span { | |
| 12 final source_span.SourceSpan _inner; | |
| 13 | |
| 14 String get text => _inner.text; | |
| 15 | |
| 16 SpanWrapper(source_span.SourceSpan inner, bool isIdentifier) | |
| 17 : _inner = inner, | |
| 18 super( | |
| 19 new LocationWrapper(inner.start), | |
| 20 new LocationWrapper(inner.end), | |
| 21 isIdentifier); | |
| 22 | |
| 23 static Span wrap(span, [bool isIdentifier = false]) { | |
| 24 if (span is Span) return span; | |
| 25 return new SpanWrapper(span, isIdentifier); | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 /// A wrapper that exposes a [source_span.SourceLocation] as a [Location]. | |
| 30 class LocationWrapper extends Location { | |
| 31 final source_span.SourceLocation _inner; | |
| 32 | |
| 33 String get sourceUrl => _inner.sourceUrl.toString(); | |
| 34 int get line => _inner.line; | |
| 35 int get column => _inner.column; | |
| 36 | |
| 37 LocationWrapper(source_span.SourceLocation inner) | |
| 38 : _inner = inner, | |
| 39 super(inner.offset); | |
| 40 | |
| 41 static Location wrap(location) { | |
| 42 if (location is Location) return location; | |
| 43 return new LocationWrapper(location); | |
| 44 } | |
| 45 } | |
| OLD | NEW |