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

Side by Side Diff: runtime/observatory/lib/src/elements/json_view.dart

Issue 2345023003: Use dartfmt on Observatory code (Closed)
Patch Set: merge Created 4 years, 3 months 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library json_view_element; 5 library json_view_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:observatory/models.dart' as M; 9 import 'package:observatory/models.dart' as M;
10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; 10 import 'package:observatory/src/elements/helpers/nav_bar.dart';
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
12 import 'package:observatory/src/elements/helpers/tag.dart'; 12 import 'package:observatory/src/elements/helpers/tag.dart';
13 import 'package:observatory/src/elements/nav/notify.dart'; 13 import 'package:observatory/src/elements/nav/notify.dart';
14 import 'package:observatory/src/elements/nav/top_menu.dart'; 14 import 'package:observatory/src/elements/nav/top_menu.dart';
15 import 'package:observatory/src/elements/view_footer.dart'; 15 import 'package:observatory/src/elements/view_footer.dart';
16 16
17 class JSONViewElement extends HtmlElement implements Renderable { 17 class JSONViewElement extends HtmlElement implements Renderable {
18 static const tag = const Tag<JSONViewElement>('json-view', 18 static const tag = const Tag<JSONViewElement>('json-view',
19 dependencies: const [ 19 dependencies: const [
20 NavTopMenuElement.tag, 20 NavTopMenuElement.tag,
21 NavNotifyElement.tag, 21 NavNotifyElement.tag,
22 ViewFooterElement.tag 22 ViewFooterElement.tag
23 ]); 23 ]);
24 24
25 RenderingScheduler<JSONViewElement> _r; 25 RenderingScheduler<JSONViewElement> _r;
26 26
27 Stream<RenderedEvent<JSONViewElement>> get onRendered => _r.onRendered; 27 Stream<RenderedEvent<JSONViewElement>> get onRendered => _r.onRendered;
28 28
29 M.NotificationRepository _notifications; 29 M.NotificationRepository _notifications;
30 Map _map; 30 Map _map;
31 31
32
33 M.NotificationRepository get notifications => _notifications; 32 M.NotificationRepository get notifications => _notifications;
34 Map get map => _map; 33 Map get map => _map;
35 34
36 factory JSONViewElement(Map map, 35 factory JSONViewElement(Map map, M.NotificationRepository notifications,
37 M.NotificationRepository notifications, 36 {RenderingQueue queue}) {
38 {RenderingQueue queue}) {
39 assert(notifications != null); 37 assert(notifications != null);
40 assert(map != null); 38 assert(map != null);
41 JSONViewElement e = document.createElement(tag.name); 39 JSONViewElement e = document.createElement(tag.name);
42 e._r = new RenderingScheduler(e, queue: queue); 40 e._r = new RenderingScheduler(e, queue: queue);
43 e._notifications = notifications; 41 e._notifications = notifications;
44 e._map = map; 42 e._map = map;
45 return e; 43 return e;
46 } 44 }
47 45
48 JSONViewElement.created() : super.created(); 46 JSONViewElement.created() : super.created();
(...skipping 10 matching lines...) Expand all
59 _r.disable(notify: true); 57 _r.disable(notify: true);
60 children = []; 58 children = [];
61 } 59 }
62 60
63 void render() { 61 void render() {
64 children = [ 62 children = [
65 navBar([ 63 navBar([
66 new NavTopMenuElement(queue: _r.queue), 64 new NavTopMenuElement(queue: _r.queue),
67 new NavNotifyElement(_notifications, queue: _r.queue) 65 new NavNotifyElement(_notifications, queue: _r.queue)
68 ]), 66 ]),
69 new DivElement()..classes = ['content-centered-big'] 67 new DivElement()
68 ..classes = ['content-centered-big']
70 ..children = [ 69 ..children = [
71 new HeadingElement.h2()..text = 'Object', 70 new HeadingElement.h2()..text = 'Object',
72 new HRElement(), 71 new HRElement(),
73 new PreElement() 72 new PreElement()..text = JSONPretty.stringify(_map),
74 ..text = JSONPretty.stringify(_map),
75 new HRElement(), 73 new HRElement(),
76 new ViewFooterElement(queue: _r.queue) 74 new ViewFooterElement(queue: _r.queue)
77 ] 75 ]
78 ]; 76 ];
79 } 77 }
80 } 78 }
81 79
82
83 class JSONPretty { 80 class JSONPretty {
84 JSONPretty._(); 81 JSONPretty._();
85 82
86 static String stringify(Map map) => new JSONPretty._()._stringify(map); 83 static String stringify(Map map) => new JSONPretty._()._stringify(map);
87 84
88 String _stringify(Map map) { 85 String _stringify(Map map) {
89 _buffer.clear(); 86 _buffer.clear();
90 _buffer.write('{\n'); 87 _buffer.write('{\n');
91 _printMap(map, 0); 88 _printMap(map, 0);
92 _buffer.write('}\n'); 89 _buffer.write('}\n');
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } else { 139 } else {
143 _writeIndent(depth); 140 _writeIndent(depth);
144 _buffer.write(v); 141 _buffer.write(v);
145 _buffer.write('\n'); 142 _buffer.write('\n');
146 } 143 }
147 } 144 }
148 _seen.remove(list); 145 _seen.remove(list);
149 } 146 }
150 147
151 void _writeIndent(int depth) { 148 void _writeIndent(int depth) {
152 const tab = ' '; // 2 spaces. 149 const tab = ' '; // 2 spaces.
153 _buffer.write(tab * depth); 150 _buffer.write(tab * depth);
154 } 151 }
155 152
156 final _buffer = new StringBuffer(); 153 final _buffer = new StringBuffer();
157 final _seen = new Set(); 154 final _seen = new Set();
158 } 155 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/isolate_view.dart ('k') | runtime/observatory/lib/src/elements/library_ref.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698