| Index: pkg/analyzer/lib/src/context/builder.dart
|
| diff --git a/pkg/analyzer/lib/src/context/builder.dart b/pkg/analyzer/lib/src/context/builder.dart
|
| index 0bd531e4e9e197ddc57593fad45b9cafe9a96c34..7a833865f78dd1ec1fa15a9926dc6a1b32e40138 100644
|
| --- a/pkg/analyzer/lib/src/context/builder.dart
|
| +++ b/pkg/analyzer/lib/src/context/builder.dart
|
| @@ -13,7 +13,10 @@ import 'package:analyzer/plugin/resolver_provider.dart';
|
| import 'package:analyzer/source/analysis_options_provider.dart';
|
| import 'package:analyzer/source/package_map_resolver.dart';
|
| import 'package:analyzer/src/command_line/arguments.dart'
|
| - show applyAnalysisOptionFlags;
|
| + show
|
| + applyAnalysisOptionFlags,
|
| + bazelAnalysisOptionsPath,
|
| + flutterAnalysisOptionsPath;
|
| import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
| import 'package:analyzer/src/dart/analysis/driver.dart'
|
| show AnalysisDriver, AnalysisDriverScheduler, PerformanceLog;
|
| @@ -398,23 +401,24 @@ class ContextBuilder {
|
| }
|
| } else {
|
| // Search for the default analysis options
|
| + // unless explicitly directed not to do so.
|
| Source source;
|
| - // TODO(danrubel) determine if bazel or gn project depends upon flutter
|
| - if (workspace.hasFlutterDependency) {
|
| - source =
|
| - sourceFactory.forUri('package:flutter/analysis_options_user.yaml');
|
| - }
|
| - if (source == null || !source.exists()) {
|
| - source =
|
| - sourceFactory.forUri('package:dart.analysis_options/default.yaml');
|
| - }
|
| - if (source.exists()) {
|
| - try {
|
| - optionMap = optionsProvider.getOptionsFromSource(source);
|
| - verbose('Loaded analysis options from ${source.fullName}');
|
| - } catch (e) {
|
| - // Ignore exceptions thrown while trying to load the options file.
|
| - verbose('Exception: $e\n when loading ${source.fullName}');
|
| + if (builderOptions.packageDefaultAnalysisOptions) {
|
| + // TODO(danrubel) determine if bazel or gn project depends upon flutter
|
| + if (workspace.hasFlutterDependency) {
|
| + source = sourceFactory.forUri(flutterAnalysisOptionsPath);
|
| + }
|
| + if (source == null || !source.exists()) {
|
| + source = sourceFactory.forUri(bazelAnalysisOptionsPath);
|
| + }
|
| + if (source.exists()) {
|
| + try {
|
| + optionMap = optionsProvider.getOptionsFromSource(source);
|
| + verbose('Loaded analysis options from ${source.fullName}');
|
| + } catch (e) {
|
| + // Ignore exceptions thrown while trying to load the options file.
|
| + verbose('Exception: $e\n when loading ${source.fullName}');
|
| + }
|
| }
|
| }
|
| }
|
| @@ -628,6 +632,11 @@ class ContextBuilderOptions {
|
| String defaultPackagesDirectoryPath;
|
|
|
| /**
|
| + * Allow Flutter and bazel default analysis options to be used.
|
| + */
|
| + bool packageDefaultAnalysisOptions = true;
|
| +
|
| + /**
|
| * Initialize a newly created set of options
|
| */
|
| ContextBuilderOptions();
|
|
|