| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.plugin.plugin_configuration; | 5 library analyzer.src.plugin.plugin_configuration; |
| 6 | 6 |
| 7 import 'package:analyzer/plugin/options.dart'; | 7 import 'package:analyzer/plugin/options.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
| 9 import 'package:yaml/yaml.dart'; | 9 import 'package:yaml/yaml.dart'; |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 /// A callback for error handling. | 77 /// A callback for error handling. |
| 78 typedef ErrorHandler(Exception e); | 78 typedef ErrorHandler(Exception e); |
| 79 | 79 |
| 80 /// Describes plugin configuration information as extracted from an | 80 /// Describes plugin configuration information as extracted from an |
| 81 /// analysis options map or plugin manifest. | 81 /// analysis options map or plugin manifest. |
| 82 class PluginConfig { | 82 class PluginConfig { |
| 83 final Iterable<PluginInfo> plugins; | 83 final Iterable<PluginInfo> plugins; |
| 84 PluginConfig(this.plugins); | 84 PluginConfig(this.plugins); |
| 85 | 85 |
| 86 /// Create a plugin configuration from an options map. | 86 /// Create a plugin configuration from an options map. |
| 87 factory PluginConfig.fromOptions(Map<String, YamlNode> options) { | 87 factory PluginConfig.fromOptions(Map<String, Object> options) { |
| 88 List<PluginInfo> plugins = []; | 88 List<PluginInfo> plugins = []; |
| 89 var analyzerOptions = options[_analyzerOptionScope]; | 89 var analyzerOptions = options[_analyzerOptionScope]; |
| 90 if (analyzerOptions != null) { | 90 if (analyzerOptions != null) { |
| 91 //TODO(pq): handle "raw" maps (https://github.com/dart-lang/sdk/issues/251
26) |
| 91 if (analyzerOptions is YamlMap) { | 92 if (analyzerOptions is YamlMap) { |
| 92 var pluginConfig = analyzerOptions[_pluginOptionScope]; | 93 var pluginConfig = analyzerOptions[_pluginOptionScope]; |
| 93 if (pluginConfig is YamlMap) { | 94 if (pluginConfig is YamlMap) { |
| 94 pluginConfig.forEach((name, details) { | 95 pluginConfig.forEach((name, details) { |
| 95 var plugin = _processPluginMapping(name, details); | 96 var plugin = _processPluginMapping(name, details); |
| 96 if (plugin != null) { | 97 if (plugin != null) { |
| 97 plugins.add(plugin); | 98 plugins.add(plugin); |
| 98 } | 99 } |
| 99 }); | 100 }); |
| 100 } else { | 101 } else { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 PluginConfig get config => _config; | 136 PluginConfig get config => _config; |
| 136 | 137 |
| 137 @override | 138 @override |
| 138 void onError(Exception exception) { | 139 void onError(Exception exception) { |
| 139 if (_errorHandler != null) { | 140 if (_errorHandler != null) { |
| 140 _errorHandler(exception); | 141 _errorHandler(exception); |
| 141 } | 142 } |
| 142 } | 143 } |
| 143 | 144 |
| 144 @override | 145 @override |
| 145 void optionsProcessed( | 146 void optionsProcessed(AnalysisContext context, Map<String, Object> options) { |
| 146 AnalysisContext context, Map<String, YamlNode> options) { | |
| 147 _config = new PluginConfig.fromOptions(options); | 147 _config = new PluginConfig.fromOptions(options); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 /// Describes plugin information. | 151 /// Describes plugin information. |
| 152 class PluginInfo { | 152 class PluginInfo { |
| 153 final String name; | 153 final String name; |
| 154 final String className; | 154 final String className; |
| 155 final String version; | 155 final String version; |
| 156 final String libraryUri; | 156 final String libraryUri; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 /// Provisional manifest file format: | 189 /// Provisional manifest file format: |
| 190 /// | 190 /// |
| 191 /// class_name: MyAnalyzerPlugin | 191 /// class_name: MyAnalyzerPlugin |
| 192 /// library_uri: 'my_plugin/my_analyzer_plugin.dart' | 192 /// library_uri: 'my_plugin/my_analyzer_plugin.dart' |
| 193 /// contributes_to: analyzer | 193 /// contributes_to: analyzer |
| 194 class PluginManifest { | 194 class PluginManifest { |
| 195 PluginInfo plugin; | 195 PluginInfo plugin; |
| 196 Iterable<String> contributesTo; | 196 Iterable<String> contributesTo; |
| 197 PluginManifest({this.plugin, this.contributesTo}); | 197 PluginManifest({this.plugin, this.contributesTo}); |
| 198 } | 198 } |
| OLD | NEW |