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

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

Issue 2060263006: Deprecate FileUriResolver and RelativeFileUriResolver in source_io.dart, replace the usages with Re… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/java_io.dart'; 12 import 'package:analyzer/src/generated/java_io.dart';
13 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 13 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
14 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; 14 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
15 import 'package:analyzer/src/generated/source.dart'; 15 import 'package:analyzer/src/generated/source.dart';
16 import 'package:analyzer/src/generated/source_io.dart'; 16 import 'package:analyzer/src/generated/source_io.dart';
17 import 'package:analyzer/file_system/file_system.dart' hide File;
18 import 'package:analyzer/file_system/physical_file_system.dart';
17 19
18 void main(List<String> args) { 20 void main(List<String> args) {
19 print('working dir ${new File('.').resolveSymbolicLinksSync()}'); 21 print('working dir ${new File('.').resolveSymbolicLinksSync()}');
20 22
21 if (args.length < 2 || args.length > 3) { 23 if (args.length < 2 || args.length > 3) {
22 print(_usage); 24 print(_usage);
23 exit(0); 25 exit(0);
24 } 26 }
25 27
26 String packageRoot; 28 String packageRoot;
27 if (args.length == 3) { 29 if (args.length == 3) {
28 packageRoot = args[2]; 30 packageRoot = args[2];
29 } 31 }
30 32
31 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]); 33 JavaSystemIO.setProperty("com.google.dart.sdk", args[0]);
32 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk; 34 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk;
33 35
34 var resolvers = [new DartUriResolver(sdk), new FileUriResolver()]; 36 var resolvers = [
37 new DartUriResolver(sdk),
38 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)
39 ];
35 40
36 if (packageRoot != null) { 41 if (packageRoot != null) {
37 var packageDirectory = new JavaFile(packageRoot); 42 var packageDirectory = new JavaFile(packageRoot);
38 resolvers.add(new PackageUriResolver([packageDirectory])); 43 resolvers.add(new PackageUriResolver([packageDirectory]));
39 } 44 }
40 45
41 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() 46 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext()
42 ..sourceFactory = new SourceFactory(resolvers); 47 ..sourceFactory = new SourceFactory(resolvers);
43 48
44 Source source = new FileBasedSource(new JavaFile(args[1])); 49 Source source = new FileBasedSource(new JavaFile(args[1]));
(...skipping 24 matching lines...) Expand all
69 var fullName = 74 var fullName =
70 element.library.definingCompilationUnit.source.fullName; 75 element.library.definingCompilationUnit.source.fullName;
71 lines.add(" from $fullName"); 76 lines.add(" from $fullName");
72 } 77 }
73 } 78 }
74 } 79 }
75 print(lines.join('\n')); 80 print(lines.join('\n'));
76 return super.visitNode(node); 81 return super.visitNode(node);
77 } 82 }
78 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698