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

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

Issue 1425393002: Map merging. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Runtime type check fixes. Created 5 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/util/yaml.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 529e52f36539d7be4bba5aacb3d9af5fa50bdacd..97be54b9c1ad40636851577098d40a35aeed2d28 100644
--- a/pkg/analyzer/lib/source/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/source/analysis_options_provider.dart
@@ -6,6 +6,7 @@ library source.analysis_options_provider;
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/util/yaml.dart';
import 'package:source_span/source_span.dart';
import 'package:yaml/yaml.dart';
@@ -66,6 +67,22 @@ class AnalysisOptionsProvider {
return options;
}
+ /// Merge the given options contents where the values in [defaults] may be
+ /// overridden by [overrides].
+ ///
+ /// Some notes about merge semantics:
+ ///
+ /// * lists are merged (without duplicates).
+ /// * lists of scalar values can be promoted to simple maps when merged with
+ /// maps of strings to booleans (e.g., ['opt1', 'opt2'] becomes
+ /// {'opt1': true, 'opt2': true}.
+ /// * maps are merged recursively.
+ /// * if map values cannot be merged, the overriding value is taken.
+ ///
+ Map<String, YamlNode> merge(
+ Map<String, YamlNode> defaults, Map<String, YamlNode> overrides) =>
+ new Merger().merge(defaults, overrides);
+
/// Read the contents of [file] as a string.
/// Returns null if file does not exist.
String _readAnalysisOptionsFile(File file) {
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/util/yaml.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698