register extension for extension point (for Upsource)

(cherry picked from commit 5076526)
This commit is contained in:
pasynkov
2017-10-25 14:16:36 +03:00
committed by nik
parent bf654336c9
commit 094aec6946
2 changed files with 24 additions and 0 deletions
@@ -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;