Index: runtime/bin/vmservice/client/lib/src/elements/script_ref.dart |
diff --git a/runtime/bin/vmservice/client/lib/src/elements/script_ref.dart b/runtime/bin/vmservice/client/lib/src/elements/script_ref.dart |
index 1eaf1b46c338e96d11171663404126fcd568fd2b..1d368cfc4739b735e4acca725bb9ef1c8fa3f5fc 100644 |
--- a/runtime/bin/vmservice/client/lib/src/elements/script_ref.dart |
+++ b/runtime/bin/vmservice/client/lib/src/elements/script_ref.dart |
@@ -5,20 +5,30 @@ |
library script_ref_element; |
import 'package:polymer/polymer.dart'; |
+import 'package:observatory/service.dart'; |
import 'service_ref.dart'; |
@CustomTag('script-ref') |
class ScriptRefElement extends ServiceRefElement { |
- @published int line = -1; |
+ @published int pos = -1; |
+ bool loadStarted = false; |
Cutch
2014/03/28 20:22:32
Here too.
|
String get hoverText { |
if (ref == null) { |
return super.hoverText; |
} |
- if (line < 0) { |
- return ref.vmName; |
- } else { |
- return '${ref.vmName}:$line'; |
+ return ref.vmName; |
+ } |
+ |
+ void posChanged(oldValue) { |
+ loadStarted = false; |
+ _updateProperties(); |
+ } |
+ |
+ void _updateProperties(_) { |
+ if (ref.loaded) { |
+ notifyPropertyChange(#name, 0, 1); |
+ notifyPropertyChange(#url, 0, 1); |
} |
} |
@@ -26,11 +36,36 @@ class ScriptRefElement extends ServiceRefElement { |
if (ref == null) { |
return super.name; |
} |
- if (line < 0) { |
- return ref.name; |
- } else { |
- return '${ref.name}:$line'; |
+ if (pos >= 0) { |
+ if (ref.loaded) { |
+ // Script is loaded, get the line number. |
+ Script script = ref; |
+ return '${super.name}:${script.tokenToLine(pos)}'; |
+ } else if (!loadStarted) { |
+ // Script is not loaded. Load now. |
+ loadStarted = true; |
+ ref.load().then(_updateProperties); |
+ } |
+ } |
+ return super.name; |
+ } |
+ |
+ String get url { |
+ if (ref == null) { |
+ return super.url; |
+ } |
+ if (pos >= 0) { |
+ if (ref.loaded) { |
+ // Script is loaded, get the line number. |
+ Script script = ref; |
+ return '${super.url}#line=${script.tokenToLine(pos)}'; |
+ } else if (!loadStarted) { |
+ // Script is not loaded. Load now. |
+ loadStarted = true; |
+ ref.load().then(_updateProperties); |
+ } |
} |
+ return super.url; |
} |
ScriptRefElement.created() : super.created(); |