Merge pull request #1 from dart-lang/make-manager-public Provide public access to the ExtensionManager
diff --git a/lib/manager.dart b/lib/manager.dart new file mode 100644 index 0000000..4fd6e73 --- /dev/null +++ b/lib/manager.dart
@@ -0,0 +1,27 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library plugin.manager; + +import 'package:plugin/src/plugin_impl.dart'; +import 'package:plugin/plugin.dart'; + +/** + * An object that manages the extension points for the host application. + */ +abstract class ExtensionManager { + /** + * Initialize a newly created manager. + */ + factory ExtensionManager() = ExtensionManagerImpl; + + /** + * Process each of the given [plugins] by allowing them to register extension + * points and extensions. + * + * An [ExtensionError] will be thrown if any of the plugins throws such an + * exception while registering with this manager. + */ + void processPlugins(List<Plugin> plugins); +}
diff --git a/lib/plugin.dart b/lib/plugin.dart index 019acd2..b0176f8 100644 --- a/lib/plugin.dart +++ b/lib/plugin.dart
@@ -85,8 +85,8 @@ } /** - * A contribution to the analysis server that can extend the behavior of the - * server while also allowing other plugins to extend it's behavior. + * A contribution to the host application that can extend the behavior of the + * application while also allowing other plugins to extend it's behavior. * * Clients are expected to subtype this class when implementing plugins. */
diff --git a/lib/src/plugin_impl.dart b/lib/src/plugin_impl.dart index 70a76e5..a65a0d3 100644 --- a/lib/src/plugin_impl.dart +++ b/lib/src/plugin_impl.dart
@@ -6,13 +6,13 @@ import 'dart:collection'; +import 'package:plugin/manager.dart'; import 'package:plugin/plugin.dart'; /** - * An object that manages the extension points for a single instance of the - * analysis server. + * A concrete implementation of an [ExtensionManager]. */ -class ExtensionManager { +class ExtensionManagerImpl implements ExtensionManager { /** * A table mapping the id's of extension points to the corresponding * extension points. @@ -20,13 +20,7 @@ Map<String, ExtensionPointImpl> extensionPoints = new HashMap<String, ExtensionPointImpl>(); - /** - * Process each of the given [plugins] by allowing them to register extension - * points and extensions. - * - * An [ExtensionError] will be thrown if any of the plugins throws such an - * exception while registering with this manager. - */ + @override void processPlugins(List<Plugin> plugins) { for (Plugin plugin in plugins) { plugin.registerExtensionPoints((String identifier,
diff --git a/test/plugin_impl_test.dart b/test/plugin_impl_test.dart index d28ebb0..5d2902f 100644 --- a/test/plugin_impl_test.dart +++ b/test/plugin_impl_test.dart
@@ -15,7 +15,7 @@ test('processPlugins', () { TestPlugin plugin1 = new TestPlugin('plugin1'); TestPlugin plugin2 = new TestPlugin('plugin1'); - ExtensionManager manager = new ExtensionManager(); + ExtensionManagerImpl manager = new ExtensionManagerImpl(); manager.processPlugins([plugin1, plugin2]); expect(plugin1.extensionPointsRegistered, true); expect(plugin1.extensionsRegistered, true); @@ -25,7 +25,7 @@ test('registerExtension - valid', () { Plugin plugin = new TestPlugin('plugin'); - ExtensionManager manager = new ExtensionManager(); + ExtensionManagerImpl manager = new ExtensionManagerImpl(); ExtensionPoint point = manager.registerExtensionPoint(plugin, 'point', null); expect(point, isNotNull); @@ -38,7 +38,7 @@ }); test('registerExtension - non existent', () { - ExtensionManager manager = new ExtensionManager(); + ExtensionManagerImpl manager = new ExtensionManagerImpl(); expect(() => manager.registerExtension('does not exist', 'extension'), throwsA(new isInstanceOf<ExtensionError>())); ; @@ -47,7 +47,7 @@ test('registerExtensionPoint - non-conflicting', () { Plugin plugin1 = new TestPlugin('plugin1'); Plugin plugin2 = new TestPlugin('plugin2'); - ExtensionManager manager = new ExtensionManager(); + ExtensionManagerImpl manager = new ExtensionManagerImpl(); expect( manager.registerExtensionPoint(plugin1, 'point1', null), isNotNull); expect( @@ -60,7 +60,7 @@ test('registerExtensionPoint - conflicting - same plugin', () { Plugin plugin1 = new TestPlugin('plugin1'); - ExtensionManager manager = new ExtensionManager(); + ExtensionManagerImpl manager = new ExtensionManagerImpl(); expect( manager.registerExtensionPoint(plugin1, 'point1', null), isNotNull); expect(() => manager.registerExtensionPoint(plugin1, 'point1', null), @@ -70,7 +70,7 @@ test('registerExtensionPoint - conflicting - different plugins', () { Plugin plugin1 = new TestPlugin('plugin1'); Plugin plugin2 = new TestPlugin('plugin1'); - ExtensionManager manager = new ExtensionManager(); + ExtensionManagerImpl manager = new ExtensionManagerImpl(); expect( manager.registerExtensionPoint(plugin1, 'point1', null), isNotNull); expect(() => manager.registerExtensionPoint(plugin2, 'point1', null),