Chromium Code Reviews| Index: pkg/analysis_server/lib/src/status/ast_writer.dart |
| diff --git a/pkg/analysis_server/lib/src/status/ast_writer.dart b/pkg/analysis_server/lib/src/status/ast_writer.dart |
| index a5dd302da2b3c06d3077d7b558c8e45ced275f6a..97e9fa4eae46d824029ea9024b5260c9b54ee97a 100644 |
| --- a/pkg/analysis_server/lib/src/status/ast_writer.dart |
| +++ b/pkg/analysis_server/lib/src/status/ast_writer.dart |
| @@ -7,6 +7,7 @@ library analysis_server.src.status.ast_writer; |
| import 'dart:convert'; |
| import 'package:analyzer/src/generated/ast.dart'; |
| +import 'package:analyzer/src/generated/java_engine.dart'; |
| /** |
| * A visitor that will produce an HTML representation of an AST structure. |
| @@ -23,6 +24,12 @@ class AstWriter extends UnifyingAstVisitor { |
| int indentLevel = 0; |
| /** |
| + * A list containing the exceptions that were caught while attempting to write |
| + * out an AST structure. |
| + */ |
| + List<CaughtException> exceptions = <CaughtException>[]; |
| + |
| + /** |
| * Initialize a newly created element writer to write the HTML representation |
| * of visited nodes on the given [buffer]. |
| */ |
| @@ -174,9 +181,21 @@ class AstWriter extends UnifyingAstVisitor { |
| */ |
| void _writeProperty(String name, Object value) { |
| if (value != null) { |
| + String valueString = null; |
| + try { |
| + valueString = value.toString(); |
| + } catch (exception, stackTrace) { |
| + exceptions.add(new CaughtException(exception, stackTrace)); |
| + } |
| _indent(2); |
| buffer.write('$name = '); |
| - buffer.write(HTML_ESCAPE.convert(value.toString())); |
| + if (valueString == null) { |
| + buffer.write('<span style="color: #FF0000">'); |
| + buffer.write(HTML_ESCAPE.convert(value.runtimeType.toString())); |
|
Paul Berry
2015/02/02 23:08:59
Nit: this will print "Null" in red whenever an err
Brian Wilkerson
2015/02/02 23:25:03
Why? The value of 'value' is known to be non-null,
Paul Berry
2015/02/02 23:32:27
Sorry, I misread the code. lgtm as is.
|
| + buffer.write('</span>'); |
| + } else { |
| + buffer.write(HTML_ESCAPE.convert(valueString)); |
| + } |
| buffer.write('<br>'); |
| } |
| } |