Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: pkg/analyzer/lib/src/context/builder.dart

Issue 2745653012: enable/disable default package contributed analysis options (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
« no previous file with comments | « pkg/analyzer/lib/src/command_line/arguments.dart ('k') | pkg/analyzer/test/src/command_line/arguments_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698