Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: runtime/bin/vmservice/client/lib/src/elements/script_ref.dart

Issue 216883008: Use tokenPos instead of line/col in the vm service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js / handle multiple reloads Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698