| 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'; |
| 11 import 'dart:json' as json; | |
| 12 | 11 |
| 13 import 'package:path/path.dart' as pathos; | 12 import 'package:path/path.dart' as pathos; |
| 14 | 13 |
| 15 import 'package:analyzer_experimental/src/generated/source.dart' show Source, So
urceRange; | |
| 16 import 'package:analyzer_experimental/src/generated/scanner.dart' show StringSca
nner; | 14 import 'package:analyzer_experimental/src/generated/scanner.dart' show StringSca
nner; |
| 17 import 'package:analyzer_experimental/src/generated/parser.dart' show Parser; | 15 import 'package:analyzer_experimental/src/generated/parser.dart' show Parser; |
| 18 import 'package:analyzer_experimental/src/generated/ast.dart'; | 16 import 'package:analyzer_experimental/src/generated/ast.dart'; |
| 19 import 'package:analyzer_experimental/src/generated/engine.dart' show RecordingE
rrorListener; | 17 import 'package:analyzer_experimental/src/generated/engine.dart' show RecordingE
rrorListener; |
| 20 | 18 |
| 21 import '../log.dart' as log; | 19 import '../log.dart' as log; |
| 22 import 'models.dart'; | 20 import 'models.dart'; |
| 23 import 'utils.dart'; | |
| 24 | 21 |
| 25 /// Run the [targetPath] with code coverage rewriting. | 22 /// Run the [targetPath] with code coverage rewriting. |
| 26 /// Redirects stdandard process streams. | 23 /// Redirects stdandard process streams. |
| 27 /// On process exit dumps coverage statistics into the [outPath]. | 24 /// On process exit dumps coverage statistics into the [outPath]. |
| 28 void runServerApplication(String targetPath, String outPath) { | 25 void runServerApplication(String targetPath, String outPath) { |
| 29 var targetFolder = pathos.dirname(targetPath); | 26 var targetFolder = pathos.dirname(targetPath); |
| 30 var targetName = pathos.basename(targetPath); | 27 var targetName = pathos.basename(targetPath); |
| 31 var server = new CoverageServer(targetFolder, targetPath, outPath); | 28 var server = new CoverageServer(targetFolder, targetPath, outPath); |
| 32 server.start().then((port) { | 29 server.start().then((port) { |
| 33 var options = new Options(); | 30 var options = new Options(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 var lastOffset = 0; | 330 var lastOffset = 0; |
| 334 offsetFragmentMap.forEach((offset, fragment) { | 331 offsetFragmentMap.forEach((offset, fragment) { |
| 335 sb.write(_code.substring(lastOffset, offset)); | 332 sb.write(_code.substring(lastOffset, offset)); |
| 336 sb.write(fragment); | 333 sb.write(fragment); |
| 337 lastOffset = offset; | 334 lastOffset = offset; |
| 338 }); | 335 }); |
| 339 sb.write(_code.substring(lastOffset, _code.length)); | 336 sb.write(_code.substring(lastOffset, _code.length)); |
| 340 return sb.toString(); | 337 return sb.toString(); |
| 341 } | 338 } |
| 342 } | 339 } |
| OLD | NEW |