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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 } | 67 } |
68 line = nextLine; | 68 line = nextLine; |
69 column = 0; | 69 column = 0; |
70 first = true; | 70 first = true; |
71 } | 71 } |
72 | 72 |
73 if (!first) buff.write(','); | 73 if (!first) buff.write(','); |
74 first = false; | 74 first = false; |
75 column = _append(buff, column, entry.target.column); | 75 column = _append(buff, column, entry.target.column); |
76 | 76 |
77 if (entry.source == null) continue; | 77 // Encoding can be just the column offset if there is no source |
78 // information, or if two consecutive mappings share exactly the same | |
79 // source infromation. | |
dgrove
2013/07/12 22:49:20
information
| |
80 var source = entry.source; | |
81 if (source == null) continue; | |
82 var newUrlId = _indexOf(_urls, source.sourceUrl); | |
83 if (newUrlId == srcUrlId && source.line == srcLine | |
84 && source.column == srcColumn && entry.identifierName == null) { | |
85 continue; | |
86 } | |
78 | 87 |
79 srcUrlId = _append(buff, srcUrlId, | 88 srcUrlId = _append(buff, srcUrlId, newUrlId); |
80 _indexOf(_urls, entry.source.sourceUrl)); | 89 srcLine = _append(buff, srcLine, source.line); |
81 srcLine = _append(buff, srcLine, entry.source.line); | 90 srcColumn = _append(buff, srcColumn, source.column); |
82 srcColumn = _append(buff, srcColumn, entry.source.column); | |
83 | 91 |
84 if (entry.identifierName == null) continue; | 92 if (entry.identifierName == null) continue; |
85 srcNameId = _append(buff, srcNameId, | 93 srcNameId = _append(buff, srcNameId, |
86 _indexOf(_names, entry.identifierName)); | 94 _indexOf(_names, entry.identifierName)); |
87 } | 95 } |
88 | 96 |
89 var result = { | 97 var result = { |
90 'version': 3, | 98 'version': 3, |
91 'sourceRoot': '', | 99 'sourceRoot': '', |
92 'sources': _urls.keys.toList(), | 100 'sources': _urls.keys.toList(), |
(...skipping 44 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 | 145 /// because source map files are encoded by printing each mapping in order as |
138 /// they appear in the target file. | 146 /// they appear in the target file. |
139 int compareTo(Entry other) { | 147 int compareTo(Entry other) { |
140 int res = target.compareTo(other.target); | 148 int res = target.compareTo(other.target); |
141 if (res != 0) return res; | 149 if (res != 0) return res; |
142 res = source.sourceUrl.compareTo(other.source.sourceUrl); | 150 res = source.sourceUrl.compareTo(other.source.sourceUrl); |
143 if (res != 0) return res; | 151 if (res != 0) return res; |
144 return source.compareTo(other.source); | 152 return source.compareTo(other.source); |
145 } | 153 } |
146 } | 154 } |
OLD | NEW |