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

Side by Side Diff: pkg/analyzer/lib/src/plugin/plugin_configuration.dart

Issue 1506963002: Options processing API update (#25126). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
146 AnalysisContext context, Map<String, YamlNode> options) { 147 AnalysisContext context, Map<String, Object> options) {
147 _config = new PluginConfig.fromOptions(options); 148 _config = new PluginConfig.fromOptions(options);
148 } 149 }
149 } 150 }
150 151
151 /// Describes plugin information. 152 /// Describes plugin information.
152 class PluginInfo { 153 class PluginInfo {
153 final String name; 154 final String name;
154 final String className; 155 final String className;
155 final String version; 156 final String version;
156 final String libraryUri; 157 final String libraryUri;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 /// Provisional manifest file format: 190 /// Provisional manifest file format:
190 /// 191 ///
191 /// class_name: MyAnalyzerPlugin 192 /// class_name: MyAnalyzerPlugin
192 /// library_uri: 'my_plugin/my_analyzer_plugin.dart' 193 /// library_uri: 'my_plugin/my_analyzer_plugin.dart'
193 /// contributes_to: analyzer 194 /// contributes_to: analyzer
194 class PluginManifest { 195 class PluginManifest {
195 PluginInfo plugin; 196 PluginInfo plugin;
196 Iterable<String> contributesTo; 197 Iterable<String> contributesTo;
197 PluginManifest({this.plugin, this.contributesTo}); 198 PluginManifest({this.plugin, this.contributesTo});
198 } 199 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698