| 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 extends Observable { | |
| 8 final int line; | |
| 9 final int numDigits; | |
| 10 @observable final String src; | |
| 11 @observable String paddedLine; | |
| 12 ScriptSourceLine(this.line, this.numDigits, this.src) { | |
| 13 paddedLine = '$line'; | |
| 14 for (int i = paddedLine.length; i < numDigits; i++) { | |
| 15 paddedLine = ' $paddedLine'; | |
| 16 } | |
| 17 } | |
| 18 } | |
| 19 | |
| 20 class ScriptSource extends Observable { | |
| 21 @observable String kind = ''; | |
| 22 @observable String url = ''; | |
| 23 @observable List<ScriptSourceLine> lines = toObservable([]); | |
| 24 | |
| 25 ScriptSource(Map response) { | |
| 26 kind = response['kind']; | |
| 27 url = response['name']; | |
| 28 buildSourceLines(response['source']); | |
| 29 } | |
| 30 | |
| 31 void buildSourceLines(String src) { | |
| 32 List<String> splitSrc = src.split('\n'); | |
| 33 int numDigits = '${splitSrc.length+1}'.length; | |
| 34 for (int i = 0; i < splitSrc.length; i++) { | |
| 35 ScriptSourceLine sourceLine = new ScriptSourceLine(i+1, numDigits, | |
| 36 splitSrc[i]); | |
| 37 lines.add(sourceLine); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 String toString() => 'ScriptSource'; | |
| 42 } | |
| OLD | NEW |