Java 类com.intellij.util.KeyedLazyInstance 实例源码

项目:intellij-ce-playground    文件:KeyedExtensionCollector.java   
public boolean hasAnyExtensions() {
  synchronized (lock) {
    if (!myExplicitExtensions.isEmpty()) return true;
    final ExtensionPoint<KeyedLazyInstance<T>> point = getPoint();
    return point != null && point.hasAnyExtensions();
  }
}
项目:tools-idea    文件:KeyedExtensionCollector.java   
public boolean hasAnyExtensions() {
  synchronized (lock) {
    if (!myExplicitExtensions.isEmpty()) return true;
    final ExtensionPoint<KeyedLazyInstance<T>> point = getPoint();
    return point != null && point.hasAnyExtensions();
  }
}
项目:consulo    文件:KeyedExtensionCollector.java   
public boolean hasAnyExtensions() {
  synchronized (lock) {
    if (!myExplicitExtensions.isEmpty()) return true;
    final ExtensionPoint<KeyedLazyInstance<T>> point = getPoint();
    return point != null && point.hasAnyExtensions();
  }
}
项目:intellij-ce-playground    文件:KeyedExtensionCollector.java   
@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;
}
项目:tools-idea    文件:KeyedExtensionCollector.java   
@Nullable
private ExtensionPoint<KeyedLazyInstance<T>> getPoint() {
  if (myPoint == null) {
    if (Extensions.getRootArea().hasExtensionPoint(myEpName)) {
      ExtensionPointName<KeyedLazyInstance<T>> typesafe = ExtensionPointName.create(myEpName);
      myPoint = 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();
        }
      };

      myPoint.addExtensionPointListener(myListener);
    }
  }
  return myPoint;
}
项目:consulo    文件:KeyedExtensionCollector.java   
@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(@Nonnull 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(@Nonnull 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;
}