| OLD | NEW |
| (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('┊ '); |
| 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 } |
| OLD | NEW |