Chromium Code Reviews| 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 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 import 'package:analyzer/src/generated/constant.dart'; | 26 import 'package:analyzer/src/generated/constant.dart'; |
| 27 import 'package:analyzer/src/generated/engine.dart'; | 27 import 'package:analyzer/src/generated/engine.dart'; |
| 28 import 'package:analyzer/src/generated/interner.dart'; | 28 import 'package:analyzer/src/generated/interner.dart'; |
| 29 import 'package:analyzer/src/generated/java_engine.dart'; | 29 import 'package:analyzer/src/generated/java_engine.dart'; |
| 30 import 'package:analyzer/src/generated/sdk.dart'; | 30 import 'package:analyzer/src/generated/sdk.dart'; |
| 31 import 'package:analyzer/src/generated/source.dart'; | 31 import 'package:analyzer/src/generated/source.dart'; |
| 32 import 'package:analyzer/src/generated/source_io.dart'; | 32 import 'package:analyzer/src/generated/source_io.dart'; |
| 33 import 'package:analyzer/src/generated/utilities_general.dart' | 33 import 'package:analyzer/src/generated/utilities_general.dart' |
| 34 show PerformanceTag; | 34 show PerformanceTag; |
| 35 import 'package:analyzer/src/lint/registry.dart'; | 35 import 'package:analyzer/src/lint/registry.dart'; |
| 36 import 'package:analyzer/src/services/lint.dart'; | |
| 37 import 'package:analyzer/src/source/source_resource.dart'; | 36 import 'package:analyzer/src/source/source_resource.dart'; |
| 38 import 'package:analyzer/src/summary/idl.dart'; | 37 import 'package:analyzer/src/summary/idl.dart'; |
| 39 import 'package:analyzer/src/summary/package_bundle_reader.dart'; | 38 import 'package:analyzer/src/summary/package_bundle_reader.dart'; |
| 40 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; | 39 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; |
| 41 import 'package:analyzer/src/task/options.dart'; | 40 import 'package:analyzer/src/task/options.dart'; |
| 42 import 'package:analyzer_cli/src/analyzer_impl.dart'; | 41 import 'package:analyzer_cli/src/analyzer_impl.dart'; |
| 43 import 'package:analyzer_cli/src/build_mode.dart'; | 42 import 'package:analyzer_cli/src/build_mode.dart'; |
| 44 import 'package:analyzer_cli/src/error_formatter.dart'; | 43 import 'package:analyzer_cli/src/error_formatter.dart'; |
| 45 import 'package:analyzer_cli/src/options.dart'; | 44 import 'package:analyzer_cli/src/options.dart'; |
| 46 import 'package:analyzer_cli/src/perf_report.dart'; | 45 import 'package:analyzer_cli/src/perf_report.dart'; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 }; | 360 }; |
| 362 } | 361 } |
| 363 | 362 |
| 364 /// Decide on the appropriate method for resolving URIs based on the given | 363 /// Decide on the appropriate method for resolving URIs based on the given |
| 365 /// [options] and [customUrlMappings] settings, and return a | 364 /// [options] and [customUrlMappings] settings, and return a |
| 366 /// [SourceFactory] that has been configured accordingly. | 365 /// [SourceFactory] that has been configured accordingly. |
| 367 SourceFactory _chooseUriResolutionPolicy( | 366 SourceFactory _chooseUriResolutionPolicy( |
| 368 CommandLineOptions options, | 367 CommandLineOptions options, |
| 369 Map<file_system.Folder, YamlMap> embedderMap, | 368 Map<file_system.Folder, YamlMap> embedderMap, |
| 370 _PackageInfo packageInfo, | 369 _PackageInfo packageInfo, |
| 371 SummaryDataStore summaryDataStore) { | 370 SummaryDataStore summaryDataStore, |
| 371 bool includeSdkResolver, | |
| 372 AnalysisOptions analysisOptions) { | |
|
Brian Wilkerson
2017/02/04 16:58:38
We should document that analysisOptions can / will
danrubel
2017/02/04 17:08:34
Good point. Done.
| |
| 372 // Create a custom package resolver if one has been specified. | 373 // Create a custom package resolver if one has been specified. |
| 373 if (packageResolverProvider != null) { | 374 if (packageResolverProvider != null) { |
| 374 file_system.Folder folder = resourceProvider.getResource('.'); | 375 file_system.Folder folder = resourceProvider.getResource('.'); |
| 375 UriResolver resolver = packageResolverProvider(folder); | 376 UriResolver resolver = packageResolverProvider(folder); |
| 376 if (resolver != null) { | 377 if (resolver != null) { |
| 377 UriResolver sdkResolver = new DartUriResolver(sdk); | |
| 378 | |
| 379 // TODO(brianwilkerson) This doesn't handle sdk extensions. | 378 // TODO(brianwilkerson) This doesn't handle sdk extensions. |
| 380 List<UriResolver> resolvers = <UriResolver>[ | 379 List<UriResolver> resolvers = <UriResolver>[]; |
| 381 sdkResolver, | 380 if (includeSdkResolver) { |
| 382 new InSummaryUriResolver(resourceProvider, summaryDataStore), | 381 resolvers.add(new DartUriResolver(sdk)); |
| 383 resolver, | 382 } |
| 384 new file_system.ResourceUriResolver(resourceProvider) | 383 resolvers |
| 385 ]; | 384 .add(new InSummaryUriResolver(resourceProvider, summaryDataStore)); |
| 385 resolvers.add(resolver); | |
| 386 resolvers.add(new file_system.ResourceUriResolver(resourceProvider)); | |
| 386 return new SourceFactory(resolvers); | 387 return new SourceFactory(resolvers); |
| 387 } | 388 } |
| 388 } | 389 } |
| 389 | 390 |
| 390 UriResolver packageUriResolver; | 391 UriResolver packageUriResolver; |
| 391 | 392 |
| 392 if (options.packageRootPath != null) { | 393 if (options.packageRootPath != null) { |
| 393 ContextBuilderOptions builderOptions = new ContextBuilderOptions(); | 394 ContextBuilderOptions builderOptions = new ContextBuilderOptions(); |
| 394 builderOptions.defaultPackagesDirectoryPath = options.packageRootPath; | 395 builderOptions.defaultPackagesDirectoryPath = options.packageRootPath; |
| 395 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null, | 396 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 417 } | 418 } |
| 418 } | 419 } |
| 419 } | 420 } |
| 420 | 421 |
| 421 // Now, build our resolver list. | 422 // Now, build our resolver list. |
| 422 List<UriResolver> resolvers = []; | 423 List<UriResolver> resolvers = []; |
| 423 | 424 |
| 424 // 'dart:' URIs come first. | 425 // 'dart:' URIs come first. |
| 425 | 426 |
| 426 // Setup embedding. | 427 // Setup embedding. |
| 427 EmbedderSdk embedderSdk = new EmbedderSdk(resourceProvider, embedderMap); | 428 if (includeSdkResolver) { |
| 428 if (embedderSdk.libraryMap.size() == 0) { | 429 EmbedderSdk embedderSdk = new EmbedderSdk(resourceProvider, embedderMap); |
| 429 // The embedder uri resolver has no mappings. Use the default Dart SDK | 430 if (embedderSdk.libraryMap.size() == 0) { |
| 430 // uri resolver. | 431 // The embedder uri resolver has no mappings. Use the default Dart SDK |
| 431 resolvers.add(new DartUriResolver(sdk)); | 432 // uri resolver. |
| 432 } else { | 433 resolvers.add(new DartUriResolver(sdk)); |
| 433 // The embedder uri resolver has mappings, use it instead of the default | 434 } else { |
| 434 // Dart SDK uri resolver. | 435 // The embedder uri resolver has mappings, use it instead of the default |
| 435 embedderSdk.analysisOptions = _context.analysisOptions; | 436 // Dart SDK uri resolver. |
| 436 resolvers.add(new DartUriResolver(embedderSdk)); | 437 embedderSdk.analysisOptions = analysisOptions; |
| 438 resolvers.add(new DartUriResolver(embedderSdk)); | |
| 439 } | |
| 437 } | 440 } |
| 438 | 441 |
| 439 // Next SdkExts. | 442 // Next SdkExts. |
| 440 if (packageInfo.packageMap != null) { | 443 if (packageInfo.packageMap != null) { |
| 441 resolvers.add(new SdkExtUriResolver(packageInfo.packageMap)); | 444 resolvers.add(new SdkExtUriResolver(packageInfo.packageMap)); |
| 442 } | 445 } |
| 443 | 446 |
| 444 // Then package URIs from summaries. | 447 // Then package URIs from summaries. |
| 445 resolvers.add(new InSummaryUriResolver(resourceProvider, summaryDataStore)); | 448 resolvers.add(new InSummaryUriResolver(resourceProvider, summaryDataStore)); |
| 446 | 449 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 if (_canContextBeReused(options)) { | 505 if (_canContextBeReused(options)) { |
| 503 return; | 506 return; |
| 504 } | 507 } |
| 505 _previousOptions = options; | 508 _previousOptions = options; |
| 506 | 509 |
| 507 // Save stats from previous context before clobbering it. | 510 // Save stats from previous context before clobbering it. |
| 508 if (_context != null) { | 511 if (_context != null) { |
| 509 _analyzedFileCount += _context.sources.length; | 512 _analyzedFileCount += _context.sources.length; |
| 510 } | 513 } |
| 511 | 514 |
| 512 // Create a context. | |
| 513 _context = AnalysisEngine.instance.createAnalysisContext(); | |
| 514 | |
| 515 // Find package info. | 515 // Find package info. |
| 516 _PackageInfo packageInfo = _findPackages(options); | 516 _PackageInfo packageInfo = _findPackages(options); |
| 517 | 517 |
| 518 // Process embedders. | 518 // Process embedders. |
| 519 Map<file_system.Folder, YamlMap> embedderMap = | 519 Map<file_system.Folder, YamlMap> embedderMap = |
| 520 new EmbedderYamlLocator(packageInfo.packageMap).embedderYamls; | 520 new EmbedderYamlLocator(packageInfo.packageMap).embedderYamls; |
| 521 | 521 |
| 522 // Scan for SDK extenders. | 522 // Scan for SDK extenders. |
| 523 bool hasSdkExt = _hasSdkExt(packageInfo.packageMap?.values); | 523 bool hasSdkExt = _hasSdkExt(packageInfo.packageMap?.values); |
| 524 | 524 |
| 525 // No summaries in the presence of embedders or extenders. | 525 // No summaries in the presence of embedders or extenders. |
| 526 bool useSummaries = embedderMap.isEmpty && !hasSdkExt; | 526 bool useSummaries = embedderMap.isEmpty && !hasSdkExt; |
| 527 | 527 |
| 528 if (!useSummaries && options.buildSummaryInputs.isNotEmpty) { | 528 if (!useSummaries && options.buildSummaryInputs.isNotEmpty) { |
| 529 throw new _DriverError( | 529 throw new _DriverError( |
| 530 'Summaries are not yet supported when using Flutter.'); | 530 'Summaries are not yet supported when using Flutter.'); |
| 531 } | 531 } |
| 532 | 532 |
| 533 // Read any input summaries. | 533 // Read any input summaries. |
| 534 SummaryDataStore summaryDataStore = new SummaryDataStore( | 534 SummaryDataStore summaryDataStore = new SummaryDataStore( |
| 535 useSummaries ? options.buildSummaryInputs : <String>[]); | 535 useSummaries ? options.buildSummaryInputs : <String>[]); |
| 536 | 536 |
| 537 // Create a temporary source factory without an SDK resolver | |
| 538 // for resolving "include:" directives in analysis options files. | |
| 539 SourceFactory tempSourceFactory = _chooseUriResolutionPolicy( | |
| 540 options, embedderMap, packageInfo, summaryDataStore, false, null); | |
| 541 | |
| 542 AnalysisOptionsImpl analysisOptions = | |
| 543 createAnalysisOptions(resourceProvider, tempSourceFactory, options); | |
| 544 analysisOptions.analyzeFunctionBodiesPredicate = | |
| 545 _chooseDietParsingPolicy(options); | |
| 546 | |
| 537 // Once options and embedders are processed, setup the SDK. | 547 // Once options and embedders are processed, setup the SDK. |
| 538 _setupSdk(options, useSummaries); | 548 _setupSdk(options, useSummaries, analysisOptions); |
| 539 | 549 |
| 540 PackageBundle sdkBundle = sdk.getLinkedBundle(); | 550 PackageBundle sdkBundle = sdk.getLinkedBundle(); |
| 541 if (sdkBundle != null) { | 551 if (sdkBundle != null) { |
| 542 summaryDataStore.addBundle(null, sdkBundle); | 552 summaryDataStore.addBundle(null, sdkBundle); |
| 543 } | 553 } |
| 544 | 554 |
| 545 // Choose a package resolution policy and a diet parsing policy based on | 555 // Choose a package resolution policy and a diet parsing policy based on |
| 546 // the command-line options. | 556 // the command-line options. |
| 547 SourceFactory sourceFactory = _chooseUriResolutionPolicy( | 557 SourceFactory sourceFactory = _chooseUriResolutionPolicy(options, |
| 548 options, embedderMap, packageInfo, summaryDataStore); | 558 embedderMap, packageInfo, summaryDataStore, true, analysisOptions); |
| 549 | 559 |
| 550 AnalyzeFunctionBodiesPredicate dietParsingPolicy = | 560 // Create a context. |
| 551 _chooseDietParsingPolicy(options); | 561 _context = AnalysisEngine.instance.createAnalysisContext(); |
| 552 setAnalysisContextOptions( | 562 setupAnalysisContext(_context, options, analysisOptions); |
| 553 resourceProvider, sourceFactory, _context, options, | |
| 554 (AnalysisOptionsImpl contextOptions) { | |
| 555 contextOptions.analyzeFunctionBodiesPredicate = dietParsingPolicy; | |
| 556 }); | |
| 557 | |
| 558 _context.sourceFactory = sourceFactory; | 563 _context.sourceFactory = sourceFactory; |
| 559 | 564 |
| 560 if (options.enableNewAnalysisDriver) { | 565 if (options.enableNewAnalysisDriver) { |
| 561 PerformanceLog log = new PerformanceLog(null); | 566 PerformanceLog log = new PerformanceLog(null); |
| 562 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); | 567 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); |
| 563 analysisDriver = new AnalysisDriver( | 568 analysisDriver = new AnalysisDriver( |
| 564 scheduler, | 569 scheduler, |
| 565 log, | 570 log, |
| 566 resourceProvider, | 571 resourceProvider, |
| 567 analysisDriverByteStore, | 572 analysisDriverByteStore, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 ErrorSeverity errorSeverity = await analyzer.analyze(); | 684 ErrorSeverity errorSeverity = await analyzer.analyze(); |
| 680 if (errorSeverity == ErrorSeverity.ERROR) { | 685 if (errorSeverity == ErrorSeverity.ERROR) { |
| 681 io.exitCode = errorSeverity.ordinal; | 686 io.exitCode = errorSeverity.ordinal; |
| 682 } | 687 } |
| 683 if (options.warningsAreFatal && errorSeverity == ErrorSeverity.WARNING) { | 688 if (options.warningsAreFatal && errorSeverity == ErrorSeverity.WARNING) { |
| 684 io.exitCode = errorSeverity.ordinal; | 689 io.exitCode = errorSeverity.ordinal; |
| 685 } | 690 } |
| 686 return errorSeverity; | 691 return errorSeverity; |
| 687 } | 692 } |
| 688 | 693 |
| 689 void _setupSdk(CommandLineOptions options, bool useSummaries) { | 694 void _setupSdk(CommandLineOptions options, bool useSummaries, |
| 695 AnalysisOptions analysisOptions) { | |
| 690 if (sdk == null) { | 696 if (sdk == null) { |
| 691 if (options.dartSdkSummaryPath != null) { | 697 if (options.dartSdkSummaryPath != null) { |
| 692 sdk = new SummaryBasedDartSdk( | 698 sdk = new SummaryBasedDartSdk( |
| 693 options.dartSdkSummaryPath, options.strongMode); | 699 options.dartSdkSummaryPath, options.strongMode); |
| 694 } else { | 700 } else { |
| 695 String dartSdkPath = options.dartSdkPath; | 701 String dartSdkPath = options.dartSdkPath; |
| 696 FolderBasedDartSdk dartSdk = new FolderBasedDartSdk(resourceProvider, | 702 FolderBasedDartSdk dartSdk = new FolderBasedDartSdk(resourceProvider, |
| 697 resourceProvider.getFolder(dartSdkPath), options.strongMode); | 703 resourceProvider.getFolder(dartSdkPath), options.strongMode); |
| 698 dartSdk.useSummary = useSummaries && | 704 dartSdk.useSummary = useSummaries && |
| 699 options.sourceFiles.every((String sourcePath) { | 705 options.sourceFiles.every((String sourcePath) { |
| 700 sourcePath = path.absolute(sourcePath); | 706 sourcePath = path.absolute(sourcePath); |
| 701 sourcePath = path.normalize(sourcePath); | 707 sourcePath = path.normalize(sourcePath); |
| 702 return !path.isWithin(dartSdkPath, sourcePath); | 708 return !path.isWithin(dartSdkPath, sourcePath); |
| 703 }); | 709 }); |
| 704 | 710 dartSdk.analysisOptions = analysisOptions; |
| 705 dartSdk.analysisOptions = context.analysisOptions; | |
| 706 sdk = dartSdk; | 711 sdk = dartSdk; |
| 707 } | 712 } |
| 708 } | 713 } |
| 709 } | 714 } |
| 710 | 715 |
| 711 static AnalysisOptionsImpl createAnalysisOptionsForCommandLineOptions( | 716 static AnalysisOptionsImpl createAnalysisOptionsForCommandLineOptions( |
| 712 CommandLineOptions options) { | 717 CommandLineOptions options) { |
| 713 AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl(); | 718 AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl(); |
| 714 contextOptions.trackCacheDependencies = false; | 719 contextOptions.trackCacheDependencies = false; |
| 715 contextOptions.disableCacheFlushing = options.disableCacheFlushing; | 720 contextOptions.disableCacheFlushing = options.disableCacheFlushing; |
| 716 contextOptions.hint = !options.disableHints; | 721 contextOptions.hint = !options.disableHints; |
| 717 contextOptions.enableStrictCallChecks = options.enableStrictCallChecks; | 722 contextOptions.enableStrictCallChecks = options.enableStrictCallChecks; |
| 718 contextOptions.enableSuperMixins = options.enableSuperMixins; | 723 contextOptions.enableSuperMixins = options.enableSuperMixins; |
| 719 contextOptions.generateImplicitErrors = options.showPackageWarnings; | 724 contextOptions.generateImplicitErrors = options.showPackageWarnings; |
| 720 contextOptions.generateSdkErrors = options.showSdkWarnings; | 725 contextOptions.generateSdkErrors = options.showSdkWarnings; |
| 721 contextOptions.lint = options.lints; | 726 contextOptions.lint = options.lints; |
| 722 contextOptions.strongMode = options.strongMode; | 727 contextOptions.strongMode = options.strongMode; |
| 723 contextOptions.implicitCasts = options.implicitCasts; | 728 contextOptions.implicitCasts = options.implicitCasts; |
| 724 contextOptions.implicitDynamic = options.implicitDynamic; | 729 contextOptions.implicitDynamic = options.implicitDynamic; |
| 725 return contextOptions; | 730 return contextOptions; |
| 726 } | 731 } |
| 727 | 732 |
| 733 static AnalysisOptionsImpl createAnalysisOptions( | |
| 734 file_system.ResourceProvider resourceProvider, | |
| 735 SourceFactory sourceFactory, | |
| 736 CommandLineOptions options) { | |
| 737 // Prepare context options. | |
| 738 AnalysisOptionsImpl analysisOptions = | |
| 739 createAnalysisOptionsForCommandLineOptions(options); | |
| 740 | |
| 741 // Process analysis options file (and notify all interested parties). | |
| 742 _processAnalysisOptions( | |
| 743 resourceProvider, sourceFactory, analysisOptions, options); | |
| 744 return analysisOptions; | |
| 745 } | |
| 746 | |
| 728 static void setAnalysisContextOptions( | 747 static void setAnalysisContextOptions( |
| 729 file_system.ResourceProvider resourceProvider, | 748 file_system.ResourceProvider resourceProvider, |
| 730 SourceFactory sourceFactory, | 749 SourceFactory sourceFactory, |
| 731 AnalysisContext context, | 750 AnalysisContext context, |
| 732 CommandLineOptions options, | 751 CommandLineOptions options, |
| 733 void configureContextOptions(AnalysisOptionsImpl contextOptions)) { | 752 void configureContextOptions(AnalysisOptionsImpl contextOptions)) { |
| 753 AnalysisOptionsImpl analysisOptions = | |
| 754 createAnalysisOptions(resourceProvider, sourceFactory, options); | |
| 755 configureContextOptions(analysisOptions); | |
| 756 setupAnalysisContext(context, options, analysisOptions); | |
| 757 } | |
| 758 | |
| 759 static void setupAnalysisContext(AnalysisContext context, | |
| 760 CommandLineOptions options, AnalysisOptionsImpl analysisOptions) { | |
| 734 Map<String, String> definedVariables = options.definedVariables; | 761 Map<String, String> definedVariables = options.definedVariables; |
| 735 if (definedVariables.isNotEmpty) { | 762 if (definedVariables.isNotEmpty) { |
| 736 DeclaredVariables declaredVariables = context.declaredVariables; | 763 DeclaredVariables declaredVariables = context.declaredVariables; |
| 737 definedVariables.forEach((String variableName, String value) { | 764 definedVariables.forEach((String variableName, String value) { |
| 738 declaredVariables.define(variableName, value); | 765 declaredVariables.define(variableName, value); |
| 739 }); | 766 }); |
| 740 } | 767 } |
| 741 | 768 |
| 742 if (options.log) { | 769 if (options.log) { |
| 743 AnalysisEngine.instance.logger = new StdLogger(); | 770 AnalysisEngine.instance.logger = new StdLogger(); |
| 744 } | 771 } |
| 745 | 772 |
| 746 // Prepare context options. | |
| 747 AnalysisOptionsImpl contextOptions = | |
| 748 createAnalysisOptionsForCommandLineOptions(options); | |
| 749 configureContextOptions(contextOptions); | |
| 750 | |
| 751 // Set context options. | 773 // Set context options. |
| 752 context.analysisOptions = contextOptions; | 774 context.analysisOptions = analysisOptions; |
| 753 | |
| 754 // Process analysis options file (and notify all interested parties). | |
| 755 _processAnalysisOptions(resourceProvider, sourceFactory, context, options); | |
| 756 } | 775 } |
| 757 | 776 |
| 758 /// Perform a deep comparison of two string lists. | 777 /// Perform a deep comparison of two string lists. |
| 759 static bool _equalLists(List<String> l1, List<String> l2) { | 778 static bool _equalLists(List<String> l1, List<String> l2) { |
| 760 if (l1.length != l2.length) { | 779 if (l1.length != l2.length) { |
| 761 return false; | 780 return false; |
| 762 } | 781 } |
| 763 for (int i = 0; i < l1.length; i++) { | 782 for (int i = 0; i < l1.length; i++) { |
| 764 if (l1[i] != l2[i]) { | 783 if (l1[i] != l2[i]) { |
| 765 return false; | 784 return false; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 return file; | 822 return file; |
| 804 } | 823 } |
| 805 | 824 |
| 806 /// Convert [sourcePath] into an absolute path. | 825 /// Convert [sourcePath] into an absolute path. |
| 807 static String _normalizeSourcePath(String sourcePath) => | 826 static String _normalizeSourcePath(String sourcePath) => |
| 808 path.normalize(new io.File(sourcePath).absolute.path); | 827 path.normalize(new io.File(sourcePath).absolute.path); |
| 809 | 828 |
| 810 static void _processAnalysisOptions( | 829 static void _processAnalysisOptions( |
| 811 file_system.ResourceProvider resourceProvider, | 830 file_system.ResourceProvider resourceProvider, |
| 812 SourceFactory sourceFactory, | 831 SourceFactory sourceFactory, |
| 813 AnalysisContext context, | 832 AnalysisOptionsImpl analysisOptions, |
| 814 CommandLineOptions options) { | 833 CommandLineOptions options) { |
| 815 file_system.File file = _getOptionsFile(resourceProvider, options); | 834 file_system.File file = _getOptionsFile(resourceProvider, options); |
| 816 | 835 |
| 817 AnalysisOptionsProvider analysisOptionsProvider = | 836 AnalysisOptionsProvider analysisOptionsProvider = |
| 818 new AnalysisOptionsProvider(sourceFactory); | 837 new AnalysisOptionsProvider(sourceFactory); |
| 819 Map<String, YamlNode> optionMap = | 838 Map<String, YamlNode> optionMap = |
| 820 analysisOptionsProvider.getOptionsFromFile(file); | 839 analysisOptionsProvider.getOptionsFromFile(file); |
| 821 | 840 |
| 822 // Fill in lint rule defaults in case lints are enabled and rules are | 841 // Fill in lint rule defaults in case lints are enabled and rules are |
| 823 // not specified in an options file. | 842 // not specified in an options file. |
| 824 if (options.lints && !containsLintRuleEntry(optionMap)) { | 843 if (options.lints && !containsLintRuleEntry(optionMap)) { |
| 825 setLints(context, Registry.ruleRegistry.defaultRules); | 844 analysisOptions.lintRules = Registry.ruleRegistry.defaultRules; |
| 826 } | 845 } |
| 827 | 846 |
| 828 // Ask engine to further process options. | 847 // Ask engine to further process options. |
| 829 if (optionMap != null) { | 848 if (optionMap != null) { |
| 830 applyToAnalysisOptions(context.analysisOptions, optionMap); | 849 applyToAnalysisOptions(analysisOptions, optionMap); |
| 831 } | 850 } |
| 832 } | 851 } |
| 833 } | 852 } |
| 834 | 853 |
| 835 /// Provides a framework to read command line options from stdin and feed them | 854 /// Provides a framework to read command line options from stdin and feed them |
| 836 /// to a callback. | 855 /// to a callback. |
| 837 class _BatchRunner { | 856 class _BatchRunner { |
| 838 /// Run the tool in 'batch' mode, receiving command lines through stdin and | 857 /// Run the tool in 'batch' mode, receiving command lines through stdin and |
| 839 /// returning pass/fail status through stdout. This feature is intended for | 858 /// returning pass/fail status through stdout. This feature is intended for |
| 840 /// use in unit testing. | 859 /// use in unit testing. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 for (var package in packages) { | 935 for (var package in packages) { |
| 917 var packageName = path.basename(package.path); | 936 var packageName = path.basename(package.path); |
| 918 var realPath = package.resolveSymbolicLinksSync(); | 937 var realPath = package.resolveSymbolicLinksSync(); |
| 919 result[packageName] = [ | 938 result[packageName] = [ |
| 920 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 939 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 921 ]; | 940 ]; |
| 922 } | 941 } |
| 923 return result; | 942 return result; |
| 924 } | 943 } |
| 925 } | 944 } |
| OLD | NEW |