OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core'; | 10 import 'dart:core'; |
11 | 11 |
12 import 'package:analysis_server/src/analysis_server.dart'; | 12 import 'package:analysis_server/src/analysis_server.dart'; |
13 import 'package:analyzer/exception/exception.dart'; | 13 import 'package:analyzer/exception/exception.dart'; |
14 import 'package:analyzer/file_system/file_system.dart'; | 14 import 'package:analyzer/file_system/file_system.dart'; |
15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
16 import 'package:analyzer/plugin/options.dart'; | 16 import 'package:analyzer/plugin/options.dart'; |
17 import 'package:analyzer/plugin/resolver_provider.dart'; | 17 import 'package:analyzer/plugin/resolver_provider.dart'; |
18 import 'package:analyzer/source/analysis_options_provider.dart'; | 18 import 'package:analyzer/source/analysis_options_provider.dart'; |
19 import 'package:analyzer/source/config.dart'; | |
20 import 'package:analyzer/source/package_map_provider.dart'; | 19 import 'package:analyzer/source/package_map_provider.dart'; |
21 import 'package:analyzer/source/package_map_resolver.dart'; | 20 import 'package:analyzer/source/package_map_resolver.dart'; |
22 import 'package:analyzer/source/path_filter.dart'; | 21 import 'package:analyzer/source/path_filter.dart'; |
23 import 'package:analyzer/source/pub_package_map_provider.dart'; | 22 import 'package:analyzer/source/pub_package_map_provider.dart'; |
24 import 'package:analyzer/source/sdk_ext.dart'; | 23 import 'package:analyzer/source/sdk_ext.dart'; |
25 import 'package:analyzer/src/context/builder.dart'; | 24 import 'package:analyzer/src/context/builder.dart'; |
26 import 'package:analyzer/src/context/context.dart' as context; | 25 import 'package:analyzer/src/context/context.dart' as context; |
27 import 'package:analyzer/src/dart/analysis/driver.dart'; | 26 import 'package:analyzer/src/dart/analysis/driver.dart'; |
28 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 27 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
29 import 'package:analyzer/src/generated/engine.dart'; | 28 import 'package:analyzer/src/generated/engine.dart'; |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 if (packagespecFile.shortName == PUBSPEC_NAME) { | 1096 if (packagespecFile.shortName == PUBSPEC_NAME) { |
1098 pubspec = packagespecFile; | 1097 pubspec = packagespecFile; |
1099 } | 1098 } |
1100 } | 1099 } |
1101 if (pubspec == null) { | 1100 if (pubspec == null) { |
1102 Resource child = folder.getChild(PUBSPEC_NAME); | 1101 Resource child = folder.getChild(PUBSPEC_NAME); |
1103 if (child.exists && child is File) { | 1102 if (child.exists && child is File) { |
1104 pubspec = child; | 1103 pubspec = child; |
1105 } | 1104 } |
1106 } | 1105 } |
1107 if (pubspec != null) { | |
1108 File pubSource = resourceProvider.getFile(pubspec.path); | |
1109 if (enableNewAnalysisDriver) { | |
1110 // TODO(scheglov) implement for the new analysis driver | |
1111 } else { | |
1112 setConfiguration( | |
1113 info.context, | |
1114 new AnalysisConfiguration.fromPubspec( | |
1115 pubSource, resourceProvider, disposition.packages)); | |
1116 } | |
1117 } | |
1118 | 1106 |
1119 if (enableNewAnalysisDriver) { | 1107 if (enableNewAnalysisDriver) { |
1120 // TODO(scheglov) implement for the new analysis driver | 1108 // TODO(scheglov) implement for the new analysis driver |
1121 } else { | 1109 } else { |
1122 processOptionsForContext(info, optionMap); | 1110 processOptionsForContext(info, optionMap); |
1123 } | 1111 } |
1124 | 1112 |
1125 return info; | 1113 return info; |
1126 } | 1114 } |
1127 | 1115 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 /// | 1253 /// |
1266 /// Returns null if there are no embedded/configured options. | 1254 /// Returns null if there are no embedded/configured options. |
1267 Map _getEmbeddedOptions(ContextInfo info) { | 1255 Map _getEmbeddedOptions(ContextInfo info) { |
1268 Map embeddedOptions = null; | 1256 Map embeddedOptions = null; |
1269 EmbedderYamlLocator locator = | 1257 EmbedderYamlLocator locator = |
1270 info.disposition.getEmbedderLocator(resourceProvider); | 1258 info.disposition.getEmbedderLocator(resourceProvider); |
1271 Iterable<YamlMap> maps = locator.embedderYamls.values; | 1259 Iterable<YamlMap> maps = locator.embedderYamls.values; |
1272 if (maps.length == 1) { | 1260 if (maps.length == 1) { |
1273 embeddedOptions = maps.first; | 1261 embeddedOptions = maps.first; |
1274 } | 1262 } |
1275 | |
1276 AnalysisConfiguration configuration = getConfiguration(info.context); | |
1277 if (configuration != null) { | |
1278 Map configMap = configuration.options; | |
1279 if (configMap != null) { | |
1280 if (embeddedOptions != null) { | |
1281 embeddedOptions = new Merger().merge(embeddedOptions, configMap); | |
1282 } else { | |
1283 embeddedOptions = configMap; | |
1284 } | |
1285 } | |
1286 } | |
1287 return embeddedOptions; | 1263 return embeddedOptions; |
1288 } | 1264 } |
1289 | 1265 |
1290 /** | 1266 /** |
1291 * Return the [ContextInfo] for the "innermost" context whose associated | 1267 * Return the [ContextInfo] for the "innermost" context whose associated |
1292 * folder is or contains the given path. ("innermost" refers to the nesting | 1268 * folder is or contains the given path. ("innermost" refers to the nesting |
1293 * of contexts, so if there is a context for path /foo and a context for | 1269 * of contexts, so if there is a context for path /foo and a context for |
1294 * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is | 1270 * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is |
1295 * the context for /foo/bar.) | 1271 * the context for /foo/bar.) |
1296 * | 1272 * |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 } | 1867 } |
1892 return _embedderLocator; | 1868 return _embedderLocator; |
1893 } | 1869 } |
1894 | 1870 |
1895 @override | 1871 @override |
1896 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { | 1872 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { |
1897 return _sdkExtensionFinder ??= | 1873 return _sdkExtensionFinder ??= |
1898 new SdkExtensionFinder(buildPackageMap(resourceProvider)); | 1874 new SdkExtensionFinder(buildPackageMap(resourceProvider)); |
1899 } | 1875 } |
1900 } | 1876 } |
OLD | NEW |