@NotNull @Override public final <T> List<T> getComponentInstancesOfType(@NotNull Class<T> baseClass) { List<T> result = null; // we must use instances only from our adapter (could be service or extension point or something else) for (ComponentAdapter componentAdapter : ((DefaultPicoContainer)getPicoContainer()).getComponentAdapters()) { if (componentAdapter instanceof ComponentConfigComponentAdapter && ReflectionUtil.isAssignable(baseClass, componentAdapter.getComponentImplementation())) { //noinspection unchecked T instance = (T)((ComponentConfigComponentAdapter)componentAdapter).myInitializedComponentInstance; if (instance != null) { if (result == null) { result = new ArrayList<T>(); } result.add(instance); } } } return ContainerUtil.notNullize(result); }
public MockComponentManager(@Nullable PicoContainer parent, @Nonnull Disposable parentDisposable) { myPicoContainer = new DefaultPicoContainer(parent) { private final Set<Object> myDisposableComponents = ContainerUtil.newConcurrentSet(); @Override @Nullable public Object getComponentInstance(final Object componentKey) { final Object o = super.getComponentInstance(componentKey); if (o instanceof Disposable && o != MockComponentManager.this) { if (myDisposableComponents.add(o)) Disposer.register(MockComponentManager.this, (Disposable)o); } return o; } }; myPicoContainer.registerComponentInstance(this); Disposer.register(parentDisposable, this); }
public TypedActionHandler getHandler(TypedActionHandler originalHandler) { if (myHandler == null) { try { DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer()); container.registerComponentInstance(originalHandler); myHandler = instantiate(implementationClass, container); } catch(Exception e) { LOG.error(e); return null; } } return myHandler; }
public EditorActionHandler getHandler(EditorActionHandler originalHandler) { if (myHandler == null) { try { DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer()); container.registerComponentInstance(originalHandler); myHandler = instantiate(implementationClass, container); } catch(Exception e) { LOG.error(e); return null; } } return myHandler; }
public ExtensionsAreaImpl(String areaClass, AreaInstance areaInstance, PicoContainer parentPicoContainer, @NotNull LogProvider logger) { myCreationTrace = DEBUG_REGISTRATION ? new Throwable("Area creation trace") : null; myAreaClass = areaClass; myAreaInstance = areaInstance; myPicoContainer = new DefaultPicoContainer(parentPicoContainer); myLogger = logger; initialize(); }
public HeavyTestFixtureBuilderImpl(HeavyIdeaTestFixtureImpl fixture, final Map<Class<? extends ModuleFixtureBuilder>, Class<? extends ModuleFixtureBuilder>> providers) { myFixture = fixture; myProviders = providers; myContainer = new DefaultPicoContainer(); myContainer.registerComponentInstance(this); }
public MockComponentManager(@Nullable PicoContainer parent, @NotNull Disposable parentDisposable) { myPicoContainer = new DefaultPicoContainer(parent) { @Override @Nullable public Object getComponentInstance(final Object componentKey) { final Object o = super.getComponentInstance(componentKey); registerComponentInDisposer(o); return o; } }; myPicoContainer.registerComponentInstance(this); Disposer.register(parentDisposable, this); }
protected void createComponents(@Nullable ProgressIndicator indicator) { DefaultPicoContainer picoContainer = (DefaultPicoContainer)getPicoContainer(); for (ComponentAdapter componentAdapter : picoContainer.getComponentAdapters()) { if (componentAdapter instanceof ComponentConfigComponentAdapter) { componentAdapter.getComponentInstance(picoContainer); if (indicator != null) { indicator.checkCanceled(); } } } }
@Nullable private ComponentConfigComponentAdapter getComponentAdapter(@NotNull Class<?> componentImplementation) { for (ComponentAdapter componentAdapter : ((DefaultPicoContainer)getPicoContainer()).getComponentAdapters()) { if (componentAdapter instanceof ComponentConfigComponentAdapter && componentAdapter.getComponentImplementation() == componentImplementation) { return ((ComponentConfigComponentAdapter)componentAdapter); } } return null; }
@NotNull public static MockProject mockProject( @Nullable PicoContainer container, Disposable parentDisposable) { Extensions.registerAreaClass("IDEA_PROJECT", null); container = container != null ? container : new DefaultPicoContainer(); return new MockProject(container, parentDisposable); }
/** Construct a mock project. */ @NotNull public static MockProject mockProject(@Nullable PicoContainer container) { Extensions.registerAreaClass("IDEA_PROJECT", null); container = container != null ? container : new DefaultPicoContainer(); return new MockProject(container, getParentDisposableForCleanup()); }
public ExtensionsAreaImpl(String areaClass, AreaInstance areaInstance, PicoContainer parentPicoContainer, @Nonnull LogProvider logger) { myCreationTrace = DEBUG_REGISTRATION ? new Throwable("Area creation trace") : null; myAreaClass = areaClass; myAreaInstance = areaInstance; myPicoContainer = new DefaultPicoContainer(parentPicoContainer); myLogger = logger; initialize(); }
@NotNull protected MutablePicoContainer createPicoContainer() { return myParentComponentManager == null ? new DefaultPicoContainer() : new DefaultPicoContainer(myParentComponentManager.getPicoContainer()); }