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

Side by Side Diff: pkg/analysis_server/lib/src/status/element_writer.dart

Issue 840953008: Alternate status page (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Sorted and formatted Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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 library analysis_server.src.status.element_writer;
6
7 import 'package:analysis_server/src/status/utilities.dart';
8 import 'package:analyzer/src/generated/element.dart';
9
10 /**
11 * A visitor that will produce an HTML representation of an element structure.
12 */
13 class ElementWriter extends GeneralizingElementVisitor {
14 /**
15 * The buffer on which the HTML is to be written.
16 */
17 final StringBuffer buffer;
18
19 /**
20 * The current level of indentation.
21 */
22 int indentLevel = 0;
23
24 /**
25 * Initialize a newly created element writer to write the HTML representation
26 * of visited elements on the given [buffer].
27 */
28 ElementWriter(this.buffer);
29
30 @override
31 void visitElement(Element element) {
32 for (int i = 0; i < indentLevel; i++) {
33 buffer.write('&#x250A;&nbsp;&nbsp;&nbsp;');
34 }
35 if (element.isSynthetic) {
36 buffer.write('<i>');
37 }
38 buffer.write(encodeHtml(element.toString()));
39 if (element.isSynthetic) {
40 buffer.write('</i>');
41 }
42 buffer.write(' <span style="color:gray">(');
43 buffer.write(element.runtimeType);
44 buffer.write(')</span><br>');
45 indentLevel++;
46 try {
47 element.visitChildren(this);
48 } finally {
49 indentLevel--;
50 }
51 }
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698