| 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 (entry.sourceUrlId != null) { | 77 if (entry.sourceUrlId != null || columnEnd == null) { |
| 78 int sourceUrlId = entry.sourceUrlId; | |
| 79 int sourceLine = entry.sourceLine + 1; | |
| 80 int sourceColumn = entry.sourceColumn + 1; | |
| 81 if (needsComma) { | 78 if (needsComma) { |
| 82 sb.write(',\n'); | 79 sb.write(',\n'); |
| 83 } | 80 } |
| 84 sb.write(' {"target": "$position"'); | 81 sb.write(' {"target": "$position"'); |
| 85 sb.write(', "source": "$sourceUrlId:$sourceLine,$sourceColumn"'); | 82 if (entry.sourceUrlId != null) { |
| 86 if (entry.sourceNameId != null) { | 83 int sourceUrlId = entry.sourceUrlId; |
| 87 sb.write(', "name": "${sourceMap.names[entry.sourceNameId]}"'); | 84 int sourceLine = entry.sourceLine + 1; |
| 85 int sourceColumn = entry.sourceColumn + 1; |
| 86 sb.write(', "source": "$sourceUrlId:$sourceLine,$sourceColumn"'); |
| 87 if (entry.sourceNameId != null) { |
| 88 sb.write(', "name": "${sourceMap.names[entry.sourceNameId]}"'); |
| 89 } |
| 88 } | 90 } |
| 89 sb.write('}'); | 91 sb.write('}'); |
| 90 needsComma = true; | 92 needsComma = true; |
| 91 } | 93 } |
| 92 } | 94 } |
| 93 } | 95 } |
| 94 sb.write('\n ]\n'); | 96 sb.write('\n ]\n'); |
| 95 sb.write('}'); | 97 sb.write('}'); |
| 96 return sb.toString(); | 98 return sb.toString(); |
| 97 } | 99 } |
| OLD | NEW |