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

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
« no previous file with comments | « lib/src/pause_event.dart ('k') | lib/src/source_location.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/script.dart
diff --git a/lib/src/script.dart b/lib/src/script.dart
index f92eb0c28e577afd6269d5f3916f178e58441e43..c11a4572372a88abd1a6fa67e87c8533b2a1e7be 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,50 @@ 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. An [ArgumentError] is thrown if `location.end` is `null`.
+ 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) {
+ if (location.end == null) {
+ throw new ArgumentError.value(
+ location, 'location', 'location.end cannot be null.');
+ }
+ params['tokenPos'] = location.token._position;
+ params['endTokenPos'] = location.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);
« no previous file with comments | « lib/src/pause_event.dart ('k') | lib/src/source_location.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698