| OLD | NEW |
| (Empty) | |
| 1 -------------------------------------------------------------------------------- |
| 2 |
| 3 To provide a psuedo backward compatible layer. |
| 4 |
| 5 In plugin.dart: |
| 6 |
| 7 /** |
| 8 * A function used to register an extension point with the given simple |
| 9 * [identifier]. If given, the [validator] will be used to validate extensions |
| 10 * to the extension point. |
| 11 * |
| 12 * An [ExtensionError] will be thrown if the extension point cannot be |
| 13 * registered, such as when a plugin attempts to define two extension points |
| 14 * with the same simple identifier. |
| 15 */ |
| 16 typedef ExtensionPoint RegisterExtensionPoint(String identifier, |
| 17 [ValidateExtension validateExtension]); |
| 18 |
| 19 class Plugin { |
| 20 /** |
| 21 * Use the [register] function to register all of the extension points |
| 22 * contributed by this plugin. |
| 23 * |
| 24 * Clients should not invoke the [register] function after this method has |
| 25 * returned. |
| 26 * |
| 27 * This method is deprecated and will be removed in the next breaking release. |
| 28 * Plugins should migrate to using [registerExtensionPoints2]. |
| 29 */ |
| 30 void registerExtensionPoints(RegisterExtensionPoint register); |
| 31 } |
| 32 |
| 33 In plugin_impl.dart: |
| 34 |
| 35 class ExtensionManager { |
| 36 |
| 37 In processPlugins: |
| 38 |
| 39 for (Plugin plugin in plugins) { |
| 40 plugin.registerExtensionPoints((String identifier, |
| 41 [ValidateExtension validateExtension]) => |
| 42 registerExtensionPoint(plugin, identifier, validateExtension)); |
| 43 } |
| 44 |
| 45 /** |
| 46 * Register an extension point being defined by the given [plugin] with the |
| 47 * given simple [identifier] and [validateExtension]. |
| 48 */ |
| 49 ExtensionPoint registerExtensionPoint( |
| 50 Plugin plugin, String identifier, ValidateExtension validateExtension) { |
| 51 String uniqueIdentifier = Plugin.buildUniqueIdentifier(plugin, identifier); |
| 52 if (extensionPoints.containsKey(uniqueIdentifier)) { |
| 53 throw new ExtensionError( |
| 54 'There is already an extension point with the id "$identifier"'); |
| 55 } |
| 56 ExtensionPointImpl extensionPoint = |
| 57 new ExtensionPointImpl(plugin, identifier, validateExtension); |
| 58 extensionPoints[uniqueIdentifier] = extensionPoint; |
| 59 return extensionPoint; |
| 60 } |
| 61 } |
| 62 |
| 63 -------------------------------------------------------------------------------- |
| OLD | NEW |