| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.src.context.context_builder; | 5 library analyzer.src.context.context_builder; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:core' hide Resource; | 8 import 'dart:core' hide Resource; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| 11 import 'package:analyzer/context/declared_variables.dart'; | 11 import 'package:analyzer/context/declared_variables.dart'; |
| 12 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
| 13 import 'package:analyzer/plugin/resolver_provider.dart'; | 13 import 'package:analyzer/plugin/resolver_provider.dart'; |
| 14 import 'package:analyzer/source/analysis_options_provider.dart'; | 14 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 15 import 'package:analyzer/source/package_map_resolver.dart'; | 15 import 'package:analyzer/source/package_map_resolver.dart'; |
| 16 import 'package:analyzer/source/sdk_ext.dart'; | 16 import 'package:analyzer/source/sdk_ext.dart'; |
| 17 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 17 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 18 import 'package:analyzer/src/generated/engine.dart'; | 18 import 'package:analyzer/src/generated/engine.dart'; |
| 19 import 'package:analyzer/src/generated/java_io.dart'; | |
| 20 import 'package:analyzer/src/generated/sdk.dart'; | 19 import 'package:analyzer/src/generated/sdk.dart'; |
| 21 import 'package:analyzer/src/generated/sdk_io.dart'; | |
| 22 import 'package:analyzer/src/generated/source.dart'; | 20 import 'package:analyzer/src/generated/source.dart'; |
| 23 import 'package:analyzer/src/generated/source_io.dart'; | |
| 24 import 'package:analyzer/src/task/options.dart'; | 21 import 'package:analyzer/src/task/options.dart'; |
| 25 import 'package:package_config/discovery.dart'; | 22 import 'package:package_config/discovery.dart'; |
| 26 import 'package:package_config/packages.dart'; | 23 import 'package:package_config/packages.dart'; |
| 27 import 'package:package_config/packages_file.dart'; | 24 import 'package:package_config/packages_file.dart'; |
| 28 import 'package:package_config/src/packages_impl.dart'; | 25 import 'package:package_config/src/packages_impl.dart'; |
| 29 import 'package:yaml/yaml.dart'; | 26 import 'package:yaml/yaml.dart'; |
| 30 | 27 |
| 31 /** | 28 /** |
| 32 * A utility class used to build an analysis context for a given directory. | 29 * A utility class used to build an analysis context for a given directory. |
| 33 * | 30 * |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return dartSdk; | 288 return dartSdk; |
| 292 } else if (extFilePaths != null && extFilePaths.isNotEmpty) { | 289 } else if (extFilePaths != null && extFilePaths.isNotEmpty) { |
| 293 // | 290 // |
| 294 // We have an extension file, but no embedder file. | 291 // We have an extension file, but no embedder file. |
| 295 // | 292 // |
| 296 String sdkPath = sdkManager.defaultSdkDirectory; | 293 String sdkPath = sdkManager.defaultSdkDirectory; |
| 297 List<String> paths = <String>[sdkPath]; | 294 List<String> paths = <String>[sdkPath]; |
| 298 paths.addAll(extFilePaths); | 295 paths.addAll(extFilePaths); |
| 299 SdkDescription description = new SdkDescription(paths, options); | 296 SdkDescription description = new SdkDescription(paths, options); |
| 300 return sdkManager.getSdk(description, () { | 297 return sdkManager.getSdk(description, () { |
| 301 DirectoryBasedDartSdk sdk = | 298 FolderBasedDartSdk sdk = new FolderBasedDartSdk( |
| 302 new DirectoryBasedDartSdk(new JavaFile(sdkPath)); | 299 resourceProvider, resourceProvider.getFolder(sdkPath)); |
| 303 if (extFilePaths.isNotEmpty) { | 300 if (extFilePaths.isNotEmpty) { |
| 304 embedderSdk.addExtensions(extResolver.urlMappings); | 301 sdk.addExtensions(extResolver.urlMappings); |
| 305 } | 302 } |
| 306 sdk.analysisOptions = options; | 303 sdk.analysisOptions = options; |
| 307 sdk.useSummary = sdkManager.canUseSummaries; | 304 sdk.useSummary = sdkManager.canUseSummaries; |
| 308 return sdk; | 305 return sdk; |
| 309 }); | 306 }); |
| 310 } | 307 } |
| 311 } | 308 } |
| 312 String sdkPath = sdkManager.defaultSdkDirectory; | 309 String sdkPath = sdkManager.defaultSdkDirectory; |
| 313 SdkDescription description = new SdkDescription(<String>[sdkPath], options); | 310 SdkDescription description = new SdkDescription(<String>[sdkPath], options); |
| 314 return sdkManager.getSdk(description, () { | 311 return sdkManager.getSdk(description, () { |
| 315 DirectoryBasedDartSdk sdk = | 312 FolderBasedDartSdk sdk = new FolderBasedDartSdk( |
| 316 new DirectoryBasedDartSdk(new JavaFile(sdkPath)); | 313 resourceProvider, resourceProvider.getFolder(sdkPath)); |
| 317 sdk.analysisOptions = options; | 314 sdk.analysisOptions = options; |
| 318 sdk.useSummary = sdkManager.canUseSummaries; | 315 sdk.useSummary = sdkManager.canUseSummaries; |
| 319 return sdk; | 316 return sdk; |
| 320 }); | 317 }); |
| 321 } | 318 } |
| 322 | 319 |
| 323 /** | 320 /** |
| 324 * Return the analysis options that should be used when analyzing code in the | 321 * Return the analysis options that should be used when analyzing code in the |
| 325 * directory with the given [path]. | 322 * directory with the given [path]. |
| 326 */ | 323 */ |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 String _readEmbedderYaml(Folder libDir) { | 444 String _readEmbedderYaml(Folder libDir) { |
| 448 File file = libDir.getChild(EMBEDDER_FILE_NAME); | 445 File file = libDir.getChild(EMBEDDER_FILE_NAME); |
| 449 try { | 446 try { |
| 450 return file.readAsStringSync(); | 447 return file.readAsStringSync(); |
| 451 } on FileSystemException { | 448 } on FileSystemException { |
| 452 // File can't be read. | 449 // File can't be read. |
| 453 return null; | 450 return null; |
| 454 } | 451 } |
| 455 } | 452 } |
| 456 } | 453 } |
| OLD | NEW |