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:collection'; | 10 import 'dart:collection'; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Encoding can be just the column offset if there is no source | 77 // Encoding can be just the column offset if there is no source |
78 // information, or if two consecutive mappings share exactly the same | 78 // information. |
79 // source information. | |
80 var source = entry.source; | 79 var source = entry.source; |
81 if (source == null) continue; | 80 if (source == null) continue; |
82 var newUrlId = _indexOf(_urls, source.sourceUrl); | 81 var newUrlId = _indexOf(_urls, source.sourceUrl); |
83 if (newUrlId == srcUrlId && source.line == srcLine | |
84 && source.column == srcColumn && entry.identifierName == null) { | |
85 continue; | |
86 } | |
87 | 82 |
88 srcUrlId = _append(buff, srcUrlId, newUrlId); | 83 srcUrlId = _append(buff, srcUrlId, newUrlId); |
89 srcLine = _append(buff, srcLine, source.line); | 84 srcLine = _append(buff, srcLine, source.line); |
90 srcColumn = _append(buff, srcColumn, source.column); | 85 srcColumn = _append(buff, srcColumn, source.column); |
91 | 86 |
92 if (entry.identifierName == null) continue; | 87 if (entry.identifierName == null) continue; |
93 srcNameId = _append(buff, srcNameId, | 88 srcNameId = _append(buff, srcNameId, |
94 _indexOf(_names, entry.identifierName)); | 89 _indexOf(_names, entry.identifierName)); |
95 } | 90 } |
96 | 91 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 /// because source map files are encoded by printing each mapping in order as | 140 /// because source map files are encoded by printing each mapping in order as |
146 /// they appear in the target file. | 141 /// they appear in the target file. |
147 int compareTo(Entry other) { | 142 int compareTo(Entry other) { |
148 int res = target.compareTo(other.target); | 143 int res = target.compareTo(other.target); |
149 if (res != 0) return res; | 144 if (res != 0) return res; |
150 res = source.sourceUrl.compareTo(other.source.sourceUrl); | 145 res = source.sourceUrl.compareTo(other.source.sourceUrl); |
151 if (res != 0) return res; | 146 if (res != 0) return res; |
152 return source.compareTo(other.source); | 147 return source.compareTo(other.source); |
153 } | 148 } |
154 } | 149 } |
OLD | NEW |