| 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 11 matching lines...) Expand all Loading... |
| 22 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 22 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 23 import 'package:analyzer/src/generated/constant.dart'; | 23 import 'package:analyzer/src/generated/constant.dart'; |
| 24 import 'package:analyzer/src/generated/engine.dart'; | 24 import 'package:analyzer/src/generated/engine.dart'; |
| 25 import 'package:analyzer/src/generated/interner.dart'; | 25 import 'package:analyzer/src/generated/interner.dart'; |
| 26 import 'package:analyzer/src/generated/java_engine.dart'; | 26 import 'package:analyzer/src/generated/java_engine.dart'; |
| 27 import 'package:analyzer/src/generated/sdk.dart'; | 27 import 'package:analyzer/src/generated/sdk.dart'; |
| 28 import 'package:analyzer/src/generated/source.dart'; | 28 import 'package:analyzer/src/generated/source.dart'; |
| 29 import 'package:analyzer/src/generated/source_io.dart'; | 29 import 'package:analyzer/src/generated/source_io.dart'; |
| 30 import 'package:analyzer/src/generated/utilities_general.dart' | 30 import 'package:analyzer/src/generated/utilities_general.dart' |
| 31 show PerformanceTag; | 31 show PerformanceTag; |
| 32 import 'package:analyzer/src/lint/registry.dart'; |
| 32 import 'package:analyzer/src/services/lint.dart'; | 33 import 'package:analyzer/src/services/lint.dart'; |
| 33 import 'package:analyzer/src/source/source_resource.dart'; | 34 import 'package:analyzer/src/source/source_resource.dart'; |
| 34 import 'package:analyzer/src/summary/package_bundle_reader.dart'; | 35 import 'package:analyzer/src/summary/package_bundle_reader.dart'; |
| 35 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; | 36 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; |
| 36 import 'package:analyzer/src/task/options.dart'; | 37 import 'package:analyzer/src/task/options.dart'; |
| 37 import 'package:analyzer_cli/src/analyzer_impl.dart'; | 38 import 'package:analyzer_cli/src/analyzer_impl.dart'; |
| 38 import 'package:analyzer_cli/src/build_mode.dart'; | 39 import 'package:analyzer_cli/src/build_mode.dart'; |
| 39 import 'package:analyzer_cli/src/error_formatter.dart'; | 40 import 'package:analyzer_cli/src/error_formatter.dart'; |
| 40 import 'package:analyzer_cli/src/options.dart'; | 41 import 'package:analyzer_cli/src/options.dart'; |
| 41 import 'package:analyzer_cli/src/perf_report.dart'; | 42 import 'package:analyzer_cli/src/perf_report.dart'; |
| 42 import 'package:analyzer_cli/starter.dart'; | 43 import 'package:analyzer_cli/starter.dart'; |
| 43 import 'package:linter/src/plugin/linter_plugin.dart'; | |
| 44 import 'package:linter/src/rules.dart' as linter; | 44 import 'package:linter/src/rules.dart' as linter; |
| 45 import 'package:package_config/discovery.dart' as pkg_discovery; | 45 import 'package:package_config/discovery.dart' as pkg_discovery; |
| 46 import 'package:package_config/packages.dart' show Packages; | 46 import 'package:package_config/packages.dart' show Packages; |
| 47 import 'package:package_config/packages_file.dart' as pkgfile show parse; | 47 import 'package:package_config/packages_file.dart' as pkgfile show parse; |
| 48 import 'package:package_config/src/packages_impl.dart' show MapPackages; | 48 import 'package:package_config/src/packages_impl.dart' show MapPackages; |
| 49 import 'package:path/path.dart' as path; | 49 import 'package:path/path.dart' as path; |
| 50 import 'package:plugin/manager.dart'; | 50 import 'package:plugin/manager.dart'; |
| 51 import 'package:plugin/plugin.dart'; | 51 import 'package:plugin/plugin.dart'; |
| 52 import 'package:yaml/yaml.dart'; | 52 import 'package:yaml/yaml.dart'; |
| 53 | 53 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 611 |
| 612 /// Returns `true` if this relative path is a hidden directory. | 612 /// Returns `true` if this relative path is a hidden directory. |
| 613 bool _isInHiddenDir(String relative) => | 613 bool _isInHiddenDir(String relative) => |
| 614 path.split(relative).any((part) => part.startsWith(".")); | 614 path.split(relative).any((part) => part.startsWith(".")); |
| 615 | 615 |
| 616 void _processPlugins() { | 616 void _processPlugins() { |
| 617 List<Plugin> plugins = <Plugin>[]; | 617 List<Plugin> plugins = <Plugin>[]; |
| 618 plugins.addAll(AnalysisEngine.instance.requiredPlugins); | 618 plugins.addAll(AnalysisEngine.instance.requiredPlugins); |
| 619 plugins.add(AnalysisEngine.instance.commandLinePlugin); | 619 plugins.add(AnalysisEngine.instance.commandLinePlugin); |
| 620 plugins.add(AnalysisEngine.instance.optionsPlugin); | 620 plugins.add(AnalysisEngine.instance.optionsPlugin); |
| 621 plugins.add(linterPlugin); | |
| 622 plugins.addAll(_userDefinedPlugins); | 621 plugins.addAll(_userDefinedPlugins); |
| 623 | 622 |
| 624 ExtensionManager manager = new ExtensionManager(); | 623 ExtensionManager manager = new ExtensionManager(); |
| 625 manager.processPlugins(plugins); | 624 manager.processPlugins(plugins); |
| 626 | 625 |
| 627 linter.registerLintRules(); | 626 linter.registerLintRules(); |
| 628 } | 627 } |
| 629 | 628 |
| 630 /// Analyze a single source. | 629 /// Analyze a single source. |
| 631 ErrorSeverity _runAnalyzer(Source source, CommandLineOptions options) { | 630 ErrorSeverity _runAnalyzer(Source source, CommandLineOptions options) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 file_system.File file = _getOptionsFile(resourceProvider, options); | 770 file_system.File file = _getOptionsFile(resourceProvider, options); |
| 772 | 771 |
| 773 AnalysisOptionsProvider analysisOptionsProvider = | 772 AnalysisOptionsProvider analysisOptionsProvider = |
| 774 new AnalysisOptionsProvider(sourceFactory); | 773 new AnalysisOptionsProvider(sourceFactory); |
| 775 Map<String, YamlNode> optionMap = | 774 Map<String, YamlNode> optionMap = |
| 776 analysisOptionsProvider.getOptionsFromFile(file); | 775 analysisOptionsProvider.getOptionsFromFile(file); |
| 777 | 776 |
| 778 // Fill in lint rule defaults in case lints are enabled and rules are | 777 // Fill in lint rule defaults in case lints are enabled and rules are |
| 779 // not specified in an options file. | 778 // not specified in an options file. |
| 780 if (options.lints && !containsLintRuleEntry(optionMap)) { | 779 if (options.lints && !containsLintRuleEntry(optionMap)) { |
| 781 setLints(context, linterPlugin.contributedRules); | 780 setLints(context, Registry.ruleRegistry.defaultRules); |
| 782 } | 781 } |
| 783 | 782 |
| 784 // Ask engine to further process options. | 783 // Ask engine to further process options. |
| 785 if (optionMap != null) { | 784 if (optionMap != null) { |
| 786 applyToAnalysisOptions(context.analysisOptions, optionMap); | 785 applyToAnalysisOptions(context.analysisOptions, optionMap); |
| 787 } | 786 } |
| 788 } | 787 } |
| 789 } | 788 } |
| 790 | 789 |
| 791 /// Provides a framework to read command line options from stdin and feed them | 790 /// Provides a framework to read command line options from stdin and feed them |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 for (var package in packages) { | 871 for (var package in packages) { |
| 873 var packageName = path.basename(package.path); | 872 var packageName = path.basename(package.path); |
| 874 var realPath = package.resolveSymbolicLinksSync(); | 873 var realPath = package.resolveSymbolicLinksSync(); |
| 875 result[packageName] = [ | 874 result[packageName] = [ |
| 876 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 875 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 877 ]; | 876 ]; |
| 878 } | 877 } |
| 879 return result; | 878 return result; |
| 880 } | 879 } |
| 881 } | 880 } |
| OLD | NEW |