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

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 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 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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698