Chromium Code Reviews| 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 'service_ref.dart'; | 9 import 'service_ref.dart'; |
| 9 | 10 |
| 10 @CustomTag('script-ref') | 11 @CustomTag('script-ref') |
| 11 class ScriptRefElement extends ServiceRefElement { | 12 class ScriptRefElement extends ServiceRefElement { |
| 12 @published int line = -1; | 13 @published int pos = -1; |
| 14 bool loadStarted = false; | |
|
Cutch
2014/03/28 20:22:32
Here too.
| |
| 13 | 15 |
| 14 String get hoverText { | 16 String get hoverText { |
| 15 if (ref == null) { | 17 if (ref == null) { |
| 16 return super.hoverText; | 18 return super.hoverText; |
| 17 } | 19 } |
| 18 if (line < 0) { | 20 return ref.vmName; |
| 19 return ref.vmName; | 21 } |
| 20 } else { | 22 |
| 21 return '${ref.vmName}:$line'; | 23 void posChanged(oldValue) { |
| 24 loadStarted = false; | |
| 25 _updateProperties(); | |
| 26 } | |
| 27 | |
| 28 void _updateProperties(_) { | |
| 29 if (ref.loaded) { | |
| 30 notifyPropertyChange(#name, 0, 1); | |
| 31 notifyPropertyChange(#url, 0, 1); | |
| 22 } | 32 } |
| 23 } | 33 } |
| 24 | 34 |
| 25 String get name { | 35 String get name { |
| 26 if (ref == null) { | 36 if (ref == null) { |
| 27 return super.name; | 37 return super.name; |
| 28 } | 38 } |
| 29 if (line < 0) { | 39 if (pos >= 0) { |
| 30 return ref.name; | 40 if (ref.loaded) { |
| 31 } else { | 41 // Script is loaded, get the line number. |
| 32 return '${ref.name}:$line'; | 42 Script script = ref; |
| 43 return '${super.name}:${script.tokenToLine(pos)}'; | |
| 44 } else if (!loadStarted) { | |
| 45 // Script is not loaded. Load now. | |
| 46 loadStarted = true; | |
| 47 ref.load().then(_updateProperties); | |
| 48 } | |
| 33 } | 49 } |
| 50 return super.name; | |
| 51 } | |
| 52 | |
| 53 String get url { | |
| 54 if (ref == null) { | |
| 55 return super.url; | |
| 56 } | |
| 57 if (pos >= 0) { | |
| 58 if (ref.loaded) { | |
| 59 // Script is loaded, get the line number. | |
| 60 Script script = ref; | |
| 61 return '${super.url}#line=${script.tokenToLine(pos)}'; | |
| 62 } else if (!loadStarted) { | |
| 63 // Script is not loaded. Load now. | |
| 64 loadStarted = true; | |
| 65 ref.load().then(_updateProperties); | |
| 66 } | |
| 67 } | |
| 68 return super.url; | |
| 34 } | 69 } |
| 35 | 70 |
| 36 ScriptRefElement.created() : super.created(); | 71 ScriptRefElement.created() : super.created(); |
| 37 } | 72 } |
| OLD | NEW |