OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:async/async.dart'; | 9 import 'package:async/async.dart'; |
10 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; | 10 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; |
11 | 11 |
12 import 'breakpoint.dart'; | 12 import 'breakpoint.dart'; |
13 import 'error.dart'; | 13 import 'error.dart'; |
14 import 'exceptions.dart'; | 14 import 'exceptions.dart'; |
15 import 'library.dart'; | 15 import 'library.dart'; |
16 import 'pause_event.dart'; | 16 import 'pause_event.dart'; |
17 import 'scope.dart'; | 17 import 'scope.dart'; |
18 import 'sentinel.dart'; | 18 import 'sentinel.dart'; |
| 19 import 'source_report.dart'; |
19 import 'stack.dart'; | 20 import 'stack.dart'; |
20 import 'stream_manager.dart'; | 21 import 'stream_manager.dart'; |
21 import 'utils.dart'; | 22 import 'utils.dart'; |
22 | 23 |
23 VMIsolateRef newVMIsolateRef(rpc.Peer peer, StreamManager streams, Map json) { | 24 VMIsolateRef newVMIsolateRef(rpc.Peer peer, StreamManager streams, Map json) { |
24 if (json == null) return null; | 25 if (json == null) return null; |
25 assert(json["type"] == "@Isolate" || json["type"] == "Isolate"); | 26 assert(json["type"] == "@Isolate" || json["type"] == "Isolate"); |
26 var scope = new Scope(peer, streams, json["id"]); | 27 var scope = new Scope(peer, streams, json["id"]); |
27 return new VMIsolateRef._(scope, json); | 28 return new VMIsolateRef._(scope, json); |
28 } | 29 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 /// | 337 /// |
337 /// This is supported as of VM service version 3.1, or Dart SDK version 1.14. | 338 /// This is supported as of VM service version 3.1, or Dart SDK version 1.14. |
338 Future<Object> invokeExtension(String method, [Map<String, String> params]) { | 339 Future<Object> invokeExtension(String method, [Map<String, String> params]) { |
339 if (!method.startsWith('ext.')) { | 340 if (!method.startsWith('ext.')) { |
340 throw new ArgumentError.value(method, 'method', | 341 throw new ArgumentError.value(method, 'method', |
341 'must begin with "ext." prefix'); | 342 'must begin with "ext." prefix'); |
342 } | 343 } |
343 return _scope.sendRequest(method, params); | 344 return _scope.sendRequest(method, params); |
344 } | 345 } |
345 | 346 |
| 347 /// Generates a report of code coverage information and possible break points |
| 348 /// for the scripts in this isolate. |
| 349 /// |
| 350 /// If [includeCoverageReport] is `true`, the report includes code coverage |
| 351 /// information via [VMSourceReportRange.hits] and |
| 352 /// [VMSourceReportRange.misses] in [VMSourceReport.ranges]. Otherwise, |
| 353 /// [VMSourceReportRange.coverage] is `null`. |
| 354 /// |
| 355 /// If [includePossibleBreakpoints] is `true`, the report includes a list of |
| 356 /// token positions which correspond to possible breakpoints via |
| 357 /// [VMSourceReportRange.possibleBreakpoints] in [VMSourceReport.ranges]. |
| 358 /// Otherwise, [VMSourceReportRange.possibleBreakpoints] is `null`. |
| 359 /// |
| 360 /// If [forceCompile] is `true`, all functions in the range of the report |
| 361 /// will be compiled. If `false`, functions that are never used may not appear |
| 362 /// in [VMSourceReportRange.misses]. Forcing compilation can cause a |
| 363 /// compilation error, which could terminate the running Dart program. |
| 364 Future<VMSourceReport> getSourceReport( |
| 365 {bool includeCoverageReport: true, |
| 366 bool includePossibleBreakpoints: true, |
| 367 bool forceCompile: false}) async { |
| 368 var reports = <String>[]; |
| 369 if (includeCoverageReport) reports.add('Coverage'); |
| 370 if (includePossibleBreakpoints) reports.add('PossibleBreakpoints'); |
| 371 |
| 372 var params = {'reports': reports}; |
| 373 if (forceCompile) params['forceCompile'] = true; |
| 374 |
| 375 var json = await _scope.sendRequest('getSourceReport', params); |
| 376 return newSourceReport(_scope, json); |
| 377 } |
| 378 |
346 bool operator ==(other) => other is VMIsolateRef && | 379 bool operator ==(other) => other is VMIsolateRef && |
347 other._scope.isolateId == _scope.isolateId; | 380 other._scope.isolateId == _scope.isolateId; |
348 | 381 |
349 int get hashCode => _scope.isolateId.hashCode; | 382 int get hashCode => _scope.isolateId.hashCode; |
350 | 383 |
351 String toString() => name; | 384 String toString() => name; |
352 } | 385 } |
353 | 386 |
354 /// A full isolate on the remote VM. | 387 /// A full isolate on the remote VM. |
355 class VMIsolate extends VMIsolateRef { | 388 class VMIsolate extends VMIsolateRef { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 /// The kind, which identifies the type of event and its source. | 494 /// The kind, which identifies the type of event and its source. |
462 final String kind; | 495 final String kind; |
463 | 496 |
464 /// The event's payload. | 497 /// The event's payload. |
465 final Map data; | 498 final Map data; |
466 | 499 |
467 VMExtensionEvent._(Map json) | 500 VMExtensionEvent._(Map json) |
468 : kind = json['extensionKind'], | 501 : kind = json['extensionKind'], |
469 data = json['extensionData']; | 502 data = json['extensionData']; |
470 } | 503 } |
OLD | NEW |