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

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: 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..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();

Powered by Google App Engine
This is Rietveld 408576698