| Index: runtime/observatory/lib/src/elements/script_inset.dart
|
| diff --git a/runtime/observatory/lib/src/elements/script_inset.dart b/runtime/observatory/lib/src/elements/script_inset.dart
|
| index 164c134a0b654b689b710d3a2a2736148faec24e..f2610bc7f0181c20bd6909d283e616c38cad43fb 100644
|
| --- a/runtime/observatory/lib/src/elements/script_inset.dart
|
| +++ b/runtime/observatory/lib/src/elements/script_inset.dart
|
| @@ -9,6 +9,7 @@ import 'dart:html';
|
| import 'observatory_element.dart';
|
| import 'service_ref.dart';
|
| import 'package:observatory/service.dart';
|
| +import 'package:observatory/utils.dart';
|
| import 'package:polymer/polymer.dart';
|
|
|
| const nbsp = "\u00A0";
|
| @@ -95,6 +96,24 @@ class CurrentExecutionAnnotation extends Annotation {
|
| }
|
| }
|
|
|
| +class LocalVariableAnnotation extends Annotation {
|
| + final value;
|
| +
|
| + LocalVariableAnnotation(LocalVarLocation location, this.value) {
|
| + line = location.line;
|
| + columnStart = location.column;
|
| + columnStop = location.endColumn;
|
| + }
|
| +
|
| + void applyStyleTo(element) {
|
| + if (element == null) {
|
| + return; // TODO(rmacnak): Handling overlapping annotations.
|
| + }
|
| + element.style.fontWeight = "bold";
|
| + element.title = "${value.shortName}";
|
| + }
|
| +}
|
| +
|
| class CallSiteAnnotation extends Annotation {
|
| CallSite callSite;
|
|
|
| @@ -219,6 +238,7 @@ class ScriptInsetElement extends ObservatoryElement {
|
| @published int startPos;
|
| @published int endPos;
|
| @published bool inDebuggerContext = false;
|
| + @published ObservableList variables;
|
|
|
| int _currentLine;
|
| int _currentCol;
|
| @@ -251,20 +271,24 @@ class ScriptInsetElement extends ObservatoryElement {
|
| }
|
|
|
| void currentPosChanged(oldValue) {
|
| - update();
|
| + _updateTask.queue();
|
| _scrollToCurrentPos();
|
| }
|
|
|
| void startPosChanged(oldValue) {
|
| - update();
|
| + _updateTask.queue();
|
| }
|
|
|
| void endPosChanged(oldValue) {
|
| - update();
|
| + _updateTask.queue();
|
| }
|
|
|
| void scriptChanged(oldValue) {
|
| - update();
|
| + _updateTask.queue();
|
| + }
|
| +
|
| + void variablesChanged(oldValue) {
|
| + _updateTask.queue();
|
| }
|
|
|
| Element a(String text) => new AnchorElement()..text = text;
|
| @@ -288,7 +312,9 @@ class ScriptInsetElement extends ObservatoryElement {
|
|
|
| Element container;
|
|
|
| + Task _updateTask;
|
| void update() {
|
| + assert(_updateTask != null);
|
| if (script == null) {
|
| // We may have previously had a script.
|
| if (container != null) {
|
| @@ -377,6 +403,22 @@ class ScriptInsetElement extends ObservatoryElement {
|
| }
|
| }
|
|
|
| + // We have local variable information.
|
| + if (variables != null) {
|
| + // For each variable.
|
| + for (var variable in variables) {
|
| + // Find variable usage locations.
|
| + var locations = script.scanForLocalVariableLocations(
|
| + variable['name'], variable['tokenPos'], variable['endTokenPos']);
|
| +
|
| + // Annotate locations.
|
| + for (var location in locations) {
|
| + annotations.add(new LocalVariableAnnotation(location,
|
| + variable['value']));
|
| + }
|
| + }
|
| + }
|
| +
|
| annotations.sort();
|
| }
|
|
|
| @@ -561,5 +603,8 @@ class ScriptInsetElement extends ObservatoryElement {
|
| return e;
|
| }
|
|
|
| - ScriptInsetElement.created() : super.created();
|
| + ScriptInsetElement.created()
|
| + : super.created() {
|
| + _updateTask = new Task(update);
|
| + }
|
| }
|
|
|