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/file_system/file_system.dart'; | 11 import 'package:analyzer/file_system/file_system.dart'; |
12 import 'package:analyzer/plugin/resolver_provider.dart'; | 12 import 'package:analyzer/plugin/resolver_provider.dart'; |
13 import 'package:analyzer/source/analysis_options_provider.dart'; | 13 import 'package:analyzer/source/analysis_options_provider.dart'; |
14 import 'package:analyzer/source/embedder.dart'; | 14 import 'package:analyzer/source/embedder.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/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
18 import 'package:analyzer/src/generated/java_io.dart'; | 18 import 'package:analyzer/src/generated/java_io.dart'; |
19 import 'package:analyzer/src/generated/sdk.dart'; | 19 import 'package:analyzer/src/generated/sdk.dart'; |
20 import 'package:analyzer/src/generated/sdk_io.dart'; | 20 import 'package:analyzer/src/generated/sdk_io.dart'; |
21 import 'package:analyzer/src/generated/source.dart'; | 21 import 'package:analyzer/src/generated/source.dart'; |
22 import 'package:analyzer/src/generated/source_io.dart'; | 22 import 'package:analyzer/src/generated/source_io.dart'; |
23 import 'package:analyzer/src/task/options.dart'; | 23 import 'package:analyzer/src/task/options.dart'; |
24 import 'package:package_config/discovery.dart'; | 24 import 'package:package_config/discovery.dart'; |
25 import 'package:package_config/packages.dart'; | 25 import 'package:package_config/packages.dart'; |
26 import 'package:package_config/packages_file.dart'; | 26 import 'package:package_config/packages_file.dart'; |
27 import 'package:package_config/src/packages_impl.dart'; | 27 import 'package:package_config/src/packages_impl.dart'; |
28 import 'package:path/path.dart' as path; | |
29 import 'package:yaml/yaml.dart'; | 28 import 'package:yaml/yaml.dart'; |
30 | 29 |
31 /** | 30 /** |
32 * A utility class used to build an analysis context for a given directory. | 31 * A utility class used to build an analysis context for a given directory. |
33 * | 32 * |
34 * The construction of analysis contexts is as follows: | 33 * The construction of analysis contexts is as follows: |
35 * | 34 * |
36 * 1. Determine how package: URI's are to be resolved. This follows the lookup | 35 * 1. Determine how package: URI's are to be resolved. This follows the lookup |
37 * algorithm defined by the [package specification][1]. | 36 * algorithm defined by the [package specification][1]. |
38 * | 37 * |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // optionsProcessors.forEach((OptionsProcessor p) => p.onError(e)); | 138 // optionsProcessors.forEach((OptionsProcessor p) => p.onError(e)); |
140 // } | 139 // } |
141 // } | 140 // } |
142 | 141 |
143 Map<String, List<Folder>> convertPackagesToMap(Packages packages) { | 142 Map<String, List<Folder>> convertPackagesToMap(Packages packages) { |
144 if (packages == null || packages == Packages.noPackages) { | 143 if (packages == null || packages == Packages.noPackages) { |
145 return null; | 144 return null; |
146 } | 145 } |
147 Map<String, List<Folder>> folderMap = new HashMap<String, List<Folder>>(); | 146 Map<String, List<Folder>> folderMap = new HashMap<String, List<Folder>>(); |
148 packages.asMap().forEach((String packagePath, Uri uri) { | 147 packages.asMap().forEach((String packagePath, Uri uri) { |
149 folderMap[packagePath] = [resourceProvider.getFolder(path.fromUri(uri))]; | 148 String path = resourceProvider.pathContext.fromUri(uri); |
| 149 folderMap[packagePath] = [resourceProvider.getFolder(path)]; |
150 }); | 150 }); |
151 return folderMap; | 151 return folderMap; |
152 } | 152 } |
153 | 153 |
154 Packages createPackageMap(String rootDirectoryPath) { | 154 Packages createPackageMap(String rootDirectoryPath) { |
155 if (defaultPackageFilePath != null) { | 155 if (defaultPackageFilePath != null) { |
156 // TODO(brianwilkerson) Figure out why we're going through Uri rather than | 156 // TODO(brianwilkerson) Figure out why we're going through Uri rather than |
157 // just creating the file from the path. | 157 // just creating the file from the path. |
158 Uri fileUri = new Uri.file(defaultPackageFilePath); | 158 Uri fileUri = new Uri.file(defaultPackageFilePath); |
159 io.File configFile = new io.File.fromUri(fileUri).absolute; | 159 io.File configFile = new io.File.fromUri(fileUri).absolute; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 285 } |
286 file = folder | 286 file = folder |
287 .getChildAssumingFile(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 287 .getChildAssumingFile(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
288 if (file.exists) { | 288 if (file.exists) { |
289 return file; | 289 return file; |
290 } | 290 } |
291 } | 291 } |
292 return null; | 292 return null; |
293 } | 293 } |
294 } | 294 } |
OLD | NEW |