Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: runtime/bin/vmservice/client/lib/src/observatory/script_source.dart

Issue 59283007: List scripts in library and display script source (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698