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

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

Issue 725143004: Format and sort analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « pkg/analyzer/example/parser_driver.dart ('k') | pkg/analyzer/example/scanner_driver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2
3 // 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
4 // 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
5 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
6 5
6 import 'dart:io';
7
8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/engine.dart';
7 import 'package:analyzer/src/generated/java_io.dart'; 11 import 'package:analyzer/src/generated/java_io.dart';
8 import 'package:analyzer/src/generated/source_io.dart';
9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 12 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
11 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; 13 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
12 import 'package:analyzer/src/generated/element.dart'; 14 import 'package:analyzer/src/generated/source_io.dart';
13 import 'package:analyzer/src/generated/engine.dart';
14
15 import 'dart:io';
16 15
17 main(List<String> args) { 16 main(List<String> args) {
18 print('working dir ${new File('.').resolveSymbolicLinksSync()}'); 17 print('working dir ${new File('.').resolveSymbolicLinksSync()}');
19 18
20 if (args.length != 2) { 19 if (args.length != 2) {
21 print('Usage: resolve_driver [path_to_sdk] [file_to_resolve]'); 20 print('Usage: resolve_driver [path_to_sdk] [file_to_resolve]');
22 exit(0); 21 exit(0);
23 } 22 }
24 23
25 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]); 24 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]);
26 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk; 25 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk;
27 26
28 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); 27 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
29 context.sourceFactory = new SourceFactory([new DartUriResolver(sdk), new FileU riResolver()]); 28 context.sourceFactory =
29 new SourceFactory([new DartUriResolver(sdk), new FileUriResolver()]);
30 Source source = new FileBasedSource.con1(new 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.addedSource(source); 33 changeSet.addedSource(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 =
39 context.resolveCompilationUnit(source, libElement);
39 var visitor = new _ASTVisitor(); 40 var visitor = new _ASTVisitor();
40 resolvedUnit.accept(visitor); 41 resolvedUnit.accept(visitor);
41 } 42 }
42 43
43 class _ASTVisitor extends GeneralizingAstVisitor { 44 class _ASTVisitor extends GeneralizingAstVisitor {
44 visitNode(AstNode node) { 45 visitNode(AstNode node) {
45 String text = '${node.runtimeType} : <"$node">'; 46 String text = '${node.runtimeType} : <"$node">';
46 if (node is SimpleIdentifier) { 47 if (node is SimpleIdentifier) {
47 Element element = node.staticElement; 48 Element element = node.staticElement;
48 if (element != null) { 49 if (element != null) {
49 text += " element: ${element.runtimeType}"; 50 text += " element: ${element.runtimeType}";
50 LibraryElement library = element.library; 51 LibraryElement library = element.library;
51 if (library != null) { 52 if (library != null) {
52 text += " from ${element.library.definingCompilationUnit.source.fullNa me}"; 53 text +=
54 " from ${element.library.definingCompilationUnit.source.fullName}" ;
53 } 55 }
54 } 56 }
55 } 57 }
56 print(text); 58 print(text);
57 return super.visitNode(node); 59 return super.visitNode(node);
58 } 60 }
59 } 61 }
60
OLDNEW
« no previous file with comments | « pkg/analyzer/example/parser_driver.dart ('k') | pkg/analyzer/example/scanner_driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698