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.driver; | 5 library analyzer_cli.src.driver; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
10 | 10 |
11 import 'package:analyzer/error/error.dart'; | 11 import 'package:analyzer/error/error.dart'; |
12 import 'package:analyzer/file_system/file_system.dart' as file_system; | 12 import 'package:analyzer/file_system/file_system.dart' as file_system; |
13 import 'package:analyzer/file_system/file_system.dart'; | 13 import 'package:analyzer/file_system/file_system.dart'; |
14 import 'package:analyzer/file_system/physical_file_system.dart'; | 14 import 'package:analyzer/file_system/physical_file_system.dart'; |
15 import 'package:analyzer/plugin/options.dart'; | 15 import 'package:analyzer/plugin/options.dart'; |
16 import 'package:analyzer/plugin/resolver_provider.dart'; | 16 import 'package:analyzer/plugin/resolver_provider.dart'; |
17 import 'package:analyzer/source/analysis_options_provider.dart'; | 17 import 'package:analyzer/source/analysis_options_provider.dart'; |
18 import 'package:analyzer/source/package_map_provider.dart'; | |
19 import 'package:analyzer/source/package_map_resolver.dart'; | 18 import 'package:analyzer/source/package_map_resolver.dart'; |
20 import 'package:analyzer/source/pub_package_map_provider.dart'; | |
21 import 'package:analyzer/source/sdk_ext.dart'; | 19 import 'package:analyzer/source/sdk_ext.dart'; |
22 import 'package:analyzer/src/context/builder.dart'; | 20 import 'package:analyzer/src/context/builder.dart'; |
23 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 21 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
24 import 'package:analyzer/src/generated/constant.dart'; | 22 import 'package:analyzer/src/generated/constant.dart'; |
25 import 'package:analyzer/src/generated/engine.dart'; | 23 import 'package:analyzer/src/generated/engine.dart'; |
26 import 'package:analyzer/src/generated/interner.dart'; | 24 import 'package:analyzer/src/generated/interner.dart'; |
27 import 'package:analyzer/src/generated/java_engine.dart'; | 25 import 'package:analyzer/src/generated/java_engine.dart'; |
28 import 'package:analyzer/src/generated/sdk.dart'; | 26 import 'package:analyzer/src/generated/sdk.dart'; |
29 import 'package:analyzer/src/generated/source.dart'; | 27 import 'package:analyzer/src/generated/source.dart'; |
30 import 'package:analyzer/src/generated/source_io.dart'; | 28 import 'package:analyzer/src/generated/source_io.dart'; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 365 } |
368 } | 366 } |
369 | 367 |
370 UriResolver packageUriResolver; | 368 UriResolver packageUriResolver; |
371 | 369 |
372 if (options.packageRootPath != null) { | 370 if (options.packageRootPath != null) { |
373 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null); | 371 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null); |
374 builder.defaultPackagesDirectoryPath = options.packageRootPath; | 372 builder.defaultPackagesDirectoryPath = options.packageRootPath; |
375 packageUriResolver = new PackageMapUriResolver(resourceProvider, | 373 packageUriResolver = new PackageMapUriResolver(resourceProvider, |
376 builder.convertPackagesToMap(builder.createPackageMap(''))); | 374 builder.convertPackagesToMap(builder.createPackageMap(''))); |
377 } else if (options.packageConfigPath == null) { | |
378 // TODO(pq): remove? | |
379 if (packageInfo.packageMap == null) { | |
380 // Fall back to pub list-package-dirs. | |
381 PubPackageMapProvider pubPackageMapProvider = | |
382 new PubPackageMapProvider(resourceProvider, sdk); | |
383 file_system.Resource cwd = resourceProvider.getResource('.'); | |
384 PackageMapInfo packageMapInfo = | |
385 pubPackageMapProvider.computePackageMap(cwd); | |
386 Map<String, List<file_system.Folder>> packageMap = | |
387 packageMapInfo.packageMap; | |
388 | |
389 // Only create a packageUriResolver if pub list-package-dirs succeeded. | |
390 // If it failed, that's not a problem; it simply means we have no way | |
391 // to resolve packages. | |
392 if (packageMapInfo.packageMap != null) { | |
393 packageUriResolver = | |
394 new PackageMapUriResolver(resourceProvider, packageMap); | |
395 } | |
396 } | |
397 } | 375 } |
398 | 376 |
399 // Now, build our resolver list. | 377 // Now, build our resolver list. |
400 List<UriResolver> resolvers = []; | 378 List<UriResolver> resolvers = []; |
401 | 379 |
402 // 'dart:' URIs come first. | 380 // 'dart:' URIs come first. |
403 | 381 |
404 // Setup embedding. | 382 // Setup embedding. |
405 EmbedderSdk embedderSdk = new EmbedderSdk(resourceProvider, embedderMap); | 383 EmbedderSdk embedderSdk = new EmbedderSdk(resourceProvider, embedderMap); |
406 if (embedderSdk.libraryMap.size() == 0) { | 384 if (embedderSdk.libraryMap.size() == 0) { |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 for (var package in packages) { | 851 for (var package in packages) { |
874 var packageName = path.basename(package.path); | 852 var packageName = path.basename(package.path); |
875 var realPath = package.resolveSymbolicLinksSync(); | 853 var realPath = package.resolveSymbolicLinksSync(); |
876 result[packageName] = [ | 854 result[packageName] = [ |
877 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 855 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
878 ]; | 856 ]; |
879 } | 857 } |
880 return result; | 858 return result; |
881 } | 859 } |
882 } | 860 } |
OLD | NEW |