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

Side by Side Diff: pkg/dev_compiler/lib/src/analyzer/context.dart

Issue 2371113004: Use .packages instead of pubspec.yaml (Closed)
Patch Set: Mark clang as passing Created 4 years, 2 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
« no previous file with comments | « .travis.yml ('k') | pkg/dev_compiler/lib/src/compiler/js_typeref_codegen.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 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:args/args.dart' show ArgParser, ArgResults; 5 import 'package:args/args.dart' show ArgParser, ArgResults;
6 import 'package:analyzer/file_system/file_system.dart' 6 import 'package:analyzer/file_system/file_system.dart'
7 show ResourceProvider, ResourceUriResolver; 7 show ResourceProvider, ResourceUriResolver;
8 import 'package:analyzer/file_system/physical_file_system.dart' 8 import 'package:analyzer/file_system/physical_file_system.dart'
9 show PhysicalResourceProvider; 9 show PhysicalResourceProvider;
10 import 'package:analyzer/source/custom_resolver.dart'; 10 import 'package:analyzer/source/custom_resolver.dart';
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 /// Path to the dart-sdk summary. If this is set, it will be used in favor 45 /// Path to the dart-sdk summary. If this is set, it will be used in favor
46 /// of the unsummarized one. 46 /// of the unsummarized one.
47 final String dartSdkSummaryPath; 47 final String dartSdkSummaryPath;
48 48
49 AnalyzerOptions( 49 AnalyzerOptions(
50 {this.summaryPaths: const [], 50 {this.summaryPaths: const [],
51 String dartSdkPath, 51 String dartSdkPath,
52 this.dartSdkSummaryPath, 52 this.dartSdkSummaryPath,
53 this.customUrlMappings: const {}, 53 this.customUrlMappings: const {},
54 this.packageRoot: 'packages/',
55 this.packagePaths: const []}) 54 this.packagePaths: const []})
56 : dartSdkPath = dartSdkPath ?? getSdkDir().path; 55 : dartSdkPath = dartSdkPath ?? getSdkDir().path;
57 56
58 AnalyzerOptions.fromArguments(ArgResults args) 57 AnalyzerOptions.fromArguments(ArgResults args)
59 : summaryPaths = args['summary'] as List<String>, 58 : summaryPaths = args['summary'] as List<String>,
60 dartSdkPath = args['dart-sdk'] ?? getSdkDir().path, 59 dartSdkPath = args['dart-sdk'] ?? getSdkDir().path,
61 dartSdkSummaryPath = args['dart-sdk-summary'], 60 dartSdkSummaryPath = args['dart-sdk-summary'],
62 customUrlMappings = _parseUrlMappings(args['url-mapping']), 61 customUrlMappings = _parseUrlMappings(args['url-mapping']),
63 packageRoot = args['package-root'], 62 packageRoot = args['package-root'],
64 packagePaths = (args['package-paths'] as String)?.split(',') ?? []; 63 packagePaths = (args['package-paths'] as String)?.split(',') ?? [];
65 64
66 /// Whether to resolve 'package:' uris using the multi-package resolver. 65 /// Whether to resolve 'package:' uris using the multi-package resolver.
67 bool get useMultiPackage => packagePaths.isNotEmpty; 66 bool get useMultiPackage => packagePaths.isNotEmpty;
68 67
69 static void addArguments(ArgParser parser) { 68 static void addArguments(ArgParser parser) {
70 parser 69 parser
71 ..addOption('summary', 70 ..addOption('summary',
72 abbr: 's', help: 'summary file(s) to include', allowMultiple: true) 71 abbr: 's', help: 'summary file(s) to include', allowMultiple: true)
73 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null) 72 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null)
74 ..addOption('dart-sdk-summary', 73 ..addOption('dart-sdk-summary',
75 help: 'Dart SDK Summary Path', defaultsTo: null) 74 help: 'Dart SDK Summary Path', defaultsTo: null)
76 ..addOption('package-root', 75 ..addOption('package-root',
77 abbr: 'p', 76 abbr: 'p', help: 'Package root to resolve "package:" imports')
78 help: 'Package root to resolve "package:" imports',
79 defaultsTo: 'packages/')
80 ..addOption('url-mapping', 77 ..addOption('url-mapping',
81 help: '--url-mapping=libraryUri,/path/to/library.dart uses\n' 78 help: '--url-mapping=libraryUri,/path/to/library.dart uses\n'
82 'library.dart as the source for an import of of "libraryUri".', 79 'library.dart as the source for an import of of "libraryUri".',
83 allowMultiple: true, 80 allowMultiple: true,
84 splitCommas: false) 81 splitCommas: false)
85 ..addOption('package-paths', 82 ..addOption('package-paths',
86 help: 'use a list of directories to resolve "package:" imports'); 83 help: 'use a list of directories to resolve "package:" imports');
87 } 84 }
88 85
89 static Map<String, String> _parseUrlMappings(Iterable argument) { 86 static Map<String, String> _parseUrlMappings(Iterable argument) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 createFileResolvers(options, resourceProvider: resourceProvider); 132 createFileResolvers(options, resourceProvider: resourceProvider);
136 resolvers.addAll(fileResolvers); 133 resolvers.addAll(fileResolvers);
137 return new SourceFactory(resolvers, null, resourceProvider); 134 return new SourceFactory(resolvers, null, resourceProvider);
138 } 135 }
139 136
140 List<UriResolver> createFileResolvers(AnalyzerOptions options, 137 List<UriResolver> createFileResolvers(AnalyzerOptions options,
141 {ResourceProvider resourceProvider}) { 138 {ResourceProvider resourceProvider}) {
142 resourceProvider ??= PhysicalResourceProvider.INSTANCE; 139 resourceProvider ??= PhysicalResourceProvider.INSTANCE;
143 UriResolver packageResolver() { 140 UriResolver packageResolver() {
144 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null); 141 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null);
145 builder.defaultPackagesDirectoryPath = options.packageRoot; 142 if (options.packageRoot != null) {
143 builder.defaultPackagesDirectoryPath = options.packageRoot;
144 }
146 return new PackageMapUriResolver(resourceProvider, 145 return new PackageMapUriResolver(resourceProvider,
147 builder.convertPackagesToMap(builder.createPackageMap(''))); 146 builder.convertPackagesToMap(builder.createPackageMap('')));
148 } 147 }
149 148
150 return [ 149 return [
151 new ResourceUriResolver(resourceProvider), 150 new ResourceUriResolver(resourceProvider),
152 options.useMultiPackage 151 options.useMultiPackage
153 ? new MultiPackageResolver(options.packagePaths) 152 ? new MultiPackageResolver(options.packagePaths)
154 : packageResolver() 153 : packageResolver()
155 ]; 154 ];
156 } 155 }
157 156
158 FolderBasedDartSdk _createFolderBasedDartSdk(String sdkPath) { 157 FolderBasedDartSdk _createFolderBasedDartSdk(String sdkPath) {
159 var resourceProvider = PhysicalResourceProvider.INSTANCE; 158 var resourceProvider = PhysicalResourceProvider.INSTANCE;
160 var sdk = new FolderBasedDartSdk(resourceProvider, 159 var sdk = new FolderBasedDartSdk(resourceProvider,
161 resourceProvider.getFolder(sdkPath), /*useDart2jsPaths:*/ true); 160 resourceProvider.getFolder(sdkPath), /*useDart2jsPaths:*/ true);
162 sdk.useSummary = true; 161 sdk.useSummary = true;
163 sdk.analysisOptions = new AnalysisOptionsImpl()..strongMode = true; 162 sdk.analysisOptions = new AnalysisOptionsImpl()..strongMode = true;
164 return sdk; 163 return sdk;
165 } 164 }
166 165
167 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. 166 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath].
168 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) { 167 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) {
169 var sdk = (sdkSummaryPath != null) 168 var sdk = (sdkSummaryPath != null)
170 ? new SummaryBasedDartSdk(sdkSummaryPath, true) 169 ? new SummaryBasedDartSdk(sdkSummaryPath, true)
171 : _createFolderBasedDartSdk(sdkPath); 170 : _createFolderBasedDartSdk(sdkPath);
172 return new DartUriResolver(sdk); 171 return new DartUriResolver(sdk);
173 } 172 }
OLDNEW
« no previous file with comments | « .travis.yml ('k') | pkg/dev_compiler/lib/src/compiler/js_typeref_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698