| 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'; | 8 import 'dart:core'; |
| 9 | 9 |
| 10 import 'package:analyzer/context/declared_variables.dart'; | 10 import 'package:analyzer/context/declared_variables.dart'; |
| 11 import 'package:analyzer/file_system/file_system.dart'; | 11 import 'package:analyzer/file_system/file_system.dart'; |
| 12 import 'package:analyzer/plugin/options.dart'; | 12 import 'package:analyzer/plugin/options.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/src/dart/sdk/sdk.dart'; | 16 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 17 import 'package:analyzer/src/generated/bazel.dart'; | 17 import 'package:analyzer/src/generated/bazel.dart'; |
| 18 import 'package:analyzer/src/generated/engine.dart'; | 18 import 'package:analyzer/src/generated/engine.dart'; |
| 19 import 'package:analyzer/src/generated/sdk.dart'; | 19 import 'package:analyzer/src/generated/sdk.dart'; |
| 20 import 'package:analyzer/src/generated/source.dart'; | 20 import 'package:analyzer/src/generated/source.dart'; |
| 21 import 'package:analyzer/src/summary/package_bundle_reader.dart'; | 21 import 'package:analyzer/src/summary/package_bundle_reader.dart'; |
| 22 import 'package:analyzer/src/summary/pub_summary.dart'; | 22 import 'package:analyzer/src/summary/pub_summary.dart'; |
| 23 import 'package:analyzer/src/summary/summary_sdk.dart'; |
| 23 import 'package:analyzer/src/task/options.dart'; | 24 import 'package:analyzer/src/task/options.dart'; |
| 24 import 'package:package_config/packages.dart'; | 25 import 'package:package_config/packages.dart'; |
| 25 import 'package:package_config/packages_file.dart'; | 26 import 'package:package_config/packages_file.dart'; |
| 26 import 'package:package_config/src/packages_impl.dart'; | 27 import 'package:package_config/src/packages_impl.dart'; |
| 27 import 'package:path/src/context.dart'; | 28 import 'package:path/src/context.dart'; |
| 28 import 'package:yaml/yaml.dart'; | 29 import 'package:yaml/yaml.dart'; |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * A utility class used to build an analysis context for a given directory. | 32 * A utility class used to build an analysis context for a given directory. |
| 32 * | 33 * |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 String defaultPackageFilePath; | 90 String defaultPackageFilePath; |
| 90 | 91 |
| 91 /** | 92 /** |
| 92 * The file path of the packages directory that should be used in place of any | 93 * The file path of the packages directory that should be used in place of any |
| 93 * file found using the normal (Package Specification DEP) lookup mechanism, | 94 * file found using the normal (Package Specification DEP) lookup mechanism, |
| 94 * or `null` if the normal lookup mechanism should be used. | 95 * or `null` if the normal lookup mechanism should be used. |
| 95 */ | 96 */ |
| 96 String defaultPackagesDirectoryPath; | 97 String defaultPackagesDirectoryPath; |
| 97 | 98 |
| 98 /** | 99 /** |
| 100 * The file path of the file containing the summary of the SDK that should be |
| 101 * used to "analyze" the SDK. This option should only be specified by |
| 102 * command-line tools such as 'dartanalyzer' or 'ddc'. |
| 103 */ |
| 104 String dartSdkSummaryPath; |
| 105 |
| 106 /** |
| 99 * The file path of the analysis options file that should be used in place of | 107 * The file path of the analysis options file that should be used in place of |
| 100 * any file in the root directory or a parent of the root directory, or `null` | 108 * any file in the root directory or a parent of the root directory, or `null` |
| 101 * if the normal lookup mechanism should be used. | 109 * if the normal lookup mechanism should be used. |
| 102 */ | 110 */ |
| 103 String defaultAnalysisOptionsFilePath; | 111 String defaultAnalysisOptionsFilePath; |
| 104 | 112 |
| 105 /** | 113 /** |
| 106 * The default analysis options that should be used unless some or all of them | 114 * The default analysis options that should be used unless some or all of them |
| 107 * are overridden in the analysis options file, or `null` if the default | 115 * are overridden in the analysis options file, or `null` if the default |
| 108 * defaults should be used. | 116 * defaults should be used. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 289 } |
| 282 return Packages.noPackages; | 290 return Packages.noPackages; |
| 283 } | 291 } |
| 284 | 292 |
| 285 /** | 293 /** |
| 286 * Return the SDK that should be used to analyze code. Use the given | 294 * Return the SDK that should be used to analyze code. Use the given |
| 287 * [packageMap] and [options] to locate the SDK. | 295 * [packageMap] and [options] to locate the SDK. |
| 288 */ | 296 */ |
| 289 DartSdk findSdk( | 297 DartSdk findSdk( |
| 290 Map<String, List<Folder>> packageMap, AnalysisOptions options) { | 298 Map<String, List<Folder>> packageMap, AnalysisOptions options) { |
| 291 if (packageMap != null) { | 299 if (dartSdkSummaryPath != null) { |
| 300 return new SummaryBasedDartSdk(dartSdkSummaryPath, options.strongMode); |
| 301 } else if (packageMap != null) { |
| 292 SdkExtensionFinder extFinder = new SdkExtensionFinder(packageMap); | 302 SdkExtensionFinder extFinder = new SdkExtensionFinder(packageMap); |
| 293 List<String> extFilePaths = extFinder.extensionFilePaths; | 303 List<String> extFilePaths = extFinder.extensionFilePaths; |
| 294 EmbedderYamlLocator locator = new EmbedderYamlLocator(packageMap); | 304 EmbedderYamlLocator locator = new EmbedderYamlLocator(packageMap); |
| 295 Map<Folder, YamlMap> embedderYamls = locator.embedderYamls; | 305 Map<Folder, YamlMap> embedderYamls = locator.embedderYamls; |
| 296 EmbedderSdk embedderSdk = | 306 EmbedderSdk embedderSdk = |
| 297 new EmbedderSdk(resourceProvider, embedderYamls); | 307 new EmbedderSdk(resourceProvider, embedderYamls); |
| 298 if (embedderSdk.sdkLibraries.length > 0) { | 308 if (embedderSdk.sdkLibraries.length > 0) { |
| 299 // | 309 // |
| 300 // There is an embedder file that defines the content of the SDK and | 310 // There is an embedder file that defines the content of the SDK and |
| 301 // there might be an extension file that extends it. | 311 // there might be an extension file that extends it. |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 String _readEmbedderYaml(Folder libDir) { | 590 String _readEmbedderYaml(Folder libDir) { |
| 581 File file = libDir.getChild(EMBEDDER_FILE_NAME); | 591 File file = libDir.getChild(EMBEDDER_FILE_NAME); |
| 582 try { | 592 try { |
| 583 return file.readAsStringSync(); | 593 return file.readAsStringSync(); |
| 584 } on FileSystemException { | 594 } on FileSystemException { |
| 585 // File can't be read. | 595 // File can't be read. |
| 586 return null; | 596 return null; |
| 587 } | 597 } |
| 588 } | 598 } |
| 589 } | 599 } |
| OLD | NEW |