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

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

Issue 2338883002: Update uses of deprecated API in ddc (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 // 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
3 // 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
4 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
5 4
6 import 'package:args/args.dart' show ArgParser, ArgResults; 5 import 'package:args/args.dart' show ArgParser, ArgResults;
7 import 'package:analyzer/file_system/file_system.dart' 6 import 'package:analyzer/file_system/file_system.dart'
8 show ResourceProvider, ResourceUriResolver; 7 show ResourceProvider, ResourceUriResolver;
9 import 'package:analyzer/file_system/physical_file_system.dart' 8 import 'package:analyzer/file_system/physical_file_system.dart'
10 show PhysicalResourceProvider; 9 show PhysicalResourceProvider;
10 import 'package:analyzer/source/custom_resolver.dart';
11 import 'package:analyzer/source/package_map_resolver.dart';
12 import 'package:analyzer/src/context/builder.dart';
11 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; 13 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl;
12 import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk; 14 import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk;
13 import 'package:analyzer/src/generated/engine.dart' 15 import 'package:analyzer/src/generated/engine.dart'
14 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl; 16 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl;
15 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; 17 import 'package:analyzer/src/generated/source.dart'
16 import 'package:analyzer/src/generated/source.dart'; 18 show DartUriResolver, SourceFactory, UriResolver;
17 import 'package:analyzer/src/generated/source_io.dart'
18 show
19 CustomUriResolver,
20 DartUriResolver,
21 PackageUriResolver,
22 SourceFactory,
23 UriResolver;
24 import 'package:analyzer/src/summary/package_bundle_reader.dart' 19 import 'package:analyzer/src/summary/package_bundle_reader.dart'
25 show InSummaryUriResolver, InputPackagesResultProvider, SummaryDataStore; 20 show InSummaryUriResolver, InputPackagesResultProvider, SummaryDataStore;
26 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; 21 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
27 import 'package:cli_util/cli_util.dart' show getSdkDir; 22 import 'package:cli_util/cli_util.dart' show getSdkDir;
28 import 'package:path/path.dart' as path; 23 import 'package:path/path.dart' as path;
29 24
30 import 'multi_package_resolver.dart' show MultiPackageResolver; 25 import 'multi_package_resolver.dart' show MultiPackageResolver;
31 26
32 /// Options used to set up Source URI resolution in the analysis context. 27 /// Options used to set up Source URI resolution in the analysis context.
33 class AnalyzerOptions { 28 class AnalyzerOptions {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 /// Use [options.useMockSdk] to specify the SDK mode, or use [sdkResolver] 145 /// Use [options.useMockSdk] to specify the SDK mode, or use [sdkResolver]
151 /// to entirely override the DartUriResolver. 146 /// to entirely override the DartUriResolver.
152 /// 147 ///
153 /// If supplied, [fileResolvers] will override the default `file:` and 148 /// If supplied, [fileResolvers] will override the default `file:` and
154 /// `package:` URI resolvers. 149 /// `package:` URI resolvers.
155 SourceFactory _createSourceFactory(AnalyzerOptions options, 150 SourceFactory _createSourceFactory(AnalyzerOptions options,
156 {DartUriResolver sdkResolver, 151 {DartUriResolver sdkResolver,
157 List<UriResolver> fileResolvers, 152 List<UriResolver> fileResolvers,
158 SummaryDataStore summaryData, 153 SummaryDataStore summaryData,
159 ResourceProvider resourceProvider}) { 154 ResourceProvider resourceProvider}) {
155 resourceProvider ??= PhysicalResourceProvider.INSTANCE;
160 var resolvers = <UriResolver>[]; 156 var resolvers = <UriResolver>[];
161 if (options.customUrlMappings.isNotEmpty) { 157 if (options.customUrlMappings.isNotEmpty) {
162 resolvers.add(new CustomUriResolver(options.customUrlMappings)); 158 resolvers.add(
159 new CustomUriResolver(resourceProvider, options.customUrlMappings));
163 } 160 }
164 resolvers.add(sdkResolver); 161 resolvers.add(sdkResolver);
165 if (summaryData != null) { 162 if (summaryData != null) {
166 resolvers.add(new InSummaryUriResolver(resourceProvider, summaryData)); 163 resolvers.add(new InSummaryUriResolver(resourceProvider, summaryData));
167 } 164 }
168 165
169 if (fileResolvers == null) fileResolvers = createFileResolvers(options); 166 if (fileResolvers == null)
167 fileResolvers =
168 createFileResolvers(options, resourceProvider: resourceProvider);
170 resolvers.addAll(fileResolvers); 169 resolvers.addAll(fileResolvers);
171 return new SourceFactory(resolvers, null, resourceProvider); 170 return new SourceFactory(resolvers, null, resourceProvider);
172 } 171 }
173 172
174 List<UriResolver> createFileResolvers(AnalyzerOptions options) { 173 List<UriResolver> createFileResolvers(AnalyzerOptions options,
174 {ResourceProvider resourceProvider}) {
175 resourceProvider ??= PhysicalResourceProvider.INSTANCE;
176 UriResolver packageResolver() {
177 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null);
178 builder.defaultPackagesDirectoryPath = options.packageRoot;
179 return new PackageMapUriResolver(resourceProvider,
180 builder.convertPackagesToMap(builder.createPackageMap('')));
181 }
182
175 return [ 183 return [
176 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE), 184 new ResourceUriResolver(resourceProvider),
177 options.useMultiPackage 185 options.useMultiPackage
178 ? new MultiPackageResolver(options.packagePaths) 186 ? new MultiPackageResolver(options.packagePaths)
179 : new PackageUriResolver([new JavaFile(options.packageRoot)]) 187 : packageResolver()
180 ]; 188 ];
181 } 189 }
182 190
183 FolderBasedDartSdk _createFolderBasedDartSdk(String sdkPath) { 191 FolderBasedDartSdk _createFolderBasedDartSdk(String sdkPath) {
184 var resourceProvider = PhysicalResourceProvider.INSTANCE; 192 var resourceProvider = PhysicalResourceProvider.INSTANCE;
185 var sdk = new FolderBasedDartSdk(resourceProvider, 193 var sdk = new FolderBasedDartSdk(resourceProvider,
186 resourceProvider.getFolder(sdkPath), /*useDart2jsPaths:*/ true); 194 resourceProvider.getFolder(sdkPath), /*useDart2jsPaths:*/ true);
187 sdk.useSummary = true; 195 sdk.useSummary = true;
188 sdk.analysisOptions = new AnalysisOptionsImpl()..strongMode = true; 196 sdk.analysisOptions = new AnalysisOptionsImpl()..strongMode = true;
189 return sdk; 197 return sdk;
190 } 198 }
191 199
192 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. 200 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath].
193 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) { 201 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) {
194 var sdk = (sdkSummaryPath != null) 202 var sdk = (sdkSummaryPath != null)
195 ? new SummaryBasedDartSdk(sdkSummaryPath, true) 203 ? new SummaryBasedDartSdk(sdkSummaryPath, true)
196 : _createFolderBasedDartSdk(sdkPath); 204 : _createFolderBasedDartSdk(sdkPath);
197 return new DartUriResolver(sdk); 205 return new DartUriResolver(sdk);
198 } 206 }
OLDNEW
« pkg/analyzer/lib/source/custom_resolver.dart ('K') | « pkg/analyzer/lib/source/custom_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698