Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_inset_element; | 5 library script_inset_element; |
| 6 | 6 |
| 7 import 'observatory_element.dart'; | 7 import 'observatory_element.dart'; |
| 8 import 'package:observatory/service.dart'; | 8 import 'package:observatory/service.dart'; |
| 9 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
| 10 | 10 |
| 11 /// Displays an Error response. | 11 /// Box with script source code in it. |
| 12 @CustomTag('script-inset') | 12 @CustomTag('script-inset') |
| 13 class ScriptInsetElement extends ObservatoryElement { | 13 class ScriptInsetElement extends ObservatoryElement { |
| 14 @published Script script; | 14 @published Script script; |
| 15 @published int pos; | 15 @published int pos; |
| 16 @published int endPos; | |
| 17 @published bool coverage = false; | |
| 16 | 18 |
| 17 @observable List<ScriptLine> lines = toObservable([]); | 19 @observable List<ScriptLine> lines = toObservable([]); |
| 18 | 20 |
| 19 void scriptChanged(oldValue) { | 21 void scriptChanged(oldValue) { |
| 20 _updateProperties(); | 22 _updateProperties(); |
| 21 } | 23 } |
| 22 | 24 |
| 23 void posChanged(oldValue) { | 25 void posChanged(oldValue) { |
| 24 _updateProperties(); | 26 _updateProperties(); |
| 25 } | 27 } |
| 26 | 28 |
| 29 coverageChanged(oldValue) { | |
| 30 notifyPropertyChange(#hitsStyle, 0, 1); | |
| 31 print(coverage); | |
| 32 } | |
| 33 | |
| 34 static const hitStyleNone = 'min-width:32px;'; | |
| 35 static const hitStyleExecuted = 'min-width:32px;background-color:green'; | |
| 36 static const hitStyleNotExecuted = 'min-width:32px;background-color:red'; | |
| 37 | |
| 38 @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.
| |
| 39 if ((script == null) || !coverage) { | |
| 40 return hitStyleNone; | |
| 41 } | |
| 42 var hit = script.hits[line.line]; | |
| 43 if (hit == null) { | |
| 44 return hitStyleNone; | |
| 45 } | |
| 46 if (hit == 0) { | |
| 47 return hitStyleNotExecuted; | |
| 48 } | |
| 49 assert(hit > 0); | |
| 50 return hitStyleExecuted; | |
| 51 } | |
| 52 | |
| 53 | |
| 27 void _updateProperties() { | 54 void _updateProperties() { |
| 28 if (!script.loaded) { | 55 if (!script.loaded) { |
| 29 script.load().then((_) { | 56 script.load().then((_) { |
| 30 if (script.loaded) { | 57 if (script.loaded) { |
| 31 _updateProperties(); | 58 _updateProperties(); |
| 32 } | 59 } |
| 33 }); | 60 }); |
| 34 return; | 61 return; |
| 35 } | 62 } |
| 36 notifyPropertyChange(#lines, 0, 1); | 63 notifyPropertyChange(#lines, 0, 1); |
| 37 var lineNumber = script.tokenToLine(pos); | |
| 38 lines.clear(); | 64 lines.clear(); |
| 39 lines.add(script.lines[lineNumber-1]); | 65 var startLineNumber = script.tokenToLine(pos); |
| 66 if (endPos == null) { | |
| 67 lines.add(script.lines[startLineNumber - 1]); | |
| 68 } else { | |
| 69 var endLineNumber = script.tokenToLine(endPos); | |
| 70 assert(endLineNumber != null); | |
| 71 for (var i = startLineNumber; i <= endLineNumber; i++) { | |
| 72 lines.add(script.lines[i - 1]); | |
| 73 } | |
| 74 } | |
| 40 } | 75 } |
| 41 | 76 |
| 42 ScriptInsetElement.created() : super.created(); | 77 ScriptInsetElement.created() : super.created(); |
| 43 } | 78 } |
| OLD | NEW |