| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 CompilationUnit resolvedUnit = | 50 CompilationUnit resolvedUnit = |
| 51 context.resolveCompilationUnit(source, libElement); | 51 context.resolveCompilationUnit(source, libElement); |
| 52 var visitor = new _ASTVisitor(); | 52 var visitor = new _ASTVisitor(); |
| 53 resolvedUnit.accept(visitor); | 53 resolvedUnit.accept(visitor); |
| 54 } | 54 } |
| 55 | 55 |
| 56 const _usage = | 56 const _usage = |
| 57 'Usage: resolve_driver <path_to_sdk> <file_to_resolve> [<packages_root>]'; | 57 'Usage: resolve_driver <path_to_sdk> <file_to_resolve> [<packages_root>]'; |
| 58 | 58 |
| 59 class _ASTVisitor extends GeneralizingAstVisitor { | 59 class _ASTVisitor extends GeneralizingAstVisitor { |
| 60 @override |
| 60 visitNode(AstNode node) { | 61 visitNode(AstNode node) { |
| 61 var lines = <String>['${node.runtimeType} : <"$node">']; | 62 var lines = <String>['${node.runtimeType} : <"$node">']; |
| 62 if (node is SimpleIdentifier) { | 63 if (node is SimpleIdentifier) { |
| 63 Element element = node.staticElement; | 64 Element element = node.staticElement; |
| 64 if (element != null) { | 65 if (element != null) { |
| 65 lines.add(' element: ${element.runtimeType}'); | 66 lines.add(' element: ${element.runtimeType}'); |
| 66 LibraryElement library = element.library; | 67 LibraryElement library = element.library; |
| 67 if (library != null) { | 68 if (library != null) { |
| 68 var fullName = | 69 var fullName = |
| 69 element.library.definingCompilationUnit.source.fullName; | 70 element.library.definingCompilationUnit.source.fullName; |
| 70 lines.add(" from $fullName"); | 71 lines.add(" from $fullName"); |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 print(lines.join('\n')); | 75 print(lines.join('\n')); |
| 75 return super.visitNode(node); | 76 return super.visitNode(node); |
| 76 } | 77 } |
| 77 } | 78 } |
| OLD | NEW |