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

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: nits Created 4 years, 7 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..93c35d81f17638c0f78ae150db5053e9e4c46197 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,48 @@ 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.
+ ///
+ /// [location] can be provided to restrict analysis to a subrange of the
+ /// script.
+ Future<VMSourceReport> getSourceReport(
+ {bool includeCoverageReport: true,
+ bool includePossibleBreakpoints: true,
+ bool forceCompile: false,
+ VMSourceLocation location}) 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 (location != null) {
+ params['tokenPos'] = location.token._position;
+ if (location.end != null) {
+ params['endTokenPos'] = location.end._position;
nweiz 2016/05/19 21:11:13 A location without an end represents a single poin
kevmoo 2016/05/19 21:59:46 Acknowledged.
+ }
+ }
+
+ 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