| Index: runtime/observatory/lib/src/repositories/editor.dart
|
| diff --git a/runtime/observatory/lib/src/repositories/editor.dart b/runtime/observatory/lib/src/repositories/editor.dart
|
| index 35867f1506f9b9961579e0d3294ddd8875f5b5d0..26395736c330a8432a716165142ca65238a9df82 100644
|
| --- a/runtime/observatory/lib/src/repositories/editor.dart
|
| +++ b/runtime/observatory/lib/src/repositories/editor.dart
|
| @@ -5,16 +5,46 @@
|
| part of repositories;
|
|
|
| class EditorRepository extends M.EditorRepository {
|
| - final String editor;
|
| + final S.VM _vm;
|
| + final String _editor;
|
|
|
| - EditorRepository(this.editor) {
|
| - assert(this.editor != null);
|
| + bool get canOpenClass => _getService() != null;
|
| +
|
| + EditorRepository(S.VM vm, {String editor})
|
| + : _vm = vm,
|
| + _editor = editor {
|
| + assert(_vm != null);
|
| + }
|
| +
|
| + S.Service _getService() {
|
| + if (_vm.services.isEmpty) {
|
| + return null;
|
| + }
|
| + if (_editor == null) {
|
| + return _vm.services.where((s) => s.service == 'openSourceLocation').first;
|
| + }
|
| + return _vm.services
|
| + .where((s) => s.service == 'openSourceLocation' && s.alias == _editor)
|
| + .single;
|
| + }
|
| +
|
| + Future openClass(M.IsolateRef i, M.ClassRef c) async {
|
| + S.Class clazz = c as S.Class;
|
| + assert(clazz != null);
|
| + if (!clazz.loaded) {
|
| + await clazz.load();
|
| + }
|
| + if (clazz.location == null) {
|
| + return new Future.value();
|
| + }
|
| + return await openSourceLocation(i, clazz.location);
|
| }
|
|
|
| - Future<M.Sentinel> sendObject(M.IsolateRef i, M.ObjectRef object) {
|
| + Future openSourceLocation(M.IsolateRef i, M.SourceLocation l) async {
|
| final isolate = i as S.Isolate;
|
| assert(isolate != null);
|
| - return isolate.invokeRpc(
|
| - '_sendObjectToEditor', {'editor': editor, 'objectId': object.id});
|
| + assert(l != null);
|
| + return await isolate.invokeRpc(_getService().method,
|
| + {'scriptId': l.script.id, 'tokenPos': l.tokenPos});
|
| }
|
| }
|
|
|