protected ConfigurableEP(PicoContainer picoContainer, @Nullable Project project) { myProject = project; myPicoContainer = picoContainer; myFactory = new AtomicNotNullLazyValue<NullableFactory<T>>() { @NotNull @Override protected NullableFactory<T> compute() { if (providerClass != null) { return new InstanceFromProviderFactory(); } else if (instanceClass != null) { return new NewInstanceFactory(); } else if (implementationClass != null) { return new ImplementationFactory(); } throw new RuntimeException(); } }; }
protected ConfigurableEP(PicoContainer picoContainer, @Nullable Project project) { myProject = project; myPicoContainer = picoContainer; myFactory = new AtomicNotNullLazyValue<NullableFactory<T>>() { @Nonnull @Override protected NullableFactory<T> compute() { if (providerClass != null) { return new InstanceFromProviderFactory(); } else if (instanceClass != null) { return new NewInstanceFactory(); } else if (implementationClass != null) { return new ImplementationFactory(); } throw new RuntimeException(); } }; }
@Nullable private <T extends RefElement> T getFromRefTableOrCache(final PsiElement element, @NotNull NullableFactory<T> factory, @Nullable Consumer<T> whenCached) { PsiAnchor psiAnchor = createAnchor(element); T result; synchronized (myRefTable) { //noinspection unchecked result = (T)myRefTable.get(psiAnchor); if (result != null) return result; if (!isValidPointForReference()) { //LOG.assertTrue(true, "References may become invalid after process is finished"); return null; } result = factory.create(); if (result == null) return null; myRefTable.put(psiAnchor, result); } if (whenCached != null) { whenCached.consume(result); } return result; }
private void takeStuffFromFactory(final DiffRequest request, final List<? extends AnAction> actions) { if (mySteps.size() > 1 || (myActionsFactory != null)) { request.setToolbarAddons(new DiffRequest.ToolbarAddons() { public void customize(final DiffToolbar toolbar) { if (mySteps.size() > 1) { toolbar.addSeparator(); } toolbar.addAction(myPrevChangeAction); toolbar.addAction(myNextChangeAction); toolbar.addAction(mySelectChangeAction); if (myActionsFactory != null) { toolbar.addSeparator(); for (AnAction action : actions) { toolbar.addAction(action); } } } }); } if (myActionsFactory != null) { request.setBottomComponentFactory(new NullableFactory<JComponent>() { public JComponent create() { return myActionsFactory.createBottomComponent(); } }); } }
@Override public DomElement createPathStableCopy() { final DomFileElement stableCopy = myParent.createStableCopy(); return getManager().createStableValue(new NullableFactory<DomElement>() { @Override public DomElement create() { return stableCopy.isValid() ? stableCopy.getRootElement() : null; } }); }
public DomElement createPathStableCopy() { final DomFileElement stableCopy = myParent.createStableCopy(); return getManager().createStableValue(new NullableFactory<DomElement>() { public DomElement create() { return stableCopy.isValid() ? stableCopy.getRootElement() : null; } }); }
@Nullable public RefElement getReference(final PsiElement elem, final boolean ignoreScope) { if (ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() { @Override public Boolean compute() { return elem == null || !elem.isValid() || elem instanceof LightElement || !(elem instanceof PsiDirectory) && !belongsToScope(elem, ignoreScope); } })) { return null; } return getFromRefTableOrCache( elem, new NullableFactory<RefElementImpl>() { @Override public RefElementImpl create() { return ApplicationManager.getApplication().runReadAction(new Computable<RefElementImpl>() { @Override @Nullable public RefElementImpl compute() { final RefManagerExtension extension = getExtension(elem.getLanguage()); if (extension != null) { final RefElement refElement = extension.createRefElement(elem); if (refElement != null) return (RefElementImpl)refElement; } if (elem instanceof PsiFile) { return new RefFileImpl((PsiFile)elem, RefManagerImpl.this); } if (elem instanceof PsiDirectory) { return new RefDirectoryImpl((PsiDirectory)elem, RefManagerImpl.this); } return null; } }); } }, new Consumer<RefElementImpl>() { @Override public void consume(RefElementImpl element) { element.initialize(); for (RefManagerExtension each : myExtensions.values()) { each.onEntityInitialized(element, elem); } fireNodeInitialized(element); } }); }
@Nullable protected <T extends RefElement> T getFromRefTableOrCache(final PsiElement element, @NotNull NullableFactory<T> factory) { return getFromRefTableOrCache(element, factory, null); }