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.src.context.context_builder; | 5 library analyzer.src.context.context_builder; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:core'; | 8 import 'dart:core'; |
9 | 9 |
10 import 'package:analyzer/context/context_root.dart'; | 10 import 'package:analyzer/context/context_root.dart'; |
(...skipping 11 matching lines...) Expand all Loading... |
22 show AnalysisDriver, AnalysisDriverScheduler; | 22 show AnalysisDriver, AnalysisDriverScheduler; |
23 import 'package:analyzer/src/dart/analysis/file_state.dart'; | 23 import 'package:analyzer/src/dart/analysis/file_state.dart'; |
24 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 24 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
25 import 'package:analyzer/src/generated/bazel.dart'; | 25 import 'package:analyzer/src/generated/bazel.dart'; |
26 import 'package:analyzer/src/generated/engine.dart'; | 26 import 'package:analyzer/src/generated/engine.dart'; |
27 import 'package:analyzer/src/generated/gn.dart'; | 27 import 'package:analyzer/src/generated/gn.dart'; |
28 import 'package:analyzer/src/generated/sdk.dart'; | 28 import 'package:analyzer/src/generated/sdk.dart'; |
29 import 'package:analyzer/src/generated/source.dart'; | 29 import 'package:analyzer/src/generated/source.dart'; |
30 import 'package:analyzer/src/generated/workspace.dart'; | 30 import 'package:analyzer/src/generated/workspace.dart'; |
31 import 'package:analyzer/src/lint/registry.dart'; | 31 import 'package:analyzer/src/lint/registry.dart'; |
| 32 import 'package:analyzer/src/services/lint.dart'; |
32 import 'package:analyzer/src/summary/summary_sdk.dart'; | 33 import 'package:analyzer/src/summary/summary_sdk.dart'; |
33 import 'package:analyzer/src/task/options.dart'; | 34 import 'package:analyzer/src/task/options.dart'; |
34 import 'package:args/args.dart'; | 35 import 'package:args/args.dart'; |
35 import 'package:front_end/src/base/performace_logger.dart'; | 36 import 'package:front_end/src/base/performace_logger.dart'; |
36 import 'package:front_end/src/incremental/byte_store.dart'; | 37 import 'package:front_end/src/incremental/byte_store.dart'; |
37 import 'package:package_config/packages.dart'; | 38 import 'package:package_config/packages.dart'; |
38 import 'package:package_config/packages_file.dart'; | 39 import 'package:package_config/packages_file.dart'; |
39 import 'package:package_config/src/packages_impl.dart'; | 40 import 'package:package_config/src/packages_impl.dart'; |
40 import 'package:path/src/context.dart'; | 41 import 'package:path/src/context.dart'; |
41 import 'package:yaml/yaml.dart'; | 42 import 'package:yaml/yaml.dart'; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 applyToAnalysisOptions(options, optionMap); | 452 applyToAnalysisOptions(options, optionMap); |
452 if (builderOptions.argResults != null) { | 453 if (builderOptions.argResults != null) { |
453 applyAnalysisOptionFlags(options, builderOptions.argResults, | 454 applyAnalysisOptionFlags(options, builderOptions.argResults, |
454 verbosePrint: verbosePrint); | 455 verbosePrint: verbosePrint); |
455 // If lints turned on but none specified, then enable default lints | 456 // If lints turned on but none specified, then enable default lints |
456 if (options.lint && options.lintRules.isEmpty) { | 457 if (options.lint && options.lintRules.isEmpty) { |
457 options.lintRules = Registry.ruleRegistry.defaultRules; | 458 options.lintRules = Registry.ruleRegistry.defaultRules; |
458 verbose('Using default lint rules'); | 459 verbose('Using default lint rules'); |
459 } | 460 } |
460 } | 461 } |
| 462 if (ContextBuilderOptions.flutterRepo) { |
| 463 const lintName = 'public_member_api_docs'; |
| 464 Linter rule = options.lintRules.firstWhere( |
| 465 (Linter lint) => lint.name == lintName, |
| 466 orElse: () => null); |
| 467 if (rule == null) { |
| 468 rule = Registry.ruleRegistry |
| 469 .firstWhere((Linter lint) => lint.name == lintName); |
| 470 options.lintRules = new List.from(options.lintRules)..add(rule); |
| 471 } |
| 472 } |
461 } else { | 473 } else { |
462 verbose('Using default analysis options'); | 474 verbose('Using default analysis options'); |
463 } | 475 } |
464 return options; | 476 return options; |
465 } | 477 } |
466 | 478 |
467 /** | 479 /** |
468 * Return the analysis options file that should be used when analyzing code in | 480 * Return the analysis options file that should be used when analyzing code in |
469 * the directory with the given [path]. | 481 * the directory with the given [path]. |
470 */ | 482 */ |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 } | 614 } |
603 return false; | 615 return false; |
604 } | 616 } |
605 } | 617 } |
606 | 618 |
607 /** | 619 /** |
608 * Options used by a [ContextBuilder]. | 620 * Options used by a [ContextBuilder]. |
609 */ | 621 */ |
610 class ContextBuilderOptions { | 622 class ContextBuilderOptions { |
611 /** | 623 /** |
| 624 * A flag indicating that the flutter repository is being analyzed. |
| 625 * See comments in source for `flutter analyze --watch`. |
| 626 */ |
| 627 static bool flutterRepo = false; |
| 628 |
| 629 /** |
612 * The results of parsing the command line arguments as defined by | 630 * The results of parsing the command line arguments as defined by |
613 * [defineAnalysisArguments] or `null` if none. | 631 * [defineAnalysisArguments] or `null` if none. |
614 */ | 632 */ |
615 ArgResults argResults; | 633 ArgResults argResults; |
616 | 634 |
617 /** | 635 /** |
618 * The file path of the file containing the summary of the SDK that should be | 636 * The file path of the file containing the summary of the SDK that should be |
619 * used to "analyze" the SDK. This option should only be specified by | 637 * used to "analyze" the SDK. This option should only be specified by |
620 * command-line tools such as 'dartanalyzer' or 'ddc'. | 638 * command-line tools such as 'dartanalyzer' or 'ddc'. |
621 */ | 639 */ |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 throw new ArgumentError('not absolute: $path'); | 843 throw new ArgumentError('not absolute: $path'); |
826 } | 844 } |
827 path = context.normalize(path); | 845 path = context.normalize(path); |
828 Resource resource = provider.getResource(path); | 846 Resource resource = provider.getResource(path); |
829 if (resource is File) { | 847 if (resource is File) { |
830 path = resource.parent.path; | 848 path = resource.parent.path; |
831 } | 849 } |
832 return new _BasicWorkspace._(provider, path, builder); | 850 return new _BasicWorkspace._(provider, path, builder); |
833 } | 851 } |
834 } | 852 } |
OLD | NEW |