| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.test.src.context.context_builder_test; | 5 library analyzer.test.src.context.context_builder_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/source/package_map_resolver.dart'; | 9 import 'package:analyzer/source/package_map_resolver.dart'; |
| 10 import 'package:analyzer/src/command_line/arguments.dart'; | 10 import 'package:analyzer/src/command_line/arguments.dart'; |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 ''' | 732 ''' |
| 733 linter: | 733 linter: |
| 734 rules: | 734 rules: |
| 735 - mock_lint_rule | 735 - mock_lint_rule |
| 736 '''); | 736 '''); |
| 737 String projPath = resourceProvider.convertPath('/some/directory/path'); | 737 String projPath = resourceProvider.convertPath('/some/directory/path'); |
| 738 AnalysisOptions options = builder.getAnalysisOptions(projPath); | 738 AnalysisOptions options = builder.getAnalysisOptions(projPath); |
| 739 _expectEqualOptions(options, expected); | 739 _expectEqualOptions(options, expected); |
| 740 } | 740 } |
| 741 | 741 |
| 742 void test_getAnalysisOptions_default_flutter_disabled() { |
| 743 _defineMockLintRules(); |
| 744 ArgParser argParser = new ArgParser(); |
| 745 defineAnalysisArguments(argParser); |
| 746 ArgResults argResults = |
| 747 argParser.parse(['--no-$packageDefaultAnalysisOptions']); |
| 748 |
| 749 builderOptions = createContextBuilderOptions(argResults); |
| 750 expect(builderOptions.packageDefaultAnalysisOptions, isFalse); |
| 751 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache, |
| 752 options: builderOptions); |
| 753 |
| 754 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 755 |
| 756 String packagesFilePath = |
| 757 resourceProvider.convertPath('/some/directory/path/.packages'); |
| 758 createFile(packagesFilePath, 'flutter:/pkg/flutter/lib/'); |
| 759 String optionsFilePath = resourceProvider |
| 760 .convertPath('/pkg/flutter/lib/analysis_options_user.yaml'); |
| 761 createFile( |
| 762 optionsFilePath, |
| 763 ''' |
| 764 linter: |
| 765 rules: |
| 766 - mock_lint_rule |
| 767 '''); |
| 768 String projPath = resourceProvider.convertPath('/some/directory/path'); |
| 769 AnalysisOptions options = builder.getAnalysisOptions(projPath); |
| 770 _expectEqualOptions(options, expected); |
| 771 } |
| 772 |
| 742 void test_getAnalysisOptions_default_noOverrides() { | 773 void test_getAnalysisOptions_default_noOverrides() { |
| 743 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 774 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 744 defaultOptions.enableLazyAssignmentOperators = true; | 775 defaultOptions.enableLazyAssignmentOperators = true; |
| 745 builderOptions.defaultOptions = defaultOptions; | 776 builderOptions.defaultOptions = defaultOptions; |
| 746 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); | 777 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 747 expected.enableLazyAssignmentOperators = true; | 778 expected.enableLazyAssignmentOperators = true; |
| 748 String path = resourceProvider.convertPath('/some/directory/path'); | 779 String path = resourceProvider.convertPath('/some/directory/path'); |
| 749 String filePath = | 780 String filePath = |
| 750 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 781 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
| 751 resourceProvider.newFile( | 782 resourceProvider.newFile( |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 class _MockLintRule implements LintRule { | 1040 class _MockLintRule implements LintRule { |
| 1010 final String _name; | 1041 final String _name; |
| 1011 | 1042 |
| 1012 _MockLintRule(this._name); | 1043 _MockLintRule(this._name); |
| 1013 | 1044 |
| 1014 @override | 1045 @override |
| 1015 String get name => _name; | 1046 String get name => _name; |
| 1016 | 1047 |
| 1017 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 1048 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 1018 } | 1049 } |
| OLD | NEW |