| OLD | NEW |
| 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 library analyzer_cli.src.build_mode; | 5 library analyzer_cli.src.build_mode; |
| 6 | 6 |
| 7 import 'dart:core'; | 7 import 'dart:core'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit; | 10 import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 PackageBundle sdkBundle; | 240 PackageBundle sdkBundle; |
| 241 if (options.dartSdkSummaryPath != null) { | 241 if (options.dartSdkSummaryPath != null) { |
| 242 SummaryBasedDartSdk summarySdk = new SummaryBasedDartSdk( | 242 SummaryBasedDartSdk summarySdk = new SummaryBasedDartSdk( |
| 243 options.dartSdkSummaryPath, options.strongMode); | 243 options.dartSdkSummaryPath, options.strongMode); |
| 244 sdk = summarySdk; | 244 sdk = summarySdk; |
| 245 sdkBundle = summarySdk.bundle; | 245 sdkBundle = summarySdk.bundle; |
| 246 } else { | 246 } else { |
| 247 FolderBasedDartSdk dartSdk = new FolderBasedDartSdk(resourceProvider, | 247 FolderBasedDartSdk dartSdk = new FolderBasedDartSdk(resourceProvider, |
| 248 resourceProvider.getFolder(options.dartSdkPath), options.strongMode); | 248 resourceProvider.getFolder(options.dartSdkPath), options.strongMode); |
| 249 dartSdk.analysisOptions = | 249 dartSdk.analysisOptions = |
| 250 Driver.createAnalysisOptionsForCommandLineOptions(options); | 250 Driver.createAnalysisOptionsForCommandLineOptions( |
| 251 resourceProvider, options); |
| 251 dartSdk.useSummary = !options.buildSummaryOnly; | 252 dartSdk.useSummary = !options.buildSummaryOnly; |
| 252 sdk = dartSdk; | 253 sdk = dartSdk; |
| 253 sdkBundle = dartSdk.getSummarySdkBundle(options.strongMode); | 254 sdkBundle = dartSdk.getSummarySdkBundle(options.strongMode); |
| 254 } | 255 } |
| 255 | 256 |
| 256 // Include SDK bundle to avoid parsing SDK sources. | 257 // Include SDK bundle to avoid parsing SDK sources. |
| 257 summaryDataStore.addBundle(null, sdkBundle); | 258 summaryDataStore.addBundle(null, sdkBundle); |
| 258 | 259 |
| 259 // Create the context. | 260 // Create the context. |
| 260 context = AnalysisEngine.instance.createAnalysisContext(); | 261 context = AnalysisEngine.instance.createAnalysisContext(); |
| 261 context.sourceFactory = new SourceFactory(<UriResolver>[ | 262 context.sourceFactory = new SourceFactory(<UriResolver>[ |
| 262 new DartUriResolver(sdk), | 263 new DartUriResolver(sdk), |
| 263 new InSummaryUriResolver(resourceProvider, summaryDataStore), | 264 new InSummaryUriResolver(resourceProvider, summaryDataStore), |
| 264 new ExplicitSourceResolver(uriToFileMap) | 265 new ExplicitSourceResolver(uriToFileMap) |
| 265 ]); | 266 ]); |
| 266 | 267 |
| 267 // Set context options. | 268 // Set context options. |
| 268 Driver.setAnalysisContextOptions( | 269 Driver.setAnalysisContextOptions(resourceProvider, context, options, |
| 269 resourceProvider, context.sourceFactory, context, options, | |
| 270 (AnalysisOptionsImpl contextOptions) { | 270 (AnalysisOptionsImpl contextOptions) { |
| 271 if (options.buildSummaryOnlyDiet) { | 271 if (options.buildSummaryOnlyDiet) { |
| 272 contextOptions.analyzeFunctionBodies = false; | 272 contextOptions.analyzeFunctionBodies = false; |
| 273 } | 273 } |
| 274 }); | 274 }); |
| 275 | 275 |
| 276 if (!options.buildSummaryOnly) { | 276 if (!options.buildSummaryOnly) { |
| 277 // Configure using summaries. | 277 // Configure using summaries. |
| 278 context.typeProvider = sdk.context.typeProvider; | 278 context.typeProvider = sdk.context.typeProvider; |
| 279 context.resultProvider = | 279 context.resultProvider = |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 * Build the inverse mapping of [uriToSourceMap]. | 411 * Build the inverse mapping of [uriToSourceMap]. |
| 412 */ | 412 */ |
| 413 static Map<String, Uri> _computePathToUriMap(Map<Uri, File> uriToSourceMap) { | 413 static Map<String, Uri> _computePathToUriMap(Map<Uri, File> uriToSourceMap) { |
| 414 Map<String, Uri> pathToUriMap = <String, Uri>{}; | 414 Map<String, Uri> pathToUriMap = <String, Uri>{}; |
| 415 uriToSourceMap.forEach((Uri uri, File file) { | 415 uriToSourceMap.forEach((Uri uri, File file) { |
| 416 pathToUriMap[file.path] = uri; | 416 pathToUriMap[file.path] = uri; |
| 417 }); | 417 }); |
| 418 return pathToUriMap; | 418 return pathToUriMap; |
| 419 } | 419 } |
| 420 } | 420 } |
| OLD | NEW |