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'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (_context == null) { | 202 if (_context == null) { |
203 return false; | 203 return false; |
204 } | 204 } |
205 if (options.packageRootPath != _previousOptions.packageRootPath) { | 205 if (options.packageRootPath != _previousOptions.packageRootPath) { |
206 return false; | 206 return false; |
207 } | 207 } |
208 if (options.packageConfigPath != _previousOptions.packageConfigPath) { | 208 if (options.packageConfigPath != _previousOptions.packageConfigPath) { |
209 return false; | 209 return false; |
210 } | 210 } |
211 if (!_equalMaps( | 211 if (!_equalMaps( |
212 options.customUrlMappings, _previousOptions.customUrlMappings)) { | |
213 return false; | |
214 } | |
215 if (!_equalMaps( | |
216 options.definedVariables, _previousOptions.definedVariables)) { | 212 options.definedVariables, _previousOptions.definedVariables)) { |
217 return false; | 213 return false; |
218 } | 214 } |
219 if (options.log != _previousOptions.log) { | 215 if (options.log != _previousOptions.log) { |
220 return false; | 216 return false; |
221 } | 217 } |
222 if (options.disableHints != _previousOptions.disableHints) { | 218 if (options.disableHints != _previousOptions.disableHints) { |
223 return false; | 219 return false; |
224 } | 220 } |
225 if (options.enableStrictCallChecks != | 221 if (options.enableStrictCallChecks != |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 285 } |
290 } else { | 286 } else { |
291 return true; | 287 return true; |
292 } | 288 } |
293 }; | 289 }; |
294 } | 290 } |
295 | 291 |
296 /// Decide on the appropriate method for resolving URIs based on the given | 292 /// Decide on the appropriate method for resolving URIs based on the given |
297 /// [options] and [customUrlMappings] settings, and return a | 293 /// [options] and [customUrlMappings] settings, and return a |
298 /// [SourceFactory] that has been configured accordingly. | 294 /// [SourceFactory] that has been configured accordingly. |
299 SourceFactory _chooseUriResolutionPolicy( | 295 SourceFactory _chooseUriResolutionPolicy(CommandLineOptions options) { |
300 CommandLineOptions options, Map<String, String> customUrlMappings) { | |
301 Packages packages; | 296 Packages packages; |
302 Map<String, List<fileSystem.Folder>> packageMap; | 297 Map<String, List<fileSystem.Folder>> packageMap; |
303 UriResolver packageUriResolver; | 298 UriResolver packageUriResolver; |
304 | 299 |
305 // Process options, caching package resolution details. | 300 // Process options, caching package resolution details. |
306 if (options.packageConfigPath != null) { | 301 if (options.packageConfigPath != null) { |
307 String packageConfigPath = options.packageConfigPath; | 302 String packageConfigPath = options.packageConfigPath; |
308 Uri fileUri = new Uri.file(packageConfigPath); | 303 Uri fileUri = new Uri.file(packageConfigPath); |
309 try { | 304 try { |
310 File configFile = new File.fromUri(fileUri).absolute; | 305 File configFile = new File.fromUri(fileUri).absolute; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // to resolve packages. | 340 // to resolve packages. |
346 if (packageMapInfo.packageMap != null) { | 341 if (packageMapInfo.packageMap != null) { |
347 packageUriResolver = new PackageMapUriResolver( | 342 packageUriResolver = new PackageMapUriResolver( |
348 PhysicalResourceProvider.INSTANCE, packageMap); | 343 PhysicalResourceProvider.INSTANCE, packageMap); |
349 } | 344 } |
350 } | 345 } |
351 } | 346 } |
352 | 347 |
353 // Now, build our resolver list. | 348 // Now, build our resolver list. |
354 | 349 |
355 // Custom and 'dart:' URIs come first. | 350 // 'dart:' URIs come first. |
356 List<UriResolver> resolvers = [ | 351 List<UriResolver> resolvers = [new DartUriResolver(sdk)]; |
357 new CustomUriResolver(customUrlMappings), | |
358 new DartUriResolver(sdk) | |
359 ]; | |
360 | 352 |
361 // Next SdkExts. | 353 // Next SdkExts. |
362 if (packageMap != null) { | 354 if (packageMap != null) { |
363 resolvers.add(new SdkExtUriResolver(packageMap)); | 355 resolvers.add(new SdkExtUriResolver(packageMap)); |
364 } | 356 } |
365 | 357 |
366 // Then package URIs. | 358 // Then package URIs. |
367 if (packageUriResolver != null) { | 359 if (packageUriResolver != null) { |
368 resolvers.add(packageUriResolver); | 360 resolvers.add(packageUriResolver); |
369 } | 361 } |
(...skipping 24 matching lines...) Expand all Loading... |
394 | 386 |
395 /// Create an analysis context that is prepared to analyze sources according | 387 /// Create an analysis context that is prepared to analyze sources according |
396 /// to the given [options], and store it in [_context]. | 388 /// to the given [options], and store it in [_context]. |
397 void _createAnalysisContext(CommandLineOptions options) { | 389 void _createAnalysisContext(CommandLineOptions options) { |
398 if (_canContextBeReused(options)) { | 390 if (_canContextBeReused(options)) { |
399 return; | 391 return; |
400 } | 392 } |
401 _previousOptions = options; | 393 _previousOptions = options; |
402 // Choose a package resolution policy and a diet parsing policy based on | 394 // Choose a package resolution policy and a diet parsing policy based on |
403 // the command-line options. | 395 // the command-line options. |
404 SourceFactory sourceFactory = | 396 SourceFactory sourceFactory = _chooseUriResolutionPolicy(options); |
405 _chooseUriResolutionPolicy(options, options.customUrlMappings); | |
406 AnalyzeFunctionBodiesPredicate dietParsingPolicy = | 397 AnalyzeFunctionBodiesPredicate dietParsingPolicy = |
407 _chooseDietParsingPolicy(options); | 398 _chooseDietParsingPolicy(options); |
408 // Create a context using these policies. | 399 // Create a context using these policies. |
409 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); | 400 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); |
410 context.sourceFactory = sourceFactory; | 401 context.sourceFactory = sourceFactory; |
411 | 402 |
412 if (options.strongMode) { | 403 if (options.strongMode) { |
413 // TODO(jmesserly): support options file | 404 // TODO(jmesserly): support options file |
414 var strongOptions = new StrongModeOptions(hints: options.strongHints); | 405 var strongOptions = new StrongModeOptions(hints: options.strongHints); |
415 // TODO(jmesserly): make StrongChecker an analysis plugin | 406 // TODO(jmesserly): make StrongChecker an analysis plugin |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 for (var package in packages) { | 617 for (var package in packages) { |
627 var packageName = path.basename(package.path); | 618 var packageName = path.basename(package.path); |
628 var realPath = package.resolveSymbolicLinksSync(); | 619 var realPath = package.resolveSymbolicLinksSync(); |
629 result[packageName] = [ | 620 result[packageName] = [ |
630 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 621 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
631 ]; | 622 ]; |
632 } | 623 } |
633 return result; | 624 return result; |
634 } | 625 } |
635 } | 626 } |
OLD | NEW |