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

Unified Diff: mojo/public/dart/third_party/plugin/lib/plugin.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
Index: mojo/public/dart/third_party/plugin/lib/plugin.dart
diff --git a/mojo/public/dart/third_party/plugin/lib/plugin.dart b/mojo/public/dart/third_party/plugin/lib/plugin.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b0176f8d7abd1df459f5504832e70b709ab4d0b8
--- /dev/null
+++ b/mojo/public/dart/third_party/plugin/lib/plugin.dart
@@ -0,0 +1,130 @@
+// 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;
+
+/**
+ * A function used to register the given [extension] to the extension point with
+ * the given unique [identifier].
+ *
+ * An [ExtensionError] will be thrown if the [extension] is not appropriate
+ * for the extension point, such as an [extension] that does not implement the
+ * required interface.
+ */
+typedef void RegisterExtension(String identifier, Object extension);
+
+/**
+ * A function used to register an extension point with the given simple
+ * [identifier]. If given, the [validator] will be used to validate extensions
+ * to the extension point.
+ *
+ * An [ExtensionError] will be thrown if the extension point cannot be
+ * registered, such as when a plugin attempts to define two extension points
+ * with the same simple identifier.
+ */
+typedef ExtensionPoint RegisterExtensionPoint(String identifier,
+ [ValidateExtension validateExtension]);
+
+/**
+ * A function used by a plugin to validate an [extension] to a extension point.
+ *
+ * An [ExtensionError] should be thrown if the [extension] is not valid for the
+ * extension point, such as an [extension] that does not implement the required
+ * interface.
+ */
+typedef void ValidateExtension(Object extension);
+
+/**
+ * An exception indicating that an error occurred while attempting to register
+ * either an extension or an extension point.
+ *
+ * Clients are not expected to subtype this class.
+ */
+class ExtensionError implements Exception {
+ /**
+ * The message describing the error that occurred.
+ */
+ final String message;
+
+ /**
+ * Initialize a newly created error to have the given message.
+ */
+ ExtensionError(this.message);
+}
+
+/**
+ * A representation of an extension point.
+ *
+ * Clients are not expected to subtype this class.
+ */
+abstract class ExtensionPoint {
+ /**
+ * Return an immutable list containing all of the extensions that were
+ * registered for this extension point.
+ */
+ List<Object> get extensions;
+
+ /**
+ * Return the plugin that defined this extension point.
+ */
+ Plugin get plugin;
+
+ /**
+ * Return the identifier used to uniquely identify this extension point within
+ * the defining plugin.
+ */
+ String get simpleIdentifier;
+
+ /**
+ * Return the identifier used to uniquely identify this extension point. The
+ * unique identifier is the identifier for the plugin, followed by a period
+ * (`.`), followed by the [simpleIdentifier] for the extension point.
+ */
+ String get uniqueIdentifier;
+}
+
+/**
+ * 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.
+ */
+abstract class Plugin {
+ /**
+ * Return the identifier used to uniquely identify this plugin.
+ */
+ String get uniqueIdentifier;
+
+ /**
+ * Use the [register] function to register all of the extension points
+ * contributed by this plugin.
+ *
+ * Clients should not invoke the [register] function after this method has
+ * returned.
+ */
+ void registerExtensionPoints(RegisterExtensionPoint register);
+
+ /**
+ * Use the [register] function to register all of the extensions contributed
+ * by this plugin.
+ *
+ * Clients should not invoke the [register] function after this method has
+ * returned.
+ */
+ void registerExtensions(RegisterExtension register);
+
+ /**
+ * Return a unique identifier created from the unique identifier from the
+ * [plugin] and the [simpleIdentifier].
+ */
+ static String buildUniqueIdentifier(Plugin plugin, String simpleIdentifier) =>
+ join(plugin.uniqueIdentifier, simpleIdentifier);
+
+ /**
+ * Return an identifier created by joining the [pluginIdentifier] and the
+ * [simpleIdentifier].
+ */
+ static String join(String pluginIdentifier, String simpleIdentifier) =>
+ '$pluginIdentifier.$simpleIdentifier';
+}
« no previous file with comments | « mojo/public/dart/third_party/plugin/lib/manager.dart ('k') | mojo/public/dart/third_party/plugin/lib/src/plugin_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698