OLD | NEW |
---|---|
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 function_view_element; | 5 library function_view_element; |
6 | 6 |
7 import 'observatory_element.dart'; | 7 import 'observatory_element.dart'; |
8 import 'package:observatory/service.dart'; | 8 import 'package:observatory/service.dart'; |
9 | 9 |
10 import 'package:polymer/polymer.dart'; | 10 import 'package:polymer/polymer.dart'; |
11 | 11 |
12 @CustomTag('function-view') | 12 @CustomTag('function-view') |
13 class FunctionViewElement extends ObservatoryElement { | 13 class FunctionViewElement extends ObservatoryElement { |
14 @published ServiceMap function; | 14 @published ServiceMap function; |
15 FunctionViewElement.created() : super.created(); | 15 FunctionViewElement.created() : super.created(); |
16 | 16 |
17 @published String qualifiedName; | |
18 @published String kind; | |
19 | |
20 String _getQualifiedName(ServiceMap function) { | |
21 var parent = (function != null && function['parent'] != null | |
22 ? function['parent'] : null); | |
23 if (parent != null) { | |
24 return "${_getQualifiedName(parent)}.${function['user_name']}"; | |
25 } | |
26 var cls = (function != null && | |
27 function['class'] != null && | |
28 function['class']['user_name'] != null && | |
29 function['class']['user_name'] != '::' | |
30 ? function['class'] : null); | |
31 if (cls != null) { | |
32 return "${cls['user_name']}.${function['user_name']}"; | |
33 } | |
34 return "${function['username']}"; | |
35 } | |
36 | |
37 void functionChanged(oldValue) { | |
38 notifyPropertyChange(#qualifiedName, 0, 1); | |
39 notifyPropertyChange(#kind, 0, 1); | |
40 qualifiedName = _getQualifiedName(function); | |
41 switch(function['kind']) { | |
Cutch
2014/03/25 23:12:38
Maybe add a TODO here that this code should be fac
turnidge
2014/03/26 17:05:20
Done.
| |
42 case 'kRegularFunction': | |
43 kind = 'function'; | |
44 break; | |
45 case 'kClosureFunction': | |
46 kind = 'closure function'; | |
47 break; | |
48 case 'kSignatureFunction': | |
49 kind = 'signature function'; | |
50 break; | |
51 case 'kGetterFunction': | |
52 kind = 'getter function'; | |
53 break; | |
54 case 'kSetterFunction': | |
55 kind = 'setter function'; | |
56 break; | |
57 case 'kConstructor': | |
58 kind = 'constructor'; | |
59 break; | |
60 case 'kImplicitGetterFunction': | |
61 kind = 'implicit getter function'; | |
62 break; | |
63 case 'kImplicitSetterFunction': | |
64 kind = 'implicit setter function'; | |
65 break; | |
66 case 'kStaticInitializer': | |
67 kind = 'static initializer'; | |
68 break; | |
69 case 'kMethodExtractor': | |
70 kind = 'method extractor'; | |
71 break; | |
72 case 'kNoSuchMethodDispatcher': | |
73 kind = 'noSuchMethod dispatcher'; | |
74 break; | |
75 case 'kInvokeFieldDispatcher': | |
76 kind = 'invoke field dispatcher'; | |
77 break; | |
78 default: | |
79 kind = 'UNKNOWN'; | |
80 break; | |
81 } | |
82 } | |
83 | |
17 void refresh(var done) { | 84 void refresh(var done) { |
18 function.reload().whenComplete(done); | 85 function.reload().whenComplete(done); |
19 } | 86 } |
20 } | 87 } |
OLD | NEW |