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/src/generated/java_io.dart'; | 7 import 'package:analyzer/src/generated/java_io.dart'; |
8 import 'package:analyzer/src/generated/source_io.dart'; | 8 import 'package:analyzer/src/generated/source_io.dart'; |
9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 10 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
11 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; | 11 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; |
12 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
13 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
14 | 14 |
15 import 'dart:io'; | 15 import 'dart:io'; |
16 | 16 |
17 main(List<String> args) { | 17 main(List<String> args) { |
18 print('working dir ${new File('.').resolveSymbolicLinksSync()}'); | 18 print('working dir ${new File('.').resolveSymbolicLinksSync()}'); |
19 | 19 |
20 if (args.length != 2) { | 20 if (args.length != 2) { |
21 print('Usage: resolve_driver [path_to_sdk] [file_to_resolve]'); | 21 print('Usage: resolve_driver [path_to_sdk] [file_to_resolve]'); |
22 exit(0); | 22 exit(0); |
23 } | 23 } |
24 | 24 |
25 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]); | 25 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]); |
26 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk; | 26 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk; |
27 | 27 |
28 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); | 28 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); |
29 context.sourceFactory = new SourceFactory.con2([new DartUriResolver(sdk), new
FileUriResolver()]); | 29 context.sourceFactory = new SourceFactory([new DartUriResolver(sdk), new FileU
riResolver()]); |
30 Source source = new FileBasedSource.con1(context.sourceFactory.contentCache, n
ew JavaFile(args[1])); | 30 Source source = new FileBasedSource.con1(new JavaFile(args[1])); |
31 // | 31 // |
32 ChangeSet changeSet = new ChangeSet(); | 32 ChangeSet changeSet = new ChangeSet(); |
33 changeSet.added(source); | 33 changeSet.added(source); |
34 context.applyChanges(changeSet); | 34 context.applyChanges(changeSet); |
35 LibraryElement libElement = context.computeLibraryElement(source); | 35 LibraryElement libElement = context.computeLibraryElement(source); |
36 print("libElement: $libElement"); | 36 print("libElement: $libElement"); |
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); |
(...skipping 10 matching lines...) Expand all Loading... |
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 |