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 a builder object useful for creating source maps programatically. | 5 /// Contains a builder object useful for creating source maps programatically. |
6 library source_maps.builder; | 6 library source_maps.builder; |
7 | 7 |
8 // TODO(sigmund): add a builder for multi-section mappings. | 8 // TODO(sigmund): add a builder for multi-section mappings. |
9 | 9 |
10 import 'dart:json' as json; | 10 import 'dart:json' as json; |
(...skipping 10 matching lines...) Expand all Loading... |
21 /// Indices associated with file urls that will be part of the source map. We | 21 /// Indices associated with file urls that will be part of the source map. We |
22 /// use a linked hash-map so that `_urls.keys[_urls[u]] == u` | 22 /// use a linked hash-map so that `_urls.keys[_urls[u]] == u` |
23 final Map<String, int> _urls = new LinkedHashMap<String, int>(); | 23 final Map<String, int> _urls = new LinkedHashMap<String, int>(); |
24 | 24 |
25 /// Indices associated with identifiers that will be part of the source map. | 25 /// Indices associated with identifiers that will be part of the source map. |
26 /// We use a linked hash-map so that `_names.keys[_names[n]] == n` | 26 /// We use a linked hash-map so that `_names.keys[_names[n]] == n` |
27 final Map<String, int> _names = new LinkedHashMap<String, int>(); | 27 final Map<String, int> _names = new LinkedHashMap<String, int>(); |
28 | 28 |
29 /// Adds an entry mapping the [targetOffset] to [source]. | 29 /// Adds an entry mapping the [targetOffset] to [source]. |
30 void addFromOffset(Location source, | 30 void addFromOffset(Location source, |
31 File targetFile, int targetOffset, String identifier) { | 31 SourceFile targetFile, int targetOffset, String identifier) { |
32 if (targetFile == null) { | 32 if (targetFile == null) { |
33 throw new ArgumentError('targetFile cannot be null'); | 33 throw new ArgumentError('targetFile cannot be null'); |
34 } | 34 } |
35 _entries.add(new Entry(source, | 35 _entries.add(new Entry(source, |
36 new FileLocation(targetFile, targetOffset), identifier)); | 36 new FileLocation(targetFile, targetOffset), identifier)); |
37 } | 37 } |
38 | 38 |
39 /// Adds an entry mapping [target] to [source]. | 39 /// Adds an entry mapping [target] to [source]. |
40 void addSpan(Span source, Span target) { | 40 void addSpan(Span source, Span target) { |
41 var name = source.isIdentifier ? source.text : null; | 41 var name = source.isIdentifier ? source.text : null; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 /// because source map files are encoded by printing each mapping in order as | 137 /// because source map files are encoded by printing each mapping in order as |
138 /// they appear in the target file. | 138 /// they appear in the target file. |
139 int compareTo(Entry other) { | 139 int compareTo(Entry other) { |
140 int res = target.compareTo(other.target); | 140 int res = target.compareTo(other.target); |
141 if (res != 0) return res; | 141 if (res != 0) return res; |
142 res = source.sourceUrl.compareTo(other.source.sourceUrl); | 142 res = source.sourceUrl.compareTo(other.source.sourceUrl); |
143 if (res != 0) return res; | 143 if (res != 0) return res; |
144 return source.compareTo(other.source); | 144 return source.compareTo(other.source); |
145 } | 145 } |
146 } | 146 } |
OLD | NEW |