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:json' as json; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'span.dart'; | 10 import 'span.dart'; |
11 import 'src/utils.dart'; | 11 import 'src/utils.dart'; |
12 import 'src/vlq.dart'; | 12 import 'src/vlq.dart'; |
13 | 13 |
14 /// Parses a source map directly from a json string. | 14 /// Parses a source map directly from a json string. |
15 // TODO(sigmund): evaluate whether other maps should have the json parsed, or | 15 // TODO(sigmund): evaluate whether other maps should have the json parsed, or |
16 // the string represenation. | 16 // the string represenation. |
17 Mapping parse(String jsonMap, {Map<String, Map> otherMaps}) => | 17 Mapping parse(String jsonMap, {Map<String, Map> otherMaps}) => |
18 parseJson(json.parse(jsonMap), otherMaps: otherMaps); | 18 parseJson(JSON.decode(jsonMap), otherMaps: otherMaps); |
19 | 19 |
20 /// Parses a source map directly from a json map object. | 20 /// Parses a source map directly from a json map object. |
21 Mapping parseJson(Map map, {Map<String, Map> otherMaps}) { | 21 Mapping parseJson(Map map, {Map<String, Map> otherMaps}) { |
22 if (map['version'] != 3) { | 22 if (map['version'] != 3) { |
23 throw new ArgumentError( | 23 throw new ArgumentError( |
24 'unexpected source map version: ${map["version"]}. ' | 24 'unexpected source map version: ${map["version"]}. ' |
25 'Only version 3 is supported.'); | 25 'Only version 3 is supported.'); |
26 } | 26 } |
27 | 27 |
28 if (!map.containsKey('file')) { | 28 if (!map.containsKey('file')) { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 static const _TokenKind EOF = const _TokenKind(isEof: true); | 381 static const _TokenKind EOF = const _TokenKind(isEof: true); |
382 static const _TokenKind VALUE = const _TokenKind(); | 382 static const _TokenKind VALUE = const _TokenKind(); |
383 final bool isNewLine; | 383 final bool isNewLine; |
384 final bool isNewSegment; | 384 final bool isNewSegment; |
385 final bool isEof; | 385 final bool isEof; |
386 bool get isValue => !isNewLine && !isNewSegment && !isEof; | 386 bool get isValue => !isNewLine && !isNewSegment && !isEof; |
387 | 387 |
388 const _TokenKind( | 388 const _TokenKind( |
389 {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); | 389 {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); |
390 } | 390 } |
OLD | NEW |