| 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 script_ref_element; | 5 library script_ref_element; |
| 6 | 6 |
| 7 import 'package:polymer/polymer.dart'; | 7 import 'package:polymer/polymer.dart'; |
| 8 import 'package:observatory/service.dart'; | 8 import 'package:observatory/service.dart'; |
| 9 import 'service_ref.dart'; | 9 import 'service_ref.dart'; |
| 10 | 10 |
| 11 @CustomTag('script-ref') | 11 @CustomTag('script-ref') |
| 12 class ScriptRefElement extends ServiceRefElement { | 12 class ScriptRefElement extends ServiceRefElement { |
| 13 @published int pos = -1; | 13 @published int pos; |
| 14 | 14 |
| 15 String get hoverText { | 15 String get hoverText { |
| 16 if (ref == null) { | 16 if (ref == null) { |
| 17 return super.hoverText; | 17 return super.hoverText; |
| 18 } | 18 } |
| 19 return ref.vmName; | 19 return ref.vmName; |
| 20 } | 20 } |
| 21 | 21 |
| 22 void posChanged(oldValue) { | 22 void posChanged(oldValue) { |
| 23 _updateProperties(null); | 23 _updateProperties(null); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void _updateProperties(_) { | 26 void _updateProperties(_) { |
| 27 if (ref != null && ref.loaded) { | 27 if (ref != null && ref.loaded) { |
| 28 notifyPropertyChange(#name, 0, 1); | 28 notifyPropertyChange(#name, 0, 1); |
| 29 notifyPropertyChange(#url, 0, 1); | 29 notifyPropertyChange(#url, 0, 1); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 String get name { | 33 String get name { |
| 34 if (ref == null) { | 34 if (ref == null) { |
| 35 return super.name; | 35 return super.name; |
| 36 } | 36 } |
| 37 if (pos >= 0) { | 37 if ((pos != null) && (pos >= 0)) { |
| 38 if (ref.loaded) { | 38 if (ref.loaded) { |
| 39 // Script is loaded, get the line number. | 39 // Script is loaded, get the line number. |
| 40 Script script = ref; | 40 Script script = ref; |
| 41 return '${super.name}:${script.tokenToLine(pos)}:' | 41 return '${super.name}:${script.tokenToLine(pos)}:' |
| 42 '${script.tokenToCol(pos)}'; | 42 '${script.tokenToCol(pos)}'; |
| 43 } else { | 43 } else { |
| 44 ref.load().then(_updateProperties); | 44 ref.load().then(_updateProperties); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 return super.name; | 47 return super.name; |
| 48 } | 48 } |
| 49 | 49 |
| 50 String get url { | 50 String get url { |
| 51 if (ref == null) { | 51 if (ref == null) { |
| 52 return super.url; | 52 return super.url; |
| 53 } | 53 } |
| 54 if (pos >= 0) { | 54 if ((pos != null) && (pos >= 0)) { |
| 55 if (ref.loaded) { | 55 if (ref.loaded) { |
| 56 return '${super.url}---pos=${pos}'; | 56 return '${super.url}---pos=${pos}'; |
| 57 } else { | 57 } else { |
| 58 ref.load().then(_updateProperties); | 58 ref.load().then(_updateProperties); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 return super.url; | 61 return super.url; |
| 62 } | 62 } |
| 63 | 63 |
| 64 ScriptRefElement.created() : super.created(); | 64 ScriptRefElement.created() : super.created(); |
| 65 } | 65 } |
| OLD | NEW |