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 | 6 |
7 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; | 7 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; |
8 | 8 |
9 import 'error.dart'; | 9 import 'error.dart'; |
10 import 'exceptions.dart'; | 10 import 'exceptions.dart'; |
(...skipping 28 matching lines...) Expand all Loading... |
39 if (result["type"] == "Sentinel") { | 39 if (result["type"] == "Sentinel") { |
40 throw new VMSentinelException(newVMSentinel(result)); | 40 throw new VMSentinelException(newVMSentinel(result)); |
41 } | 41 } |
42 | 42 |
43 return result; | 43 return result; |
44 } | 44 } |
45 | 45 |
46 /// Calls an isolate-scoped RPC named [method] with [params]. | 46 /// Calls an isolate-scoped RPC named [method] with [params]. |
47 /// | 47 /// |
48 /// This always adds the `isolateId` parameter to the RPC. | 48 /// This always adds the `isolateId` parameter to the RPC. |
49 Future<Map> sendRequest(String method, [Map<String, Object> params]) async { | 49 Future<Object> sendRequest(String method, [Map<String, Object> params]) async
{ |
50 var allParams = {"isolateId": isolateId}..addAll(params ?? {}); | 50 var allParams = {"isolateId": isolateId}..addAll(params ?? {}); |
51 return (await peer.sendRequest(method, allParams)) as Map; | 51 return await peer.sendRequest(method, allParams); |
52 } | 52 } |
53 | 53 |
54 /// Evaluates [expression] in the context of the object identified by [id]. | 54 /// Evaluates [expression] in the context of the object identified by [id]. |
55 /// | 55 /// |
56 /// Throws a [VMErrorException] if evaluating the expression throws an error. | 56 /// Throws a [VMErrorException] if evaluating the expression throws an error. |
57 /// Throws a [VMSentinelException] if the object has expired. | 57 /// Throws a [VMSentinelException] if the object has expired. |
58 Future<VMInstanceRef> evaluate(String id, String expression) async { | 58 Future<VMInstanceRef> evaluate(String id, String expression) async { |
59 var result = await sendRequest("evaluate", { | 59 var result = await sendRequest("evaluate", { |
60 "targetId": id, | 60 "targetId": id, |
61 "expression": expression | 61 "expression": expression |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 var result = await immediate(); | 129 var result = await immediate(); |
130 if (result != null && result != false) { | 130 if (result != null && result != false) { |
131 subscription.cancel(); | 131 subscription.cancel(); |
132 return result; | 132 return result; |
133 } | 133 } |
134 | 134 |
135 return await completer.future; | 135 return await completer.future; |
136 } | 136 } |
137 } | 137 } |
OLD | NEW |