| 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 // TODO(turnidge): Once we create a Function object, these fields | 17 // TODO(turnidge): Once we create a Function object, these fields |
| 18 // should move there. | 18 // should move there. |
| 19 @published String qualifiedName; | 19 @published String qualifiedName; |
| 20 @published String kind; | 20 @published String kind; |
| 21 | 21 |
| 22 String _getQualifiedName(ServiceMap function) { | 22 String _getQualifiedName(ServiceMap function) { |
| 23 var parent = (function != null && function['parent'] != null | 23 var parent = (function != null && function['parent'] != null |
| 24 ? function['parent'] : null); | 24 ? function['parent'] : null); |
| 25 if (parent != null) { | 25 if (parent != null) { |
| 26 return "${_getQualifiedName(parent)}.${function['user_name']}"; | 26 return "${_getQualifiedName(parent)}.${function['user_name']}"; |
| 27 } | 27 } |
| 28 var cls = (function != null && | 28 var cls = (function != null && |
| 29 function['class'] != null && | 29 function['owner'] != null && |
| 30 function['class']['user_name'] != null && | 30 function['owner'].serviceType == 'Class' |
| 31 function['class']['user_name'] != '::' | 31 ? function['owner'] : null); |
| 32 ? function['class'] : null); | |
| 33 if (cls != null) { | 32 if (cls != null) { |
| 34 return "${cls['user_name']}.${function['user_name']}"; | 33 return "${cls['user_name']}.${function['user_name']}"; |
| 35 } | 34 } |
| 36 return "${function['username']}"; | 35 return "${function['user_name']}"; |
| 37 } | 36 } |
| 38 | 37 |
| 39 void functionChanged(oldValue) { | 38 void functionChanged(oldValue) { |
| 40 notifyPropertyChange(#qualifiedName, 0, 1); | 39 notifyPropertyChange(#qualifiedName, 0, 1); |
| 41 notifyPropertyChange(#kind, 0, 1); | 40 notifyPropertyChange(#kind, 0, 1); |
| 42 qualifiedName = _getQualifiedName(function); | 41 qualifiedName = _getQualifiedName(function); |
| 43 switch(function['kind']) { | 42 switch(function['kind']) { |
| 44 case 'kRegularFunction': | 43 case 'kRegularFunction': |
| 45 kind = 'function'; | 44 kind = 'function'; |
| 46 break; | 45 break; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 default: | 79 default: |
| 81 kind = 'UNKNOWN'; | 80 kind = 'UNKNOWN'; |
| 82 break; | 81 break; |
| 83 } | 82 } |
| 84 } | 83 } |
| 85 | 84 |
| 86 void refresh(var done) { | 85 void refresh(var done) { |
| 87 function.reload().whenComplete(done); | 86 function.reload().whenComplete(done); |
| 88 } | 87 } |
| 89 } | 88 } |
| OLD | NEW |