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

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

Issue 1245513002: Refactor AnalysisOptionsProvider (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | pkg/analyzer/pubspec.yaml » ('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 e34812a988c227a0cfda3e424fb1f6dddddf65be..a3ac86bc4a8cb1e72c649fb3069c23f3f718abb1 100644
--- a/pkg/analyzer/lib/source/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/source/analysis_options_provider.dart
@@ -12,11 +12,25 @@ class AnalysisOptionsProvider {
/// The name of the analysis options source file.
static const String ANALYSIS_OPTIONS_NAME = '.analysis_options';
- /// Provide the options found in the [ANALYSIS_OPTIONS_NAME] file located in
- /// [folder]. Return an empty options map if the file does not exist.
+ /// Provide the options found in [root]/[ANALYSIS_OPTIONS_NAME].
+ /// Return an empty options map if the file does not exist.
Map<String, YamlNode> getOptions(Folder root) {
+ var optionsSource =
+ _readAnalysisOptionsFile(root.getChild(ANALYSIS_OPTIONS_NAME));
+ return getOptionsFromString(optionsSource);
+ }
+
+ /// Provide the options found in [file].
+ /// Return an empty options map if the file does not exist.
+ Map<String, YamlNode> getOptionsFromFile(File file) {
+ var optionsSource = _readAnalysisOptionsFile(file);
+ return getOptionsFromString(optionsSource);
+ }
+
+ /// Provide the options found in [optionsSource].
+ /// Return an empty options map if the source is null.
+ Map<String, YamlNode> getOptionsFromString(String optionsSource) {
var options = <String, YamlNode>{};
- var optionsSource = _readAnalysisOptionsFile(root);
if (optionsSource == null) {
return options;
}
@@ -38,10 +52,9 @@ class AnalysisOptionsProvider {
return options;
}
- /// Read the contents of [root]/[ANALYSIS_OPTIONS_NAME] as a string.
+ /// Read the contents of [file] as a string.
/// Returns null if file does not exist.
- String _readAnalysisOptionsFile(Folder root) {
- var file = root.getChild(ANALYSIS_OPTIONS_NAME);
+ String _readAnalysisOptionsFile(File file) {
try {
return file.readAsStringSync();
} on FileSystemException {
« no previous file with comments | « no previous file | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698