| 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 /// A library for code coverage support for Dart. | 5 /// A library for code coverage support for Dart. |
| 6 library runtime.coverage.impl; | 6 library runtime.coverage.impl; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection' show SplayTreeMap; | 9 import 'dart:collection' show SplayTreeMap; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 }).catchError((e) { | 186 }).catchError((e) { |
| 187 log.severe('Error in receiving statistics $e.'); | 187 log.severe('Error in receiving statistics $e.'); |
| 188 return request.response.close(); | 188 return request.response.close(); |
| 189 }); | 189 }); |
| 190 }); | 190 }); |
| 191 } | 191 } |
| 192 | 192 |
| 193 String rewritePathContent(String path) { | 193 String rewritePathContent(String path) { |
| 194 if (path.endsWith('__coverage_lib.dart')) { | 194 if (path.endsWith('__coverage_lib.dart')) { |
| 195 String implPath = pathos.joinAll([ | 195 String implPath = pathos.joinAll([ |
| 196 pathos.dirname(new Options().script), | 196 pathos.dirname(Platform.script), |
| 197 '..', 'lib', 'src', 'services', 'runtime', 'coverage', | 197 '..', 'lib', 'src', 'services', 'runtime', 'coverage', |
| 198 'coverage_lib.dart']); | 198 'coverage_lib.dart']); |
| 199 var content = new File(implPath).readAsStringSync(); | 199 var content = new File(implPath).readAsStringSync(); |
| 200 return content.replaceAll('0; // replaced during rewrite', '$port;'); | 200 return content.replaceAll('0; // replaced during rewrite', '$port;'); |
| 201 } | 201 } |
| 202 return null; | 202 return null; |
| 203 } | 203 } |
| 204 | 204 |
| 205 bool shouldRewriteFile(String path) { | 205 bool shouldRewriteFile(String path) { |
| 206 if (pathos.extension(path).toLowerCase() != '.dart') return false; | 206 if (pathos.extension(path).toLowerCase() != '.dart') return false; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 var lastOffset = 0; | 333 var lastOffset = 0; |
| 334 offsetFragmentMap.forEach((offset, fragment) { | 334 offsetFragmentMap.forEach((offset, fragment) { |
| 335 sb.write(_code.substring(lastOffset, offset)); | 335 sb.write(_code.substring(lastOffset, offset)); |
| 336 sb.write(fragment); | 336 sb.write(fragment); |
| 337 lastOffset = offset; | 337 lastOffset = offset; |
| 338 }); | 338 }); |
| 339 sb.write(_code.substring(lastOffset, _code.length)); | 339 sb.write(_code.substring(lastOffset, _code.length)); |
| 340 return sb.toString(); | 340 return sb.toString(); |
| 341 } | 341 } |
| 342 } | 342 } |
| OLD | NEW |