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

Side by Side Diff: pkg/analyzer_experimental/example/resolver_driver.dart

Issue 12803014: New Analysis Engine translation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
OLDNEW
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 14 matching lines...) Expand all
25 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]); 25 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]);
26 DartSdk sdk = DartSdk.defaultSdk; 26 DartSdk sdk = DartSdk.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.con2([new DartUriResolver(sdk), new FileUriResolver()]);
30 Source source = new FileBasedSource.con1(context.sourceFactory, new JavaFile(a rgs[1])); 30 Source source = new FileBasedSource.con1(context.sourceFactory, new JavaFile(a rgs[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.getLibraryElement(source); 35 LibraryElement libElement = context.computeLibraryElement(source);
36 print("libElement: $libElement"); 36 print("libElement: $libElement");
37 37
38 CompilationUnit resolvedUnit = context.resolve(source, libElement); 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.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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698