| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 | 2 |
| 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
| 5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 import 'package:analyzer_experimental/src/generated/java_io.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_io.dart'; |
| 8 import 'package:analyzer_experimental/src/generated/source_io.dart'; | 8 import 'package:analyzer_experimental/src/generated/source_io.dart'; |
| 9 import 'package:analyzer_experimental/src/generated/ast.dart'; | 9 import 'package:analyzer_experimental/src/generated/ast.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/sdk.dart'; | 10 import 'package:analyzer_experimental/src/generated/sdk.dart'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 CompilationUnit resolvedUnit = context.resolveCompilationUnit(source, libEleme
nt); | 38 CompilationUnit resolvedUnit = context.resolveCompilationUnit(source, libEleme
nt); |
| 39 var visitor = new _ASTVisitor(); | 39 var visitor = new _ASTVisitor(); |
| 40 resolvedUnit.accept(visitor); | 40 resolvedUnit.accept(visitor); |
| 41 } | 41 } |
| 42 | 42 |
| 43 class _ASTVisitor extends GeneralizingASTVisitor { | 43 class _ASTVisitor extends GeneralizingASTVisitor { |
| 44 visitNode(ASTNode node) { | 44 visitNode(ASTNode node) { |
| 45 String text = '${node.runtimeType} : <"${node.toString()}">'; | 45 String text = '${node.runtimeType} : <"${node.toString()}">'; |
| 46 if (node is SimpleIdentifier) { | 46 if (node is SimpleIdentifier) { |
| 47 Element element = node.element; | 47 Element element = (node as SimpleIdentifier).element; |
| 48 if (element != null) { | 48 if (element != null) { |
| 49 text += " element: ${element.runtimeType}"; | 49 text += " element: ${element.runtimeType}"; |
| 50 LibraryElement library = element.library; | 50 LibraryElement library = element.library; |
| 51 if (library != null) { | 51 if (library != null) { |
| 52 text += " from ${element.library.definingCompilationUnit.source.fullNa
me}"; | 52 text += " from ${element.library.definingCompilationUnit.source.fullNa
me}"; |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 print(text); | 56 print(text); |
| 57 return super.visitNode(node); | 57 return super.visitNode(node); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| OLD | NEW |