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

Unified Diff: pkg/analyzer/lib/source/analysis_options_provider.dart

Issue 2947743002: Add support to pass the location of the analysis options file to plugins (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « pkg/analysis_server/test/src/plugin/plugin_manager_test.dart ('k') | pkg/analyzer_plugin/doc/api.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/source/analysis_options_provider.dart
diff --git a/pkg/analyzer/lib/source/analysis_options_provider.dart b/pkg/analyzer/lib/source/analysis_options_provider.dart
index 90cf8a123bb284ed942cd722844ce81f153db382..265d7e82d3e93a1886835f62acc872f14f7797b1 100644
--- a/pkg/analyzer/lib/source/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/source/analysis_options_provider.dart
@@ -30,7 +30,16 @@ class AnalysisOptionsProvider {
/// and remove the include directive from the resulting options map.
/// Return an empty options map if the file does not exist.
Map<String, YamlNode> getOptions(Folder root, {bool crawlUp: false}) {
- Resource resource;
+ return getOptionsFromFile(getOptionsFile(root, crawlUp: crawlUp));
+ }
+
+ /// Return the analysis options file from which options should be read, or
+ /// `null` if there is no analysis options file for code in the given [root].
+ ///
+ /// The given [root] directory will be searched first. If no file is found and
+ /// if [crawlUp] is `true`, then enclosing directories will be searched.
+ File getOptionsFile(Folder root, {bool crawlUp: false}) {
+ Resource resource = null;
for (Folder folder = root; folder != null; folder = folder.parent) {
resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE);
if (resource.exists) {
@@ -41,7 +50,7 @@ class AnalysisOptionsProvider {
break;
}
}
- return getOptionsFromFile(resource);
+ return resource is File ? resource : null;
}
/// Provide the options found in [file].
« no previous file with comments | « pkg/analysis_server/test/src/plugin/plugin_manager_test.dart ('k') | pkg/analyzer_plugin/doc/api.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698