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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
13 14
14 String get hoverText { 15 String get hoverText {
15 if (ref == null) { 16 if (ref == null) {
16 return super.hoverText; 17 return super.hoverText;
17 } 18 }
18 if (line < 0) { 19 return ref.vmName;
19 return ref.vmName; 20 }
20 } else { 21
21 return '${ref.vmName}:$line'; 22 void posChanged(oldValue) {
23 _updateProperties(null);
24 }
25
26 void _updateProperties(_) {
27 if (ref != null && ref.loaded) {
28 notifyPropertyChange(#name, 0, 1);
29 notifyPropertyChange(#url, 0, 1);
22 } 30 }
23 } 31 }
24 32
25 String get name { 33 String get name {
26 if (ref == null) { 34 if (ref == null) {
27 return super.name; 35 return super.name;
28 } 36 }
29 if (line < 0) { 37 if (pos >= 0) {
30 return ref.name; 38 if (ref.loaded) {
31 } else { 39 // Script is loaded, get the line number.
32 return '${ref.name}:$line'; 40 Script script = ref;
41 return '${super.name}:${script.tokenToLine(pos)}';
42 } else {
43 ref.load().then(_updateProperties);
44 }
33 } 45 }
46 return super.name;
47 }
48
49 String get url {
50 if (ref == null) {
51 return super.url;
52 }
53 if (pos >= 0) {
54 if (ref.loaded) {
55 // Script is loaded, get the line number.
56 Script script = ref;
57 return '${super.url}#line=${script.tokenToLine(pos)}';
58 } else {
59 ref.load().then(_updateProperties);
60 }
61 }
62 return super.url;
34 } 63 }
35 64
36 ScriptRefElement.created() : super.created(); 65 ScriptRefElement.created() : super.created();
37 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698