Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of observatory; | |
| 6 | |
| 7 class ScriptSourceLine { | |
| 8 final int line; | |
| 9 final int numDigits; | |
| 10 final String src; | |
| 11 ScriptSourceLine(this.line, this.numDigits, this.src); | |
| 12 String get paddedLine { | |
| 13 String paddedLine = '$line'; | |
| 14 for (int i = paddedLine.length; i < numDigits; i++) { | |
| 15 paddedLine = '0$paddedLine'; | |
|
Ivan Posva
2013/11/19 23:24:05
Please pad with spaces.
Cutch
2013/11/27 19:54:42
Done.
| |
| 16 } | |
| 17 return paddedLine; | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 class ScriptSource extends Observable { | |
| 22 @observable String url = ''; | |
| 23 @observable List<ScriptSourceLine> lines = toObservable([]); | |
| 24 | |
| 25 ScriptSource(Map response) { | |
| 26 url = response['name']; | |
| 27 buildSourceLines(response['source']); | |
| 28 } | |
| 29 | |
| 30 void buildSourceLines(String src) { | |
| 31 List<String> splitSrc = src.split('\n'); | |
| 32 int numDigits = '${splitSrc.length+1}'.length; | |
| 33 for (int i = 0; i < splitSrc.length; i++) { | |
| 34 ScriptSourceLine sourceLine = new ScriptSourceLine(i+1, numDigits, | |
| 35 splitSrc[i]); | |
| 36 lines.add(sourceLine); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 String toString() => 'ScriptSource'; | |
| 41 } | |
| OLD | NEW |