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

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

Issue 922453002: Include source info in status AST dump (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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 analysis_server.src.status.ast_writer; 5 library analysis_server.src.status.ast_writer;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analysis_server/src/get_handler.dart'; 9 import 'package:analysis_server/src/get_handler.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analyzer/src/generated/element.dart';
12 import 'package:analyzer/src/generated/java_engine.dart'; 12 import 'package:analyzer/src/generated/java_engine.dart';
13 import 'package:analyzer/src/generated/source.dart';
13 14
14 /** 15 /**
15 * A visitor that will produce an HTML representation of an AST structure. 16 * A visitor that will produce an HTML representation of an AST structure.
16 */ 17 */
17 class AstWriter extends UnifyingAstVisitor { 18 class AstWriter extends UnifyingAstVisitor {
18 /** 19 /**
19 * The buffer on which the HTML is to be written. 20 * The buffer on which the HTML is to be written.
20 */ 21 */
21 final StringBuffer buffer; 22 final StringBuffer buffer;
22 23
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 _writeProperty('name', _getName(node)); 136 _writeProperty('name', _getName(node));
136 if (node is BinaryExpression) { 137 if (node is BinaryExpression) {
137 _writeProperty('static element', node.staticElement); 138 _writeProperty('static element', node.staticElement);
138 _writeProperty('static type', node.staticType); 139 _writeProperty('static type', node.staticType);
139 _writeProperty('propagated element', node.propagatedElement); 140 _writeProperty('propagated element', node.propagatedElement);
140 _writeProperty('propagated type', node.propagatedType); 141 _writeProperty('propagated type', node.propagatedType);
141 } else if (node is CompilationUnit) { 142 } else if (node is CompilationUnit) {
142 _writeProperty("element", node.element); 143 _writeProperty("element", node.element);
143 } else if (node is ExportDirective) { 144 } else if (node is ExportDirective) {
144 _writeProperty("element", node.element); 145 _writeProperty("element", node.element);
146 _writeProperty("source", node.source);
145 } else if (node is FunctionExpressionInvocation) { 147 } else if (node is FunctionExpressionInvocation) {
146 _writeProperty('static element', node.staticElement); 148 _writeProperty('static element', node.staticElement);
147 _writeProperty('static type', node.staticType); 149 _writeProperty('static type', node.staticType);
148 _writeProperty('propagated element', node.propagatedElement); 150 _writeProperty('propagated element', node.propagatedElement);
149 _writeProperty('propagated type', node.propagatedType); 151 _writeProperty('propagated type', node.propagatedType);
150 } else if (node is ImportDirective) { 152 } else if (node is ImportDirective) {
151 _writeProperty("element", node.element); 153 _writeProperty("element", node.element);
154 _writeProperty("source", node.source);
152 } else if (node is LibraryDirective) { 155 } else if (node is LibraryDirective) {
153 _writeProperty("element", node.element); 156 _writeProperty("element", node.element);
154 } else if (node is PartDirective) { 157 } else if (node is PartDirective) {
155 _writeProperty("element", node.element); 158 _writeProperty("element", node.element);
159 _writeProperty("source", node.source);
156 } else if (node is PartOfDirective) { 160 } else if (node is PartOfDirective) {
157 _writeProperty("element", node.element); 161 _writeProperty("element", node.element);
158 } else if (node is PostfixExpression) { 162 } else if (node is PostfixExpression) {
159 _writeProperty('static element', node.staticElement); 163 _writeProperty('static element', node.staticElement);
160 _writeProperty('static type', node.staticType); 164 _writeProperty('static type', node.staticType);
161 _writeProperty('propagated element', node.propagatedElement); 165 _writeProperty('propagated element', node.propagatedElement);
162 _writeProperty('propagated type', node.propagatedType); 166 _writeProperty('propagated type', node.propagatedType);
163 } else if (node is PrefixExpression) { 167 } else if (node is PrefixExpression) {
164 _writeProperty('static element', node.staticElement); 168 _writeProperty('static element', node.staticElement);
165 _writeProperty('static type', node.staticType); 169 _writeProperty('static type', node.staticType);
(...skipping 12 matching lines...) Expand all
178 } 182 }
179 } 183 }
180 184
181 /** 185 /**
182 * Write the [value] of the property with the given [name]. 186 * Write the [value] of the property with the given [name].
183 */ 187 */
184 void _writeProperty(String name, Object value) { 188 void _writeProperty(String name, Object value) {
185 if (value != null) { 189 if (value != null) {
186 String valueString = null; 190 String valueString = null;
187 try { 191 try {
188 valueString = value.toString(); 192 if (value is Source) {
193 valueString = 'Source (uri="${value.uri}", path="${value.fullName}")';
194 } else {
195 valueString = value.toString();
196 }
189 } catch (exception, stackTrace) { 197 } catch (exception, stackTrace) {
190 exceptions.add(new CaughtException(exception, stackTrace)); 198 exceptions.add(new CaughtException(exception, stackTrace));
191 } 199 }
192 _indent(2); 200 _indent(2);
193 buffer.write('$name = '); 201 buffer.write('$name = ');
194 if (valueString == null) { 202 if (valueString == null) {
195 buffer.write('<span style="color: #FF0000">'); 203 buffer.write('<span style="color: #FF0000">');
196 buffer.write(HTML_ESCAPE.convert(value.runtimeType.toString())); 204 buffer.write(HTML_ESCAPE.convert(value.runtimeType.toString()));
197 buffer.write('</span>'); 205 buffer.write('</span>');
198 } else { 206 } else {
199 buffer.write(HTML_ESCAPE.convert(valueString)); 207 buffer.write(HTML_ESCAPE.convert(valueString));
200 if (value is Element && value is! LibraryElement) { 208 if (value is Element && value is! LibraryElement) {
201 String name = value.name; 209 String name = value.name;
202 if (name != null) { 210 if (name != null) {
203 buffer.write('&nbsp;&nbsp;['); 211 buffer.write('&nbsp;&nbsp;[');
204 buffer.write(GetHandler.makeLink(GetHandler.INDEX_ELEMENT_BY_NAME, { 212 buffer.write(GetHandler.makeLink(GetHandler.INDEX_ELEMENT_BY_NAME, {
205 'name': name 213 'name': name
206 }, 'search index')); 214 }, 'search index'));
207 buffer.write(']'); 215 buffer.write(']');
208 } 216 }
209 } 217 }
210 } 218 }
211 buffer.write('<br>'); 219 buffer.write('<br>');
212 } 220 }
213 } 221 }
214 } 222 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698