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

Unified Diff: pkg/analyzer/lib/src/plugin/plugin_configuration.dart

Issue 1362033002: Plugin config format validation (and tests). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/plugin/plugin_configuration.dart
diff --git a/pkg/analyzer/lib/src/plugin/plugin_configuration.dart b/pkg/analyzer/lib/src/plugin/plugin_configuration.dart
index b3a1d9061e8b53f6cfc6b8b2ec4d8e17b866978d..6d5a102a80ce607d2c0c128734c51a2fe92c11e3 100644
--- a/pkg/analyzer/lib/src/plugin/plugin_configuration.dart
+++ b/pkg/analyzer/lib/src/plugin/plugin_configuration.dart
@@ -31,9 +31,6 @@ PluginInfo _processPluginMapping(dynamic name, dynamic details) {
}
PluginInfo _processPluginNode(dynamic node) {
- if (node is String) {
- return new PluginInfo(name: node);
- }
if (node is YamlMap) {
if (node.length == 1) {
return new PluginInfo(name: node.keys.first, version: node.values.first);
@@ -65,9 +62,11 @@ class PluginConfig {
}
});
} else {
- var plugin = _processPluginNode(pluginConfig);
- if (plugin != null) {
- plugins.add(plugin);
+ // Anything but an empty list of plugins is treated as a format error.
+ if (pluginConfig != null) {
+ throw new PluginConfigFormatException(
+ 'Unrecognized plugin config format (expected `YamlMap`, got `${pluginConfig.runtimeType}`)',
+ pluginConfig);
}
}
}
@@ -77,6 +76,16 @@ class PluginConfig {
}
}
+/// Thrown on bad plugin config format.
+class PluginConfigFormatException implements Exception {
+ /// Descriptive message.
+ final message;
+
+ /// The `plugin:` yaml node for generating detailed error feedback.
+ final yamlNode;
+ PluginConfigFormatException(this.message, this.yamlNode);
+}
+
/// Extracts plugin config details from analysis options.
class PluginConfigOptionsProcessor extends OptionsProcessor {
final ErrorHandler _errorHandler;

Powered by Google App Engine
This is Rietveld 408576698