Chromium Code Reviews| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 ..write(_maps[i]) | 129 ..write(_maps[i]) |
| 130 ..write(')'); | 130 ..write(')'); |
| 131 } | 131 } |
| 132 buff.write(']'); | 132 buff.write(']'); |
| 133 return buff.toString(); | 133 return buff.toString(); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 /// A map containing direct source mappings. | 137 /// A map containing direct source mappings. |
| 138 class SingleMapping extends Mapping { | 138 class SingleMapping extends Mapping { |
| 139 /// Url of the target file. | |
| 140 final String targetUrl; | |
| 141 | |
| 142 /// Source urls used in the mapping, indexed by id. | 139 /// Source urls used in the mapping, indexed by id. |
| 143 final List<String> urls; | 140 final List<String> urls; |
| 144 | 141 |
| 145 /// Source names used in the mapping, indexed by id. | 142 /// Source names used in the mapping, indexed by id. |
| 146 final List<String> names; | 143 final List<String> names; |
| 147 | 144 |
| 148 /// Entries indicating the beginning of each span. | 145 /// Entries indicating the beginning of each span. |
| 149 final List<TargetLineEntry> lines; | 146 final List<TargetLineEntry> lines; |
| 150 | 147 |
| 148 /// Url of the target file. | |
| 149 String targetUrl; | |
| 150 | |
| 151 /// Source root appended to the start of all entries in [urls]. | 151 /// Source root appended to the start of all entries in [urls]. |
| 152 String sourceRoot = null; | 152 String sourceRoot = null; |
|
Siggi Cherem (dart-lang)
2014/07/15 17:54:56
just realized this - since this is not final, the
tjblasi
2014/07/15 18:00:14
Done.
| |
| 153 | 153 |
| 154 SingleMapping._internal(this.targetUrl, this.urls, this.names, this.lines); | 154 SingleMapping._(this.targetUrl, this.urls, this.names, this.lines); |
| 155 | 155 |
| 156 factory SingleMapping.fromEntries( | 156 factory SingleMapping.fromEntries( |
| 157 Iterable<builder.Entry> entries, [String fileUrl]) { | 157 Iterable<builder.Entry> entries, [String fileUrl]) { |
| 158 // The entries needs to be sorted by the target offsets. | 158 // The entries needs to be sorted by the target offsets. |
| 159 var sourceEntries = new List.from(entries)..sort(); | 159 var sourceEntries = new List.from(entries)..sort(); |
| 160 var lines = <TargetLineEntry>[]; | 160 var lines = <TargetLineEntry>[]; |
| 161 | 161 |
| 162 // Indices associated with file urls that will be part of the source map. We | 162 // Indices associated with file urls that will be part of the source map. We |
| 163 // use a linked hash-map so that `_urls.keys[_urls[u]] == u` | 163 // use a linked hash-map so that `_urls.keys[_urls[u]] == u` |
| 164 var urls = new LinkedHashMap<String, int>(); | 164 var urls = new LinkedHashMap<String, int>(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 184 var srcNameId = sourceEntry.identifierName == null ? null : | 184 var srcNameId = sourceEntry.identifierName == null ? null : |
| 185 names.putIfAbsent(sourceEntry.identifierName, () => names.length); | 185 names.putIfAbsent(sourceEntry.identifierName, () => names.length); |
| 186 targetEntries.add(new TargetEntry( | 186 targetEntries.add(new TargetEntry( |
| 187 sourceEntry.target.column, | 187 sourceEntry.target.column, |
| 188 urlId, | 188 urlId, |
| 189 sourceEntry.source.line, | 189 sourceEntry.source.line, |
| 190 sourceEntry.source.column, | 190 sourceEntry.source.column, |
| 191 srcNameId)); | 191 srcNameId)); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 return new SingleMapping._internal( | 194 return new SingleMapping._( |
| 195 fileUrl, urls.keys.toList(), names.keys.toList(), lines); | 195 fileUrl, urls.keys.toList(), names.keys.toList(), lines); |
| 196 } | 196 } |
| 197 | 197 |
| 198 SingleMapping.fromJson(Map map) | 198 SingleMapping.fromJson(Map map) |
| 199 : targetUrl = map['file'], | 199 : targetUrl = map['file'], |
| 200 urls = map['sources'], | 200 urls = map['sources'], |
| 201 names = map['names'], | 201 names = map['names'], |
| 202 sourceRoot = map['sourceRoot'], | 202 sourceRoot = map['sourceRoot'], |
| 203 lines = <TargetLineEntry>[] { | 203 lines = <TargetLineEntry>[] { |
| 204 int line = 0; | 204 int line = 0; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 static const _TokenKind EOF = const _TokenKind(isEof: true); | 500 static const _TokenKind EOF = const _TokenKind(isEof: true); |
| 501 static const _TokenKind VALUE = const _TokenKind(); | 501 static const _TokenKind VALUE = const _TokenKind(); |
| 502 final bool isNewLine; | 502 final bool isNewLine; |
| 503 final bool isNewSegment; | 503 final bool isNewSegment; |
| 504 final bool isEof; | 504 final bool isEof; |
| 505 bool get isValue => !isNewLine && !isNewSegment && !isEof; | 505 bool get isValue => !isNewLine && !isNewSegment && !isEof; |
| 506 | 506 |
| 507 const _TokenKind( | 507 const _TokenKind( |
| 508 {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); | 508 {this.isNewLine: false, this.isNewSegment: false, this.isEof: false}); |
| 509 } | 509 } |
| OLD | NEW |