Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: lib/src/script.dart

Issue 1929063002: pkg/vm_service_client: add getSourceReport to VMServiceReference (Closed) Base URL: https://github.com/dart-lang/vm_service_client.git@master
Patch Set: oops Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/script.dart
diff --git a/lib/src/script.dart b/lib/src/script.dart
index f92eb0c28e577afd6269d5f3916f178e58441e43..f21bc5840ccbae67594e3666ffa067a26e0f29dd 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) {
nweiz 2016/05/04 23:05:51 I think I'd call this "from position" rather than
kevmoo 2016/05/05 20:46:26 Done.
+ 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,57 @@ 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.
+ ///
+ /// Either or both [start] and [end] may be provided to restrict the analysis
+ /// to a subrange of a script.
nweiz 2016/05/04 23:05:51 What does it mean to pass only "start" or only "en
kevmoo 2016/05/05 20:46:26 I think I cleared it up
+ /// 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,
+ 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;
nweiz 2016/05/04 23:05:51 Nit: put the results on the same line as the "if"
kevmoo 2016/05/05 20:46:26 Acknowledged.
+ }
+ 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);

Powered by Google App Engine
This is Rietveld 408576698