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

Side by Side Diff: runtime/observatory/lib/src/elements/service_ref.dart

Issue 2244433003: Converted Observatory refs elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library service_ref_element; 5 library service_ref_element;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 8
9 import 'package:logging/logging.dart'; 9 import 'package:logging/logging.dart';
10 import 'package:observatory/models.dart' as M;
11 import 'package:observatory/service.dart'; 10 import 'package:observatory/service.dart';
11 import 'package:observatory/repositories.dart';
12 import 'package:polymer/polymer.dart'; 12 import 'package:polymer/polymer.dart';
13 13
14 import 'class_ref.dart'; 14 import 'helpers/any_ref.dart';
15 import 'class_ref_as_value.dart';
16 import 'code_ref.dart';
17 import 'error_ref.dart';
18 import 'function_ref.dart';
19 import 'library_ref.dart';
20 import 'library_ref_as_value.dart';
21 import 'script_ref.dart';
22 import 'observatory_element.dart'; 15 import 'observatory_element.dart';
23 16
24 class ServiceRefElement extends ObservatoryElement { 17 class ServiceRefElement extends ObservatoryElement {
25 @published ServiceObject ref; 18 @published ServiceObject ref;
26 @published bool internal = false; 19 @published bool internal = false;
27 @published String expandKey; 20 @published String expandKey;
28 ServiceRefElement.created() : super.created(); 21 ServiceRefElement.created() : super.created();
29 22
30 void refChanged(oldValue) { 23 void refChanged(oldValue) {
31 notifyPropertyChange(#url, "", url); 24 notifyPropertyChange(#url, "", url);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 80 }
88 81
89 82
90 @CustomTag('any-service-ref') 83 @CustomTag('any-service-ref')
91 class AnyServiceRefElement extends ObservatoryElement { 84 class AnyServiceRefElement extends ObservatoryElement {
92 @published ServiceObject ref; 85 @published ServiceObject ref;
93 @published String expandKey; 86 @published String expandKey;
94 @published bool asValue = false; 87 @published bool asValue = false;
95 AnyServiceRefElement.created() : super.created(); 88 AnyServiceRefElement.created() : super.created();
96 89
97 Element _constructElementForRef() {
98 var type = ref.type;
99 switch (type) {
100 case 'Class':
101 if (asValue) {
102 ClassRefAsValueElement element =
103 new Element.tag('class-ref-as-element');
104 element.ref = ref;
105 return element;
106 }
107 return new ClassRefElement(ref.isolate,
108 ref as M.ClassRef,
109 queue: app.queue);
110 case 'Code':
111 return new CodeRefElement(ref.isolate, ref as M.Code, queue: app.queue);
112 case 'Context':
113 ServiceRefElement element = new Element.tag('context-ref');
114 element.ref = ref;
115 return element;
116 case 'Error':
117 return new ErrorRefElement(ref as M.ErrorRef, queue: app.queue);
118 case 'Field':
119 ServiceRefElement element = new Element.tag('field-ref');
120 element.ref = ref;
121 return element;
122 case 'Function':
123 return new FunctionRefElement(ref.isolate,
124 ref as M.FunctionRef,
125 queue: app.queue);
126 case 'Library':
127 if (asValue) {
128 LibraryRefAsValueElement element =
129 new Element.tag('library-ref-as-value');
130 element.ref = ref;
131 return element;
132 }
133 return new LibraryRefElement(ref.isolate,
134 ref as M.LibraryRef,
135 queue: app.queue);
136 case 'Object':
137 ServiceRefElement element = new Element.tag('object-ref');
138 element.ref = ref;
139 return element;
140 case 'Script':
141 return new ScriptRefElement(ref.isolate,
142 ref as M.ScriptRef,
143 queue: app.queue);
144 case 'Instance':
145 case 'Sentinel':
146 ServiceRefElement element = new Element.tag('instance-ref');
147 element.ref = ref;
148 if (expandKey != null) {
149 element.expandKey = expandKey;
150 }
151 return element;
152 default:
153 SpanElement element = new Element.tag('span');
154 element.text = "<<Unknown service ref: $ref>>";
155 return element;
156 }
157 }
158
159 refChanged(oldValue) { 90 refChanged(oldValue) {
160 // Remove the current view. 91 // Remove the current view.
161 children.clear(); 92 children.clear();
162 if (ref == null) { 93 if (ref == null) {
163 Logger.root.info('Viewing null object.'); 94 Logger.root.info('Viewing null object.');
164 return; 95 return;
165 } 96 }
166 var type = ref.type; 97 var obj;
167 var element = _constructElementForRef(); 98 if (ref is Guarded) {
99 var g = ref as Guarded;
100 obj = g.asValue ?? g.asSentinel;
101 } else {
102 obj = ref;
103 }
104 var element;
105 switch (obj.type) {
106 case 'Class':
107 if (asValue) {
108 element = new Element.tag('class-ref-as-value');
109 element.ref = obj;
110 } else {
111 element = new Element.tag('class-ref');
112 element.ref = obj;
113 }
114 break;
115 case 'Code':
116 element = new Element.tag('code-ref');
117 element.ref = obj;
118 break;
119 case 'Context':
120 element = new Element.tag('context-ref');
121 element.ref = obj;
122 break;
123 case 'Error':
124 element = new Element.tag('error-ref');
125 element.ref = obj;
126 break;
127 case 'Field':
128 element = new Element.tag('field-ref');
129 element.ref = obj;
130 break;
131 case 'Function':
132 element = new Element.tag('function-ref');
133 element.ref = obj;
134 break;
135 case 'Instance':
136 element = new Element.tag('instance-ref');
137 element.ref = obj;
138 break;
139 case 'Library':
140 if (asValue) {
141 element =
142 new Element.tag('library-ref-as-value');
143 element.ref = obj;
144 } else {
145 element =
146 new Element.tag('library-ref');
147 element.ref = obj;
148 }
149 break;
150 case 'Script':
151 element = new Element.tag('script-ref');
152 element.ref = obj;
153 break;
154 default:
155 element = anyRef(obj.isolate, obj,
156 new InstanceRepository(obj.isolate), queue: app.queue);
157 break;
158 }
168 if (element == null) { 159 if (element == null) {
169 Logger.root.info('Unable to find a ref element for \'${type}\''); 160 Logger.root.info('Unable to find a ref element for \'${ref.type}\'');
161 element = new Element.tag('span');
162 element.text = "<<Unknown service ref: $ref>>";
170 return; 163 return;
171 } 164 }
172 children.add(element); 165 children.add(element);
173 } 166 }
174 } 167 }
175
176 @CustomTag('object-ref')
177 class ObjectRefElement extends ServiceRefElement {
178 ObjectRefElement.created() : super.created();
179 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/sentinel_value.dart ('k') | runtime/observatory/lib/src/elements/service_ref.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698