| 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'; | |
| 16 import 'package:analyzer/plugin/resolver_provider.dart'; | 15 import 'package:analyzer/plugin/resolver_provider.dart'; |
| 17 import 'package:analyzer/source/analysis_options_provider.dart'; | 16 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 18 import 'package:analyzer/source/package_map_provider.dart'; | 17 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'; | 19 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 21 import 'package:analyzer/source/sdk_ext.dart'; | 20 import 'package:analyzer/source/sdk_ext.dart'; |
| 22 import 'package:analyzer/src/context/builder.dart'; | 21 import 'package:analyzer/src/context/builder.dart'; |
| 23 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 22 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 24 import 'package:analyzer/src/generated/constant.dart'; | 23 import 'package:analyzer/src/generated/constant.dart'; |
| 25 import 'package:analyzer/src/generated/engine.dart'; | 24 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 /// Convert [sourcePath] into an absolute path. | 762 /// Convert [sourcePath] into an absolute path. |
| 764 static String _normalizeSourcePath(String sourcePath) => | 763 static String _normalizeSourcePath(String sourcePath) => |
| 765 path.normalize(new io.File(sourcePath).absolute.path); | 764 path.normalize(new io.File(sourcePath).absolute.path); |
| 766 | 765 |
| 767 static void _processAnalysisOptions( | 766 static void _processAnalysisOptions( |
| 768 file_system.ResourceProvider resourceProvider, | 767 file_system.ResourceProvider resourceProvider, |
| 769 SourceFactory sourceFactory, | 768 SourceFactory sourceFactory, |
| 770 AnalysisContext context, | 769 AnalysisContext context, |
| 771 CommandLineOptions options) { | 770 CommandLineOptions options) { |
| 772 file_system.File file = _getOptionsFile(resourceProvider, options); | 771 file_system.File file = _getOptionsFile(resourceProvider, options); |
| 773 List<OptionsProcessor> optionsProcessors = | |
| 774 AnalysisEngine.instance.optionsPlugin.optionsProcessors; | |
| 775 | 772 |
| 776 try { | 773 AnalysisOptionsProvider analysisOptionsProvider = |
| 777 AnalysisOptionsProvider analysisOptionsProvider = | 774 new AnalysisOptionsProvider(sourceFactory); |
| 778 new AnalysisOptionsProvider(sourceFactory); | 775 Map<String, YamlNode> optionMap = |
| 779 Map<String, YamlNode> optionMap = | 776 analysisOptionsProvider.getOptionsFromFile(file); |
| 780 analysisOptionsProvider.getOptionsFromFile(file); | |
| 781 optionsProcessors.forEach( | |
| 782 (OptionsProcessor p) => p.optionsProcessed(context, optionMap)); | |
| 783 | 777 |
| 784 // Fill in lint rule defaults in case lints are enabled and rules are | 778 // Fill in lint rule defaults in case lints are enabled and rules are |
| 785 // not specified in an options file. | 779 // not specified in an options file. |
| 786 if (options.lints && !containsLintRuleEntry(optionMap)) { | 780 if (options.lints && !containsLintRuleEntry(optionMap)) { |
| 787 setLints(context, linterPlugin.contributedRules); | 781 setLints(context, linterPlugin.contributedRules); |
| 788 } | 782 } |
| 789 | 783 |
| 790 // Ask engine to further process options. | 784 // Ask engine to further process options. |
| 791 if (optionMap != null) { | 785 if (optionMap != null) { |
| 792 configureContextOptions(context, optionMap); | 786 applyToAnalysisOptions(context.analysisOptions, optionMap); |
| 793 } | |
| 794 } on Exception catch (e) { | |
| 795 optionsProcessors.forEach((OptionsProcessor p) => p.onError(e)); | |
| 796 } | 787 } |
| 797 } | 788 } |
| 798 } | 789 } |
| 799 | 790 |
| 800 /// Provides a framework to read command line options from stdin and feed them | 791 /// Provides a framework to read command line options from stdin and feed them |
| 801 /// to a callback. | 792 /// to a callback. |
| 802 class _BatchRunner { | 793 class _BatchRunner { |
| 803 /// Run the tool in 'batch' mode, receiving command lines through stdin and | 794 /// Run the tool in 'batch' mode, receiving command lines through stdin and |
| 804 /// returning pass/fail status through stdout. This feature is intended for | 795 /// returning pass/fail status through stdout. This feature is intended for |
| 805 /// use in unit testing. | 796 /// use in unit testing. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 for (var package in packages) { | 872 for (var package in packages) { |
| 882 var packageName = path.basename(package.path); | 873 var packageName = path.basename(package.path); |
| 883 var realPath = package.resolveSymbolicLinksSync(); | 874 var realPath = package.resolveSymbolicLinksSync(); |
| 884 result[packageName] = [ | 875 result[packageName] = [ |
| 885 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 876 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 886 ]; | 877 ]; |
| 887 } | 878 } |
| 888 return result; | 879 return result; |
| 889 } | 880 } |
| 890 } | 881 } |
| OLD | NEW |