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

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

Issue 2502233004: report errors in included options files (Closed)
Patch Set: merge Created 4 years, 1 month 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/lib/src/analysis_options/error/option_codes.dart » ('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 808c8353301b80cd4f71b208f34dd16ef53fc598..90cf8a123bb284ed942cd722844ce81f153db382 100644
--- a/pkg/analyzer/lib/source/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/source/analysis_options_provider.dart
@@ -10,6 +10,7 @@ import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/source/source_resource.dart';
+import 'package:analyzer/src/task/options.dart';
import 'package:analyzer/src/util/yaml.dart';
import 'package:source_span/source_span.dart';
import 'package:yaml/yaml.dart';
@@ -25,6 +26,8 @@ class AnalysisOptionsProvider {
/// Provide the options found in either
/// [root]/[AnalysisEngine.ANALYSIS_OPTIONS_FILE] or
/// [root]/[AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE].
+ /// Recursively merge options referenced by an include directive
+ /// 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;
@@ -42,17 +45,21 @@ class AnalysisOptionsProvider {
}
/// Provide the options found in [file].
+ /// Recursively merge options referenced by an include directive
+ /// and remove the include directive from the resulting options map.
/// Return an empty options map if the file does not exist.
Map<String, YamlNode> getOptionsFromFile(File file) {
return getOptionsFromSource(new FileSource(file));
}
/// Provide the options found in [source].
+ /// Recursively merge options referenced by an include directive
+ /// and remove the include directive from the resulting options map.
/// Return an empty options map if the file does not exist.
Map<String, YamlNode> getOptionsFromSource(Source source) {
Map<String, YamlNode> options =
getOptionsFromString(_readAnalysisOptions(source));
- YamlNode node = options.remove('include');
+ YamlNode node = options.remove(AnalyzerOptions.include);
if (sourceFactory != null && node is YamlScalar) {
var path = node.value;
if (path is String) {
@@ -64,6 +71,8 @@ class AnalysisOptionsProvider {
}
/// Provide the options found in [optionsSource].
+ /// An include directive, if present, will be left as-is,
+ /// and the referenced options will NOT be merged into the result.
/// Return an empty options map if the source is null.
Map<String, YamlNode> getOptionsFromString(String optionsSource) {
Map<String, YamlNode> options = <String, YamlNode>{};
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/analysis_options/error/option_codes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698