| Index: lib/src/script.dart
|
| diff --git a/lib/src/script.dart b/lib/src/script.dart
|
| index f92eb0c28e577afd6269d5f3916f178e58441e43..a82c012a30d7d0cb15a28f8ce89c9316bc2a0679 100644
|
| --- a/lib/src/script.dart
|
| +++ b/lib/src/script.dart
|
| @@ -14,6 +14,7 @@ import 'library.dart';
|
| import 'object.dart';
|
| import 'scope.dart';
|
| import 'source_location.dart';
|
| +import 'source_report.dart';
|
|
|
| VMScriptRef newVMScriptRef(Scope scope, Map json) {
|
| if (json == null) return null;
|
| @@ -27,6 +28,11 @@ VMScriptToken newVMScriptToken(String isolateId, String scriptId,
|
| return new VMScriptToken._(isolateId, scriptId, position);
|
| }
|
|
|
| +VMScriptToken newVMScriptTokenFromPosition(VMScriptRef script, int position) {
|
| + if (position == null) return null;
|
| + return new VMScriptToken._(script._scope.isolateId, script._id, position);
|
| +}
|
| +
|
| /// A reference to a script in the Dart VM.
|
| ///
|
| /// A script contains information about the actual text of a library. Usually
|
| @@ -70,6 +76,46 @@ class VMScriptRef implements VMObjectRef {
|
| }
|
| }
|
|
|
| + /// Generates a set of reports tied to this script.
|
| + ///
|
| + /// If [includeCoverageReport] is `true`, the report includes code coverage
|
| + /// information via [VMSourceReportRange.coverage] in
|
| + /// [VMSourceReport.ranges].
|
| + /// Otherwise, [VMSourceReportRange.coverage] is `null`.
|
| + ///
|
| + /// If [includePossibleBreakpoints] is `true`, the report includes a list of
|
| + /// token positions which correspond to possible breakpoints via
|
| + /// [VMSourceReportRange.possibleBreakpoints] in [VMSourceReport.ranges].
|
| + /// Otherwise, [VMSourceReportRange.possibleBreakpoints] is `null`.
|
| + ///
|
| + /// If [forceCompile] is `true`, all functions in the range of the report
|
| + /// will be compiled. If `false`, functions that are never used may not appear
|
| + /// in [VMSourceReportRange.misses].
|
| + /// Forcing compilation can cause a compilation error, which could terminate
|
| + /// the running Dart program.
|
| + ///
|
| + /// [start] and [end] can be provided separately or together to restrict the
|
| + /// analysis to a subrange of a script that inclusively starts and/or ends
|
| + /// with the specified tokens.
|
| + Future<VMSourceReport> getSourceReport(
|
| + {bool includeCoverageReport: true,
|
| + bool includePossibleBreakpoints: true,
|
| + bool forceCompile: false,
|
| + VMScriptToken start,
|
| + VMScriptToken end}) async {
|
| + var reports = <String>[];
|
| + if (includeCoverageReport) reports.add('Coverage');
|
| + if (includePossibleBreakpoints) reports.add('PossibleBreakpoints');
|
| +
|
| + var params = <String, dynamic>{'scriptId': _id, 'reports': reports};
|
| + if (forceCompile) params['forceCompile'] = true;
|
| + if (start != null) params['tokenPos'] = start._position;
|
| + if (end != null) params['endTokenPos'] = end._position;
|
| +
|
| + var json = await _scope.sendRequest('getSourceReport', params);
|
| + return newSourceReport(_scope, json);
|
| + }
|
| +
|
| bool operator ==(other) => other is VMScriptRef &&
|
| (_fixedId ? _id == other._id : super == other);
|
|
|
|
|