private static void collect(@NotNull ComponentManager componentManager, @NotNull Set<String> unknownMacros, @NotNull Map<TrackingPathMacroSubstitutor, IComponentStore> substitutorToStore) { IComponentStore store = ServiceKt.getStateStore(componentManager); TrackingPathMacroSubstitutor substitutor = store.getStateStorageManager().getMacroSubstitutor(); if (substitutor == null) { return; } Set<String> macros = substitutor.getUnknownMacros(null); if (macros.isEmpty()) { return; } unknownMacros.addAll(macros); substitutorToStore.put(substitutor, store); }
@Override public String getSdkHomePath(@Nullable final Module module) { if (isSquirrelModule(module)) { ComponentManager holder = ObjectUtils.notNull(module, myProject); return CachedValuesManager.getManager(myProject).getCachedValue(holder, new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { Sdk sdk = getSquirrelSdk(module); return Result.create(sdk != null ? sdk.getHomePath() : null, SquirrelIdeaSdkService.this); } }); } else { return super.getSdkHomePath(module); } }
@Nullable @Override public String getSdkVersion(@Nullable final Module module) { if (isSquirrelModule(module)) { ComponentManager holder = ObjectUtils.notNull(module, myProject); return CachedValuesManager.getManager(myProject).getCachedValue(holder, new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { Sdk sdk = getSquirrelSdk(module); return Result.create(sdk != null ? sdk.getVersionString() : null, SquirrelIdeaSdkService.this); } }); } else { return super.getSdkVersion(module); } }
@Nullable public String getSdkVersion(@Nullable final Module module) { ComponentManager holder = ObjectUtils.notNull(module, myProject); return CachedValuesManager.getManager(myProject).getCachedValue(holder, new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { String result = null; String sdkHomePath = getSdkHomePath(module); if (sdkHomePath != null) { result = SquirrelSdkUtil.retrieveSquirrelVersion(sdkHomePath); } return Result.create(result, SquirrelSdkService.this); } }); }
protected void installEP(final ExtensionPointName<ServiceDescriptor> pointName, final ComponentManager componentManager) { myExtensionPointName = pointName; final ExtensionPoint<ServiceDescriptor> extensionPoint = Extensions.getArea(null).getExtensionPoint(pointName); assert extensionPoint != null; final MutablePicoContainer picoContainer = (MutablePicoContainer)componentManager.getPicoContainer(); myExtensionPointListener = new ExtensionPointListener<ServiceDescriptor>() { public void extensionAdded(@NotNull final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) { if (descriptor.overrides) { ComponentAdapter oldAdapter = picoContainer.unregisterComponent(descriptor.getInterface());// Allow to re-define service implementations in plugins. if (oldAdapter == null) { throw new RuntimeException("Service: " + descriptor.getInterface() + " doesn't override anything"); } } picoContainer.registerComponent(new MyComponentAdapter(descriptor, pluginDescriptor, (ComponentManagerEx)componentManager)); } public void extensionRemoved(@NotNull final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) { picoContainer.unregisterComponent(extension.getInterface()); } }; extensionPoint.addExtensionPointListener(myExtensionPointListener); }
@Override public void run() { Object res = get(); if (res == null) return; if (res instanceof PsiElement) { if (!((PsiElement)res).isValid()) return; } else if (res instanceof ComponentManager) { if (((ComponentManager)res).isDisposed()) return; } myDelegate.run(); }
protected void installEP(@NotNull ExtensionPointName<ServiceDescriptor> pointName, @NotNull final ComponentManager componentManager) { LOG.assertTrue(myExtensionPointName == null, "Already called installEP with " + myExtensionPointName); myExtensionPointName = pointName; final ExtensionPoint<ServiceDescriptor> extensionPoint = Extensions.getArea(null).getExtensionPoint(pointName); final MutablePicoContainer picoContainer = (MutablePicoContainer)componentManager.getPicoContainer(); myExtensionPointListener = new ExtensionPointListener<ServiceDescriptor>() { @Override public void extensionAdded(@NotNull final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) { if (descriptor.overrides) { // Allow to re-define service implementations in plugins. ComponentAdapter oldAdapter = picoContainer.unregisterComponent(descriptor.getInterface()); if (oldAdapter == null) { throw new RuntimeException("Service: " + descriptor.getInterface() + " doesn't override anything"); } } if (!ComponentManagerImpl.isComponentSuitableForOs(descriptor.os)) { return; } // empty serviceImplementation means we want to unregister service if (!StringUtil.isEmpty(descriptor.getImplementation())) { picoContainer.registerComponent(new MyComponentAdapter(descriptor, pluginDescriptor, (ComponentManagerEx)componentManager)); } } @Override public void extensionRemoved(@NotNull final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) { picoContainer.unregisterComponent(extension.getInterface()); } }; extensionPoint.addExtensionPointListener(myExtensionPointListener); }
private String getSdkHomeLibPath(@Nullable Module module) { ComponentManager holder = ObjectUtils.notNull(module, myProject); return CachedValuesManager.getManager(myProject).getCachedValue(holder, new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { return Result.create(ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Nullable @Override public String compute() { LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject); for (Library library : table.getLibraries()) { String libraryName = library.getName(); if (libraryName != null && libraryName.startsWith(LIBRARY_NAME)) { for (VirtualFile root : library.getFiles(OrderRootType.CLASSES)) { if (isSquirrelSdkLibRoot(root)) { return root.getCanonicalPath(); } } } } return null; } }), SquirrelSdkService.this); } }); }
public static StorageData loadStorageFile(ComponentManager componentManager, VirtualFile modulesXml) throws JDOMException, IOException { final Document document = JDOMUtil.loadDocument(new ByteArrayInputStream(modulesXml.contentsToByteArray())); StorageData storageData = new StorageData("project"); final Element element = document.getRootElement(); PathMacroManager.getInstance(componentManager).expandPaths(element); storageData.load(element); return storageData; }
@NotNull public static TreeMap<String, Element> loadStorageFile(@NotNull ComponentManager componentManager, @NotNull VirtualFile modulesXml) throws JDOMException, IOException { return FileStorageCoreUtil.load(JDOMUtil.loadDocument(modulesXml.contentsToByteArray()).getRootElement(), PathMacroManager.getInstance(componentManager), false); }
protected DisposeAwareProjectChange(@NotNull ComponentManager componentManager) { myComponentManager = componentManager; }
public static <T> T registerComponentInstance(final ComponentManager container, final Class<T> key, final T implementation) { return registerComponentInstance((MutablePicoContainer)container.getPicoContainer(), key, implementation); }
protected ConfigurablesGroupBase(ComponentManager componentManager, final ExtensionPointName<ConfigurableEP<Configurable>> configurablesExtensionPoint, boolean loadComponents) { myComponentManager = componentManager; myConfigurablesExtensionPoint = configurablesExtensionPoint; myLoadComponents = loadComponents; }
protected PlatformComponentManagerImpl(@Nullable ComponentManager parent) { super(parent); }
protected PlatformComponentManagerImpl(@Nullable ComponentManager parent, @NotNull String name) { super(parent, name); }
protected ComponentManagerImpl(@Nullable ComponentManager parentComponentManager) { myParentComponentManager = parentComponentManager; bootstrapPicoContainer(toString()); }
protected ComponentManagerImpl(@Nullable ComponentManager parentComponentManager, @NotNull String name) { myParentComponentManager = parentComponentManager; bootstrapPicoContainer(name); }
protected final ComponentManager getParentComponentManager() { return myParentComponentManager; }
protected DisposeAwareProjectChange(@Nonnull ComponentManager componentManager) { myComponentManager = componentManager; }
@Nonnull public MultiHostInjector getInstance(@Nonnull ComponentManager componentManager) { return instantiate(myImplementationClassHandler.getValue(), componentManager.getPicoContainer()); }
protected PlatformComponentManagerImpl(ComponentManager parent) { super(parent); }
protected PlatformComponentManagerImpl(ComponentManager parent, @Nonnull String name) { super(parent, name); }