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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 }).catchError((e) { | 183 }).catchError((e) { |
184 log.severe('Error in receiving statistics $e.'); | 184 log.severe('Error in receiving statistics $e.'); |
185 return request.response.close(); | 185 return request.response.close(); |
186 }); | 186 }); |
187 }); | 187 }); |
188 } | 188 } |
189 | 189 |
190 String rewritePathContent(String path) { | 190 String rewritePathContent(String path) { |
191 if (path.endsWith('__coverage_lib.dart')) { | 191 if (path.endsWith('__coverage_lib.dart')) { |
192 String implPath = pathos.joinAll([ | 192 String implPath = pathos.joinAll([ |
193 pathos.dirname(Platform.script.toFilePath()), | 193 pathos.dirname(Platform.script), |
194 '..', 'lib', 'src', 'services', 'runtime', 'coverage', | 194 '..', 'lib', 'src', 'services', 'runtime', 'coverage', |
195 'coverage_lib.dart']); | 195 'coverage_lib.dart']); |
196 var content = new File(implPath).readAsStringSync(); | 196 var content = new File(implPath).readAsStringSync(); |
197 return content.replaceAll('0; // replaced during rewrite', '$port;'); | 197 return content.replaceAll('0; // replaced during rewrite', '$port;'); |
198 } | 198 } |
199 return null; | 199 return null; |
200 } | 200 } |
201 | 201 |
202 bool shouldRewriteFile(String path) { | 202 bool shouldRewriteFile(String path) { |
203 if (pathos.extension(path).toLowerCase() != '.dart') return false; | 203 if (pathos.extension(path).toLowerCase() != '.dart') return false; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 var lastOffset = 0; | 331 var lastOffset = 0; |
332 offsetFragmentMap.forEach((offset, fragment) { | 332 offsetFragmentMap.forEach((offset, fragment) { |
333 sb.write(_code.substring(lastOffset, offset)); | 333 sb.write(_code.substring(lastOffset, offset)); |
334 sb.write(fragment); | 334 sb.write(fragment); |
335 lastOffset = offset; | 335 lastOffset = offset; |
336 }); | 336 }); |
337 sb.write(_code.substring(lastOffset, _code.length)); | 337 sb.write(_code.substring(lastOffset, _code.length)); |
338 return sb.toString(); | 338 return sb.toString(); |
339 } | 339 } |
340 } | 340 } |
OLD | NEW |