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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/vmservice/client/lib/src/observatory/script_source.dart
diff --git a/runtime/bin/vmservice/client/lib/src/observatory/script_source.dart b/runtime/bin/vmservice/client/lib/src/observatory/script_source.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f7c54f2ec26a6f15807d0369c733b031aef64db9
--- /dev/null
+++ b/runtime/bin/vmservice/client/lib/src/observatory/script_source.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of observatory;
+
+class ScriptSourceLine {
+ final int line;
+ final int numDigits;
+ final String src;
+ ScriptSourceLine(this.line, this.numDigits, this.src);
+ String get paddedLine {
+ String paddedLine = '$line';
+ for (int i = paddedLine.length; i < numDigits; i++) {
+ paddedLine = '0$paddedLine';
Ivan Posva 2013/11/19 23:24:05 Please pad with spaces.
Cutch 2013/11/27 19:54:42 Done.
+ }
+ return paddedLine;
+ }
+}
+
+class ScriptSource extends Observable {
+ @observable String url = '';
+ @observable List<ScriptSourceLine> lines = toObservable([]);
+
+ ScriptSource(Map response) {
+ url = response['name'];
+ buildSourceLines(response['source']);
+ }
+
+ void buildSourceLines(String src) {
+ List<String> splitSrc = src.split('\n');
+ int numDigits = '${splitSrc.length+1}'.length;
+ for (int i = 0; i < splitSrc.length; i++) {
+ ScriptSourceLine sourceLine = new ScriptSourceLine(i+1, numDigits,
+ splitSrc[i]);
+ lines.add(sourceLine);
+ }
+ }
+
+ String toString() => 'ScriptSource';
+}

Powered by Google App Engine
This is Rietveld 408576698