OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /// Support for client code that wants to consume options contributed to the |
| 6 /// analysis options file. |
| 7 library analyzer.plugin.options; |
| 8 |
| 9 import 'package:analyzer/src/plugin/options_plugin.dart'; |
| 10 import 'package:plugin/plugin.dart'; |
| 11 import 'package:yaml/yaml.dart'; |
| 12 |
| 13 /// The identifier of the extension point that allows plugins to access |
| 14 /// options defined in the analysis options file. The object used as an |
| 15 /// extension must be an [OptionsProcessor]. |
| 16 final String OPTIONS_PROCESSOR_EXTENSION_POINT_ID = Plugin.join( |
| 17 OptionsPlugin.UNIQUE_IDENTIFIER, |
| 18 OptionsPlugin.OPTIONS_PROCESSOR_EXTENSION_POINT); |
| 19 |
| 20 /// Processes options defined in the analysis options file. |
| 21 /// |
| 22 /// The options file format is intentionally very open-ended, giving clients |
| 23 /// utmost flexibility in defining their own options. The only hardfast |
| 24 /// expectation is that options files will contain a mapping from Strings |
| 25 /// (identifying 'scopes') to associated options. For example, the given |
| 26 /// content |
| 27 /// |
| 28 /// linter: |
| 29 /// rules: |
| 30 /// camel_case_types: true |
| 31 /// compiler: |
| 32 /// resolver: |
| 33 /// useMultiPackage: true |
| 34 /// packagePaths: |
| 35 /// - /foo/bar/pkg |
| 36 /// - /bar/baz/pkg |
| 37 /// |
| 38 /// defines two scopes, `linter` and `compiler`. Parsing would result in a |
| 39 /// map, mapping the `linter` and `compiler` scope identifiers to their |
| 40 /// respective parsed option node contents. Extracting values is a simple |
| 41 /// matter of inspecting the parsed nodes. For example, testing whether the |
| 42 /// compiler's resolver is set to use the `useMultiPackage` option might look |
| 43 /// something like this (eliding error-checking): |
| 44 /// |
| 45 /// bool useMultiPackage = |
| 46 /// options['compiler']['resolver']['useMultiPackage']; |
| 47 abstract class OptionsProcessor { |
| 48 |
| 49 /// Called when an error occurs in processing options. |
| 50 void onError(Exception exception); |
| 51 |
| 52 /// Called when the options file is processed. |
| 53 /// |
| 54 /// The options file is processed on analyzer initialization and |
| 55 /// subsequently when the file is changed on disk. In the event of a |
| 56 /// change notification, note that the notification simply indicates |
| 57 /// a change on disk. Content in specific option scopes may or may not |
| 58 /// be different. It is up to the implementer to check whether specific |
| 59 /// options have changed and to handle those changes appropriately. |
| 60 void optionsProcessed(Map<String, YamlNode> options); |
| 61 } |
OLD | NEW |