OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// Loads a source map file and outputs a human-readable version of it. | 5 /// Loads a source map file and outputs a human-readable version of it. |
6 | 6 |
7 library load; | 7 library load; |
8 | 8 |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 TargetEntry entry = lineEntry.entries[entryIndex]; | 67 TargetEntry entry = lineEntry.entries[entryIndex]; |
68 int columnStart = entry.column + 1; | 68 int columnStart = entry.column + 1; |
69 int columnEnd; | 69 int columnEnd; |
70 String position; | 70 String position; |
71 if (entryIndex + 1 < lineEntry.entries.length) { | 71 if (entryIndex + 1 < lineEntry.entries.length) { |
72 columnEnd = lineEntry.entries[entryIndex + 1].column + 1; | 72 columnEnd = lineEntry.entries[entryIndex + 1].column + 1; |
73 position = '$line,$columnStart-$columnEnd'; | 73 position = '$line,$columnStart-$columnEnd'; |
74 } else { | 74 } else { |
75 position = '$line,$columnStart-'; | 75 position = '$line,$columnStart-'; |
76 } | 76 } |
| 77 if (needsComma) { |
| 78 sb.write(',\n'); |
| 79 } |
| 80 sb.write(' {"target": "$position"'); |
77 if (entry.sourceUrlId != null) { | 81 if (entry.sourceUrlId != null) { |
78 int sourceUrlId = entry.sourceUrlId; | 82 int sourceUrlId = entry.sourceUrlId; |
79 int sourceLine = entry.sourceLine + 1; | 83 int sourceLine = entry.sourceLine + 1; |
80 int sourceColumn = entry.sourceColumn + 1; | 84 int sourceColumn = entry.sourceColumn + 1; |
81 if (needsComma) { | |
82 sb.write(',\n'); | |
83 } | |
84 sb.write(' {"target": "$position"'); | |
85 sb.write(', "source": "$sourceUrlId:$sourceLine,$sourceColumn"'); | 85 sb.write(', "source": "$sourceUrlId:$sourceLine,$sourceColumn"'); |
86 if (entry.sourceNameId != null) { | 86 if (entry.sourceNameId != null) { |
87 sb.write(', "name": "${sourceMap.names[entry.sourceNameId]}"'); | 87 sb.write(', "name": "${sourceMap.names[entry.sourceNameId]}"'); |
88 } | 88 } |
89 sb.write('}'); | |
90 needsComma = true; | |
91 } | 89 } |
| 90 sb.write('}'); |
| 91 needsComma = true; |
92 } | 92 } |
93 } | 93 } |
94 sb.write('\n ]\n'); | 94 sb.write('\n ]\n'); |
95 sb.write('}'); | 95 sb.write('}'); |
96 return sb.toString(); | 96 return sb.toString(); |
97 } | 97 } |
OLD | NEW |