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..c88d43a7045e5ec6d48884bcc65d7ef15a815a99 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,28 @@ |
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; |
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) { |
+ _updateProperties(null); |
+ } |
+ |
+ void _updateProperties(_) { |
+ if (ref != null && ref.loaded) { |
+ notifyPropertyChange(#name, 0, 1); |
+ notifyPropertyChange(#url, 0, 1); |
} |
} |
@@ -26,11 +34,32 @@ 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 { |
+ 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 { |
+ ref.load().then(_updateProperties); |
+ } |
} |
+ return super.url; |
} |
ScriptRefElement.created() : super.created(); |