| 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 library observatory_element; | 5 library observatory_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:observatory/app.dart'; | 9 import 'package:observatory/app.dart'; |
| 10 import 'package:polymer/polymer.dart'; | 10 import 'package:polymer/polymer.dart'; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 String formatSize(int bytes) => Utils.formatSize(bytes); | 105 String formatSize(int bytes) => Utils.formatSize(bytes); |
| 106 | 106 |
| 107 String fileAndLine(Map frame) { | 107 String fileAndLine(Map frame) { |
| 108 var file = frame['script'].name; | 108 var file = frame['script'].name; |
| 109 var shortFile = file.substring(file.lastIndexOf('/') + 1); | 109 var shortFile = file.substring(file.lastIndexOf('/') + 1); |
| 110 return "${shortFile}:${frame['line']}"; | 110 return "${shortFile}:${frame['line']}"; |
| 111 } | 111 } |
| 112 | 112 |
| 113 int parseInt(String value) => int.parse(value); | 113 int parseInt(String value) => int.parse(value); |
| 114 |
| 115 String asStringLiteral(String value, [bool wasTruncated=false]) { |
| 116 var result = new List(); |
| 117 result.add("'".codeUnitAt(0)); |
| 118 for (int codeUnit in value.codeUnits) { |
| 119 if (codeUnit == '\n'.codeUnitAt(0)) result.addAll('\\n'.codeUnits); |
| 120 else if (codeUnit == '\r'.codeUnitAt(0)) result.addAll('\\r'.codeUnits); |
| 121 else if (codeUnit == '\f'.codeUnitAt(0)) result.addAll('\\f'.codeUnits); |
| 122 else if (codeUnit == '\b'.codeUnitAt(0)) result.addAll('\\b'.codeUnits); |
| 123 else if (codeUnit == '\t'.codeUnitAt(0)) result.addAll('\\t'.codeUnits); |
| 124 else if (codeUnit == '\v'.codeUnitAt(0)) result.addAll('\\v'.codeUnits); |
| 125 else if (codeUnit == '\$'.codeUnitAt(0)) result.addAll('\\\$'.codeUnits); |
| 126 else if (codeUnit == '\\'.codeUnitAt(0)) result.addAll('\\\\'.codeUnits); |
| 127 else if (codeUnit == "'".codeUnitAt(0)) result.addAll("'".codeUnits); |
| 128 else if (codeUnit < 32) result.addAll("\\u$codeUnit".codeUnits); |
| 129 else result.add(codeUnit); |
| 130 } |
| 131 if (wasTruncated) { |
| 132 result.addAll("...".codeUnits); |
| 133 } else { |
| 134 result.add("'".codeUnitAt(0)); |
| 135 } |
| 136 return new String.fromCharCodes(result); |
| 137 } |
| 114 } | 138 } |
| OLD | NEW |