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

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

Issue 2320733003: Remove final references to PackageUriResolver (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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';
11 import 'package:analyzer/file_system/file_system.dart' hide File; 11 import 'package:analyzer/file_system/file_system.dart' hide File;
12 import 'package:analyzer/file_system/physical_file_system.dart'; 12 import 'package:analyzer/file_system/physical_file_system.dart';
13 import 'package:analyzer/source/package_map_resolver.dart';
14 import 'package:analyzer/src/context/builder.dart';
13 import 'package:analyzer/src/dart/sdk/sdk.dart'; 15 import 'package:analyzer/src/dart/sdk/sdk.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 16 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/java_io.dart';
16 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 17 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
17 import 'package:analyzer/src/generated/source.dart'; 18 import 'package:analyzer/src/generated/source.dart';
18 import 'package:analyzer/src/generated/source_io.dart'; 19 import 'package:analyzer/src/generated/source_io.dart';
19 import 'package:analyzer/src/source/source_resource.dart'; 20 import 'package:analyzer/src/source/source_resource.dart';
20 21
21 void main(List<String> args) { 22 void main(List<String> args) {
22 print('working dir ${new File('.').resolveSymbolicLinksSync()}'); 23 print('working dir ${new File('.').resolveSymbolicLinksSync()}');
23 24
24 if (args.length < 2 || args.length > 3) { 25 if (args.length < 2 || args.length > 3) {
25 print(_usage); 26 print(_usage);
26 exit(0); 27 exit(0);
27 } 28 }
28 29
29 String packageRoot; 30 String packageRoot;
30 if (args.length == 3) { 31 if (args.length == 3) {
31 packageRoot = args[2]; 32 packageRoot = args[2];
32 } 33 }
33 34
34 PhysicalResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE; 35 PhysicalResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
35 DartSdk sdk = new FolderBasedDartSdk( 36 DartSdk sdk = new FolderBasedDartSdk(
36 resourceProvider, resourceProvider.getFolder(args[0])); 37 resourceProvider, resourceProvider.getFolder(args[0]));
37 38
38 var resolvers = [ 39 var resolvers = [
39 new DartUriResolver(sdk), 40 new DartUriResolver(sdk),
40 new ResourceUriResolver(resourceProvider) 41 new ResourceUriResolver(resourceProvider)
41 ]; 42 ];
42 43
43 if (packageRoot != null) { 44 if (packageRoot != null) {
44 var packageDirectory = new JavaFile(packageRoot); 45 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null);
45 resolvers.add(new PackageUriResolver([packageDirectory])); 46 resolvers.add(new PackageMapUriResolver(resourceProvider,
47 builder.convertPackagesToMap(builder.createPackageMap(packageRoot))));
scheglov 2016/09/07 19:11:39 We repeat this code in several clients. Should we
Brian Wilkerson 2016/09/07 20:03:03 Eventually clients should be able to use an even h
46 } 48 }
47 49
48 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() 50 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext()
49 ..sourceFactory = new SourceFactory(resolvers); 51 ..sourceFactory = new SourceFactory(resolvers);
50 52
51 Source source = new FileSource(resourceProvider.getFile(args[1])); 53 Source source = new FileSource(resourceProvider.getFile(args[1]));
52 ChangeSet changeSet = new ChangeSet()..addedSource(source); 54 ChangeSet changeSet = new ChangeSet()..addedSource(source);
53 context.applyChanges(changeSet); 55 context.applyChanges(changeSet);
54 LibraryElement libElement = context.computeLibraryElement(source); 56 LibraryElement libElement = context.computeLibraryElement(source);
55 print("libElement: $libElement"); 57 print("libElement: $libElement");
(...skipping 20 matching lines...) Expand all
76 var fullName = 78 var fullName =
77 element.library.definingCompilationUnit.source.fullName; 79 element.library.definingCompilationUnit.source.fullName;
78 lines.add(" from $fullName"); 80 lines.add(" from $fullName");
79 } 81 }
80 } 82 }
81 } 83 }
82 print(lines.join('\n')); 84 print(lines.join('\n'));
83 return super.visitNode(node); 85 return super.visitNode(node);
84 } 86 }
85 } 87 }
OLDNEW
« no previous file with comments | « pkg/analyzer/benchmark/errors_in_all_libraries.dart ('k') | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698