Index: lib/src/script.dart |
diff --git a/lib/src/script.dart b/lib/src/script.dart |
index 12f4bfac80501fc627b615daf269d62a326cca5d..0c864339c174aed4dbd154bd554d6b1f44961f4c 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 newVMScriptTokenFromScript(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 |
@@ -68,6 +74,61 @@ 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. |
+ /// Forcing compilation can cause a compilation error, which could terminate |
+ /// the running Dart program. |
+ /// |
+ /// Set [forceCompile] to `true` to force compilation of all functions in |
+ /// the range of the report. |
+ /// Forcing compilation can cause a compilation error, which could terminate |
+ /// the running Dart program. |
+ /// |
+ /// Either or both of the [tokenPos] and [endTokenPos] may be |
+ /// provided to restrict the analysis to a subrange of a script |
+ /// (for example, these can be used to restrict the report to the range of a |
+ /// particular class or function). |
+ Future<VMSourceReport> getSourceReport( |
+ {bool includeCoverageReport: false, |
+ bool includePossibleBreakpoints: false, |
+ bool forceCompile: false, |
+ int tokenPos, |
+ int endTokenPos}) 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 (tokenPos != null) { |
+ params['tokenPos'] = tokenPos; |
+ } |
+ if (endTokenPos != null) { |
+ params['endTokenPos'] = endTokenPos; |
+ } |
+ |
+ var json = await _scope.sendRequest('getSourceReport', params); |
+ return newSourceReport(_scope, json); |
+ } |
+ |
bool operator ==(other) => other is VMScriptRef && |
(_fixedId ? _id == other._id : super == other); |