use of com.intellij.util.KeyedLazyInstance in project intellij-community by JetBrains.
the class KeyedExtensionCollector method getPoint.
@Nullable
private ExtensionPoint<KeyedLazyInstance<T>> getPoint() {
ExtensionPoint<KeyedLazyInstance<T>> point = myPoint;
if (point == null && Extensions.getRootArea().hasExtensionPoint(myEpName)) {
ExtensionPointName<KeyedLazyInstance<T>> typesafe = ExtensionPointName.create(myEpName);
myPoint = point = Extensions.getRootArea().getExtensionPoint(typesafe);
myListener = new ExtensionPointAndAreaListener<KeyedLazyInstance<T>>() {
@Override
public void extensionAdded(@NotNull final KeyedLazyInstance<T> bean, @Nullable final PluginDescriptor pluginDescriptor) {
synchronized (lock) {
if (bean.getKey() == null) {
if (pluginDescriptor != null) {
throw new PluginException("No key specified for extension of class " + bean.getInstance().getClass(), pluginDescriptor.getPluginId());
}
LOG.error("No key specified for extension of class " + bean.getInstance().getClass());
return;
}
myCache.remove(bean.getKey());
for (ExtensionPointListener<T> listener : myListeners) {
listener.extensionAdded(bean.getInstance(), null);
}
}
}
@Override
public void extensionRemoved(@NotNull final KeyedLazyInstance<T> bean, @Nullable final PluginDescriptor pluginDescriptor) {
synchronized (lock) {
myCache.remove(bean.getKey());
for (ExtensionPointListener<T> listener : myListeners) {
listener.extensionRemoved(bean.getInstance(), null);
}
}
}
@Override
public void areaReplaced(final ExtensionsArea area) {
resetAreaListener();
}
};
point.addExtensionPointListener(myListener);
}
return point;
}
Aggregations