Search in sources :

Example 6 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class BuildProcessClasspathManager method computeCompileServerPluginsClasspath.

private static List<String> computeCompileServerPluginsClasspath() {
    final List<String> classpath = ContainerUtil.newArrayList();
    for (CompileServerPlugin serverPlugin : CompileServerPlugin.EP_NAME.getExtensions()) {
        final PluginId pluginId = serverPlugin.getPluginDescriptor().getPluginId();
        final IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
        LOG.assertTrue(plugin != null, pluginId);
        final File baseFile = plugin.getPath();
        if (baseFile.isFile()) {
            classpath.add(baseFile.getPath());
        } else if (baseFile.isDirectory()) {
            for (String relativePath : StringUtil.split(serverPlugin.getClasspath(), ";")) {
                final File jarFile = new File(new File(baseFile, "lib"), relativePath);
                File classesDir = new File(baseFile, "classes");
                if (jarFile.exists()) {
                    classpath.add(jarFile.getPath());
                } else if (classesDir.isDirectory()) {
                    //'plugin run configuration': all module output are copied to 'classes' folder
                    classpath.add(classesDir.getPath());
                } else {
                    //development mode: add directory out/classes/production/<jar-name> to classpath, assuming that jar-name is equal to module name
                    final String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(relativePath));
                    File baseOutputDir = baseFile.getParentFile();
                    if (baseOutputDir.getName().equals("test")) {
                        baseOutputDir = new File(baseOutputDir.getParentFile(), "production");
                    }
                    final File dir = new File(baseOutputDir, moduleName);
                    if (dir.exists()) {
                        classpath.add(dir.getPath());
                    } else {
                        //looks like <jar-name> refers to a library, try to find it under <plugin-dir>/lib
                        File pluginDir = getPluginDir(plugin);
                        if (pluginDir != null) {
                            File libraryFile = new File(pluginDir, "lib" + File.separator + PathUtil.getFileName(relativePath));
                            if (libraryFile.exists()) {
                                classpath.add(libraryFile.getPath());
                            } else {
                                LOG.error("Cannot add " + relativePath + " from '" + plugin.getName() + ' ' + plugin.getVersion() + "'" + " to external compiler classpath: library " + libraryFile.getAbsolutePath() + " not found");
                            }
                        } else {
                            LOG.error("Cannot add " + relativePath + " from '" + plugin.getName() + ' ' + plugin.getVersion() + "'" + " to external compiler classpath: home directory of plugin not found");
                        }
                    }
                }
            }
        }
    }
    return classpath;
}
Also used : CompileServerPlugin(com.intellij.compiler.server.CompileServerPlugin) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) File(java.io.File)

Example 7 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class ExtensionsRootType method getBundledResourceUrls.

@NotNull
private static List<URL> getBundledResourceUrls(@NotNull PluginId pluginId, @NotNull String path) throws IOException {
    String resourcesPath = EXTENSIONS_PATH + "/" + path;
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
    ClassLoader pluginClassLoader = plugin != null ? plugin.getPluginClassLoader() : null;
    Set<URL> urls = plugin == null ? null : ContainerUtil.newLinkedHashSet(ContainerUtil.toList(pluginClassLoader.getResources(resourcesPath)));
    if (urls == null)
        return ContainerUtil.emptyList();
    PluginId corePluginId = PluginId.findId(PluginManagerCore.CORE_PLUGIN_ID);
    IdeaPluginDescriptor corePlugin = ObjectUtils.notNull(PluginManager.getPlugin(corePluginId));
    ClassLoader coreClassLoader = corePlugin.getPluginClassLoader();
    if (coreClassLoader != pluginClassLoader && !plugin.getUseIdeaClassLoader() && !pluginId.equals(corePluginId)) {
        urls.removeAll(ContainerUtil.toList(coreClassLoader.getResources(resourcesPath)));
    }
    return ContainerUtil.newArrayList(urls);
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) URL(java.net.URL) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class ExtensionsRootType method extractBundledExtensionsIfNeeded.

private void extractBundledExtensionsIfNeeded(@NotNull PluginId pluginId) throws IOException {
    if (!ApplicationManager.getApplication().isDispatchThread())
        return;
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
    if (plugin == null || !ResourceVersions.getInstance().shouldUpdateResourcesOf(plugin))
        return;
    extractBundledResources(pluginId, "");
    ResourceVersions.getInstance().resourcesUpdated(plugin);
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor)

Example 9 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class ComponentManagerImpl method getComponentConfigs.

@NotNull
private List<ComponentConfig> getComponentConfigs(final ProgressIndicator indicator) {
    ArrayList<ComponentConfig> componentConfigs = new ArrayList<>();
    boolean isDefaultProject = this instanceof Project && ((Project) this).isDefault();
    boolean headless = ApplicationManager.getApplication().isHeadlessEnvironment();
    for (IdeaPluginDescriptor plugin : PluginManagerCore.getPlugins((message, progress) -> indicator.setFraction(progress))) {
        if (PluginManagerCore.shouldSkipPlugin(plugin)) {
            continue;
        }
        ComponentConfig[] configs = getMyComponentConfigsFromDescriptor(plugin);
        componentConfigs.ensureCapacity(componentConfigs.size() + configs.length);
        for (ComponentConfig config : configs) {
            if ((!isDefaultProject || config.isLoadForDefaultProject()) && isComponentSuitable(config.options) && config.prepareClasses(headless)) {
                config.pluginDescriptor = plugin;
                componentConfigs.add(config);
            }
        }
    }
    return componentConfigs;
}
Also used : Project(com.intellij.openapi.project.Project) ComponentConfig(com.intellij.openapi.components.ComponentConfig) ArrayList(java.util.ArrayList) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class InspectionEP method getLocalizedString.

@Nullable
private String getLocalizedString(String bundleName, String key) {
    final String baseName = bundleName != null ? bundleName : bundle == null ? ((IdeaPluginDescriptor) myPluginDescriptor).getResourceBundleBaseName() : bundle;
    if (baseName == null || key == null) {
        if (bundleName != null) {
            LOG.warn(implementationClass);
        }
        return null;
    }
    final ResourceBundle resourceBundle = AbstractBundle.getResourceBundle(baseName, myPluginDescriptor.getPluginClassLoader());
    return CommonBundle.message(resourceBundle, key);
}
Also used : ResourceBundle(java.util.ResourceBundle) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)40 PluginId (com.intellij.openapi.extensions.PluginId)19 NotNull (org.jetbrains.annotations.NotNull)11 Nullable (org.jetbrains.annotations.Nullable)8 Project (com.intellij.openapi.project.Project)4 File (java.io.File)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ErrorBean (com.intellij.errorreport.bean.ErrorBean)3 ApplicationInfoEx (com.intellij.openapi.application.ex.ApplicationInfoEx)3 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)3 URL (java.net.URL)3 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 CantRunException (com.intellij.execution.CantRunException)2 PluginClassLoader (com.intellij.ide.plugins.cl.PluginClassLoader)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)2 PluginDescriptor (com.intellij.openapi.extensions.PluginDescriptor)2 ShowSettingsUtil (com.intellij.openapi.options.ShowSettingsUtil)2 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2