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

Unified Diff: lib/src/plugin_impl.dart

Issue 1959373002: Rework plugin API to work better with strong mode (Closed) Base URL: https://github.com/dart-lang/plugin.git@master
Patch Set: Created 4 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/plugin.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/plugin_impl.dart
diff --git a/lib/src/plugin_impl.dart b/lib/src/plugin_impl.dart
index a65a0d3e6c61bc7e8845d84bdc47c933e77da23d..a3358bfdc515430d31a56cb56f82390b1b585b1b 100644
--- a/lib/src/plugin_impl.dart
+++ b/lib/src/plugin_impl.dart
@@ -23,9 +23,7 @@ class ExtensionManagerImpl implements ExtensionManager {
@override
void processPlugins(List<Plugin> plugins) {
for (Plugin plugin in plugins) {
- plugin.registerExtensionPoints((String identifier,
- [ValidateExtension validateExtension]) =>
- registerExtensionPoint(plugin, identifier, validateExtension));
+ plugin.registerExtensionPoints(registerExtensionPoint);
}
for (Plugin plugin in plugins) {
plugin.registerExtensions(registerExtension);
@@ -46,27 +44,22 @@ class ExtensionManagerImpl implements ExtensionManager {
}
/**
- * Register an extension point being defined by the given [plugin] with the
- * given simple [identifier] and [validateExtension].
+ * Register the given [extensionPoint].
*/
- ExtensionPoint registerExtensionPoint(
- Plugin plugin, String identifier, ValidateExtension validateExtension) {
- String uniqueIdentifier = Plugin.buildUniqueIdentifier(plugin, identifier);
+ void registerExtensionPoint(ExtensionPoint extensionPoint) {
+ String uniqueIdentifier = extensionPoint.uniqueIdentifier;
if (extensionPoints.containsKey(uniqueIdentifier)) {
throw new ExtensionError(
- 'There is already an extension point with the id "$identifier"');
+ 'There is already an extension point with the id "$uniqueIdentifier"');
}
- ExtensionPointImpl extensionPoint =
- new ExtensionPointImpl(plugin, identifier, validateExtension);
- extensionPoints[uniqueIdentifier] = extensionPoint;
- return extensionPoint;
+ extensionPoints[uniqueIdentifier] = extensionPoint as ExtensionPointImpl;
}
}
/**
* A concrete representation of an extension point.
*/
-class ExtensionPointImpl implements ExtensionPoint {
+class ExtensionPointImpl<E> implements ExtensionPoint<E> {
@override
final Plugin plugin;
@@ -81,7 +74,7 @@ class ExtensionPointImpl implements ExtensionPoint {
/**
* The list of extensions to this extension point.
*/
- final List<Object> _extensions = <Object>[];
+ final List<E> _extensions = <E>[];
/**
* Initialize a newly create extension point to belong to the given [plugin]
@@ -96,7 +89,7 @@ class ExtensionPointImpl implements ExtensionPoint {
* Return a list containing all of the extensions that have been registered
* for this extension point.
*/
- List<Object> get extensions => new UnmodifiableListView(_extensions);
+ List<E> get extensions => new UnmodifiableListView<E>(_extensions);
/**
* Return the identifier used to uniquely identify this extension point. The
@@ -114,6 +107,6 @@ class ExtensionPointImpl implements ExtensionPoint {
if (validateExtension != null) {
validateExtension(extension);
}
- _extensions.add(extension);
+ _extensions.add(extension as E);
}
}
« no previous file with comments | « lib/plugin.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698