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 | 2 |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 import 'package:args/args.dart' show ArgParser, ArgResults; | 6 import 'package:args/args.dart' show ArgParser, ArgResults; |
7 import 'package:analyzer/file_system/file_system.dart' | 7 import 'package:analyzer/file_system/file_system.dart' |
8 show ResourceProvider, ResourceUriResolver; | 8 show ResourceProvider, ResourceUriResolver; |
9 import 'package:analyzer/file_system/physical_file_system.dart' | 9 import 'package:analyzer/file_system/physical_file_system.dart' |
10 show PhysicalResourceProvider; | 10 show PhysicalResourceProvider; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 : summaryPaths = args['summary'] as List<String>, | 67 : summaryPaths = args['summary'] as List<String>, |
68 dartSdkPath = args['dart-sdk'] ?? getSdkDir().path, | 68 dartSdkPath = args['dart-sdk'] ?? getSdkDir().path, |
69 dartSdkSummaryPath = args['dart-sdk-summary'], | 69 dartSdkSummaryPath = args['dart-sdk-summary'], |
70 customUrlMappings = _parseUrlMappings(args['url-mapping']), | 70 customUrlMappings = _parseUrlMappings(args['url-mapping']), |
71 packageRoot = args['package-root'], | 71 packageRoot = args['package-root'], |
72 packagePaths = (args['package-paths'] as String)?.split(',') ?? []; | 72 packagePaths = (args['package-paths'] as String)?.split(',') ?? []; |
73 | 73 |
74 /// Whether to resolve 'package:' uris using the multi-package resolver. | 74 /// Whether to resolve 'package:' uris using the multi-package resolver. |
75 bool get useMultiPackage => packagePaths.isNotEmpty; | 75 bool get useMultiPackage => packagePaths.isNotEmpty; |
76 | 76 |
77 static ArgParser addArguments(ArgParser parser) { | 77 static void addArguments(ArgParser parser) { |
78 return parser | 78 parser |
79 ..addOption('summary', | 79 ..addOption('summary', |
80 abbr: 's', help: 'summary file(s) to include', allowMultiple: true) | 80 abbr: 's', help: 'summary file(s) to include', allowMultiple: true) |
81 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null) | 81 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null) |
82 ..addOption('dart-sdk-summary', | 82 ..addOption('dart-sdk-summary', |
83 help: 'Dart SDK Summary Path', defaultsTo: null) | 83 help: 'Dart SDK Summary Path', defaultsTo: null) |
84 ..addOption('package-root', | 84 ..addOption('package-root', |
85 abbr: 'p', | 85 abbr: 'p', |
86 help: 'Package root to resolve "package:" imports', | 86 help: 'Package root to resolve "package:" imports', |
87 defaultsTo: 'packages/') | 87 defaultsTo: 'packages/') |
88 ..addOption('url-mapping', | 88 ..addOption('url-mapping', |
89 help: '--url-mapping=libraryUri,/path/to/library.dart uses \n' | 89 help: '--url-mapping=libraryUri,/path/to/library.dart uses\n' |
90 'library.dart as the source for an import of of "libraryUri".', | 90 'library.dart as the source for an import of of "libraryUri".', |
91 allowMultiple: true, | 91 allowMultiple: true, |
92 splitCommas: false) | 92 splitCommas: false) |
93 ..addOption('package-paths', | 93 ..addOption('package-paths', |
94 help: 'use a list of directories to resolve "package:" imports'); | 94 help: 'use a list of directories to resolve "package:" imports'); |
95 } | 95 } |
96 | 96 |
97 static Map<String, String> _parseUrlMappings(Iterable argument) { | 97 static Map<String, String> _parseUrlMappings(Iterable argument) { |
98 var mappings = <String, String>{}; | 98 var mappings = <String, String>{}; |
99 for (var mapping in argument) { | 99 for (var mapping in argument) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return sdk; | 191 return sdk; |
192 } | 192 } |
193 | 193 |
194 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. | 194 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. |
195 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) { | 195 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) { |
196 var sdk = (sdkSummaryPath != null) | 196 var sdk = (sdkSummaryPath != null) |
197 ? new SummaryBasedDartSdk(sdkSummaryPath, true) | 197 ? new SummaryBasedDartSdk(sdkSummaryPath, true) |
198 : _createDirectoryBasedDartSdk(sdkPath); | 198 : _createDirectoryBasedDartSdk(sdkPath); |
199 return new DartUriResolver(sdk); | 199 return new DartUriResolver(sdk); |
200 } | 200 } |
OLD | NEW |