OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Contains the top-level function to parse source maps version 3. | 5 /// Contains the top-level function to parse source maps version 3. |
6 library source_maps.parser; | 6 library source_maps.parser; |
7 | 7 |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 | 10 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 throw new ArgumentError.notNull('uri'); | 206 throw new ArgumentError.notNull('uri'); |
207 } | 207 } |
208 if (_mappings.containsKey(uri)) { | 208 if (_mappings.containsKey(uri)) { |
209 return _mappings[uri].spanFor(line, column, files: files, uri: uri); | 209 return _mappings[uri].spanFor(line, column, files: files, uri: uri); |
210 } | 210 } |
211 // Fall back to looking up the source map on just the basename. | 211 // Fall back to looking up the source map on just the basename. |
212 var name = path.basename(uri.toString()); | 212 var name = path.basename(uri.toString()); |
213 if (_mappings.containsKey(name)) { | 213 if (_mappings.containsKey(name)) { |
214 return _mappings[name].spanFor(line, column, files: files, uri: name); | 214 return _mappings[name].spanFor(line, column, files: files, uri: name); |
215 } | 215 } |
216 return null; | 216 // The uri doesn't have a source map so create a SourceMapSpan matching |
217 // the input location as well as possible. Fake the file offset because | |
Siggi Cherem (dart-lang)
2016/12/09 16:38:38
nits:
- input and output is a bit confusing here.
Jacob
2016/12/09 17:18:03
Done.
| |
218 // we don't really know it. This fake offset avoids locations with the | |
219 // same offset but different lines and columns. | |
220 var offset = line * 1000000000 + column; | |
Siggi Cherem (dart-lang)
2016/12/09 16:38:38
wow, 1 billion! that's a very long line :)
Can we
Jacob
2016/12/09 17:18:03
Switched to a million. Note that SourceMapSpan doe
| |
221 var location = new SourceLocation(offset, | |
222 line: line, column: column, sourceUrl: Uri.parse(uri)); | |
223 return new SourceMapSpan(location, location, ""); | |
217 } | 224 } |
218 } | 225 } |
219 | 226 |
220 /// A map containing direct source mappings. | 227 /// A map containing direct source mappings. |
221 class SingleMapping extends Mapping { | 228 class SingleMapping extends Mapping { |
222 /// Source urls used in the mapping, indexed by id. | 229 /// Source urls used in the mapping, indexed by id. |
223 final List<String> urls; | 230 final List<String> urls; |
224 | 231 |
225 /// Source names used in the mapping, indexed by id. | 232 /// Source names used in the mapping, indexed by id. |
226 final List<String> names; | 233 final List<String> names; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 static const _TokenKind EOF = const _TokenKind(isEof: true); | 608 static const _TokenKind EOF = const _TokenKind(isEof: true); |
602 static const _TokenKind VALUE = const _TokenKind(); | 609 static const _TokenKind VALUE = const _TokenKind(); |
603 final bool isNewLine; | 610 final bool isNewLine; |
604 final bool isNewSegment; | 611 final bool isNewSegment; |
605 final bool isEof; | 612 final bool isEof; |
606 bool get isValue => !isNewLine && !isNewSegment && !isEof; | 613 bool get isValue => !isNewLine && !isNewSegment && !isEof; |
607 | 614 |
608 const _TokenKind( | 615 const _TokenKind( |
609 {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); | 616 {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); |
610 } | 617 } |
OLD | NEW |