mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
register extension for extension point (for Upsource)
(cherry picked from commit 5076526)
This commit is contained in:
@@ -44,6 +44,7 @@ public interface ExtensionsArea {
|
||||
void registerExtensionPoint(@NotNull PluginDescriptor pluginDescriptor, @NotNull Element extensionPointElement);
|
||||
|
||||
void registerExtension(@NotNull PluginDescriptor pluginDescriptor, @NotNull Element extensionElement, String ns);
|
||||
void registerExtension(@NotNull final ExtensionPoint extensionPoint, @NotNull final PluginDescriptor pluginDescriptor, @NotNull final Element extensionElement);
|
||||
|
||||
String getAreaClass();
|
||||
}
|
||||
|
||||
@@ -155,6 +155,29 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
extensionPoint.registerExtensionAdapter(adapter);
|
||||
}
|
||||
|
||||
// Used in Upsource
|
||||
@Override
|
||||
public void registerExtension(@NotNull final ExtensionPoint extensionPoint, @NotNull final PluginDescriptor pluginDescriptor, @NotNull final Element extensionElement) {
|
||||
if (!Extensions.isComponentSuitableForOs(extensionElement.getAttributeValue("os"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
ExtensionComponentAdapter adapter;
|
||||
if (extensionPoint.getKind() == ExtensionPoint.Kind.INTERFACE) {
|
||||
String implClass = extensionElement.getAttributeValue("implementation");
|
||||
if (implClass == null) {
|
||||
throw new RuntimeException("'implementation' attribute not specified for '" + extensionPoint.getName() + "' extension in '" + pluginDescriptor.getPluginId()
|
||||
.getIdString() + "' plugin");
|
||||
}
|
||||
adapter = new ExtensionComponentAdapter(implClass, extensionElement, myPicoContainer, pluginDescriptor, shouldDeserializeInstance(extensionElement));
|
||||
}
|
||||
else {
|
||||
adapter = new ExtensionComponentAdapter(extensionPoint.getClassName(), extensionElement, myPicoContainer, pluginDescriptor, true);
|
||||
}
|
||||
myPicoContainer.registerComponent(adapter);
|
||||
((ExtensionPointImpl)extensionPoint).registerExtensionAdapter(adapter);
|
||||
}
|
||||
|
||||
private static boolean shouldDeserializeInstance(Element extensionElement) {
|
||||
// has content
|
||||
if (!extensionElement.getContent().isEmpty()) return true;
|
||||
|
||||
Reference in New Issue
Block a user