Chromium Code Reviews| Index: runtime/bin/vmservice/client/lib/src/elements/script_inset.dart |
| diff --git a/runtime/bin/vmservice/client/lib/src/elements/script_inset.dart b/runtime/bin/vmservice/client/lib/src/elements/script_inset.dart |
| index ba6c127d4976a57f13833b26440d861dc789e3de..9ae15e12443c573f15043f82ac9e4da6f7314f0f 100644 |
| --- a/runtime/bin/vmservice/client/lib/src/elements/script_inset.dart |
| +++ b/runtime/bin/vmservice/client/lib/src/elements/script_inset.dart |
| @@ -8,14 +8,16 @@ import 'observatory_element.dart'; |
| import 'package:observatory/service.dart'; |
| import 'package:polymer/polymer.dart'; |
| -/// Displays an Error response. |
| +/// Box with script source code in it. |
| @CustomTag('script-inset') |
| class ScriptInsetElement extends ObservatoryElement { |
| @published Script script; |
| @published int pos; |
| + @published int endPos; |
| + @published bool coverage = false; |
| @observable List<ScriptLine> lines = toObservable([]); |
| - |
| + |
| void scriptChanged(oldValue) { |
| _updateProperties(); |
| } |
| @@ -24,6 +26,31 @@ class ScriptInsetElement extends ObservatoryElement { |
| _updateProperties(); |
| } |
| + coverageChanged(oldValue) { |
| + notifyPropertyChange(#hitsStyle, 0, 1); |
| + print(coverage); |
| + } |
| + |
| + static const hitStyleNone = 'min-width:32px;'; |
| + static const hitStyleExecuted = 'min-width:32px;background-color:green'; |
| + static const hitStyleNotExecuted = 'min-width:32px;background-color:red'; |
| + |
| + @observable String hitsStyle(ScriptLine line) { |
|
turnidge
2014/04/01 19:42:48
This function is called "hitsStyle" (hits, plural)
Cutch
2014/04/02 18:26:52
Not intentional and fixed.
|
| + if ((script == null) || !coverage) { |
| + return hitStyleNone; |
| + } |
| + var hit = script.hits[line.line]; |
| + if (hit == null) { |
| + return hitStyleNone; |
| + } |
| + if (hit == 0) { |
| + return hitStyleNotExecuted; |
| + } |
| + assert(hit > 0); |
| + return hitStyleExecuted; |
| + } |
| + |
| + |
| void _updateProperties() { |
| if (!script.loaded) { |
| script.load().then((_) { |
| @@ -34,9 +61,17 @@ class ScriptInsetElement extends ObservatoryElement { |
| return; |
| } |
| notifyPropertyChange(#lines, 0, 1); |
| - var lineNumber = script.tokenToLine(pos); |
| lines.clear(); |
| - lines.add(script.lines[lineNumber-1]); |
| + var startLineNumber = script.tokenToLine(pos); |
| + if (endPos == null) { |
| + lines.add(script.lines[startLineNumber - 1]); |
| + } else { |
| + var endLineNumber = script.tokenToLine(endPos); |
| + assert(endLineNumber != null); |
| + for (var i = startLineNumber; i <= endLineNumber; i++) { |
| + lines.add(script.lines[i - 1]); |
| + } |
| + } |
| } |
| ScriptInsetElement.created() : super.created(); |