Search in sources :

Example 1 with PluginDescriptor

use of com.intellij.openapi.extensions.PluginDescriptor in project intellij-community by JetBrains.

the class IdeErrorsDialog method getSubmitter.

@Nullable
public static ErrorReportSubmitter getSubmitter(final Throwable throwable) {
    if (throwable instanceof MessagePool.TooManyErrorsException || throwable instanceof AbstractMethodError) {
        return null;
    }
    final PluginId pluginId = findPluginId(throwable);
    final ErrorReportSubmitter[] reporters;
    try {
        reporters = Extensions.getExtensions(ExtensionPoints.ERROR_HANDLER_EP);
    } catch (Throwable t) {
        return null;
    }
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
    if (plugin == null) {
        return getCorePluginSubmitter(reporters);
    }
    for (ErrorReportSubmitter reporter : reporters) {
        final PluginDescriptor descriptor = reporter.getPluginDescriptor();
        if (descriptor != null && Comparing.equal(pluginId, descriptor.getPluginId())) {
            return reporter;
        }
    }
    if (PluginManagerMain.isDevelopedByJetBrains(plugin)) {
        return getCorePluginSubmitter(reporters);
    }
    return null;
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PluginDescriptor

use of com.intellij.openapi.extensions.PluginDescriptor in project intellij-community by JetBrains.

the class GutterIconsConfigurable method createUIComponents.

private void createUIComponents() {
    myList = new CheckBoxList<GutterIconDescriptor>() {

        @Override
        protected JComponent adjustRendering(JComponent rootComponent, JCheckBox checkBox, int index, boolean selected, boolean hasFocus) {
            JPanel panel = new JPanel(new BorderLayout());
            panel.setBorder(BorderFactory.createEmptyBorder());
            GutterIconDescriptor descriptor = myList.getItemAt(index);
            Icon icon = descriptor == null ? null : descriptor.getIcon();
            JLabel label = new JLabel(icon == null ? EmptyIcon.ICON_16 : icon);
            label.setOpaque(true);
            label.setPreferredSize(new Dimension(25, -1));
            label.setHorizontalAlignment(SwingConstants.CENTER);
            panel.add(label, BorderLayout.WEST);
            panel.add(checkBox, BorderLayout.CENTER);
            panel.setBackground(getBackground(false));
            label.setBackground(getBackground(selected));
            if (!checkBox.isOpaque()) {
                checkBox.setOpaque(true);
            }
            checkBox.setBorder(null);
            PluginDescriptor pluginDescriptor = myFirstDescriptors.get(descriptor);
            if (pluginDescriptor instanceof IdeaPluginDescriptor) {
                SeparatorWithText separator = new SeparatorWithText();
                String name = ((IdeaPluginDescriptor) pluginDescriptor).getName();
                separator.setCaption("IDEA CORE".equals(name) ? "Common" : name);
                panel.add(separator, BorderLayout.NORTH);
            }
            return panel;
        }

        @Nullable
        @Override
        protected Point findPointRelativeToCheckBox(int x, int y, @NotNull JCheckBox checkBox, int index) {
            return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index);
        }
    };
    myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    myList.setBorder(BorderFactory.createEmptyBorder());
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) SeparatorWithText(com.intellij.ui.SeparatorWithText) EmptyIcon(com.intellij.util.ui.EmptyIcon) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with PluginDescriptor

use of com.intellij.openapi.extensions.PluginDescriptor in project intellij-community by JetBrains.

the class GutterIconsConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    ExtensionPoint<LineMarkerProvider> point = Extensions.getRootArea().getExtensionPoint(LineMarkerProviders.EP_NAME);
    @SuppressWarnings("unchecked") LanguageExtensionPoint<LineMarkerProvider>[] extensions = (LanguageExtensionPoint<LineMarkerProvider>[]) point.getExtensions();
    NullableFunction<LanguageExtensionPoint<LineMarkerProvider>, PluginDescriptor> function = point1 -> {
        LineMarkerProvider instance = point1.getInstance();
        return instance instanceof LineMarkerProviderDescriptor && ((LineMarkerProviderDescriptor) instance).getName() != null ? point1.getPluginDescriptor() : null;
    };
    MultiMap<PluginDescriptor, LanguageExtensionPoint<LineMarkerProvider>> map = ContainerUtil.groupBy(Arrays.asList(extensions), function);
    Map<GutterIconDescriptor, PluginDescriptor> pluginDescriptorMap = ContainerUtil.newHashMap();
    Set<String> ids = new HashSet<>();
    myDescriptors = new ArrayList<>();
    for (final PluginDescriptor descriptor : map.keySet()) {
        Collection<LanguageExtensionPoint<LineMarkerProvider>> points = map.get(descriptor);
        for (LanguageExtensionPoint<LineMarkerProvider> extensionPoint : points) {
            GutterIconDescriptor instance = (GutterIconDescriptor) extensionPoint.getInstance();
            if (instance.getOptions().length > 0) {
                for (GutterIconDescriptor option : instance.getOptions()) {
                    if (ids.add(option.getId())) {
                        myDescriptors.add(option);
                    }
                    pluginDescriptorMap.put(option, descriptor);
                }
            } else {
                if (ids.add(instance.getId())) {
                    myDescriptors.add(instance);
                }
                pluginDescriptorMap.put(instance, descriptor);
            }
        }
    }
    /*
    List<GutterIconDescriptor> options = new ArrayList<GutterIconDescriptor>();
    for (Iterator<GutterIconDescriptor> iterator = myDescriptors.iterator(); iterator.hasNext(); ) {
      GutterIconDescriptor descriptor = iterator.next();
      if (descriptor.getOptions().length > 0) {
        options.addAll(Arrays.asList(descriptor.getOptions()));
        iterator.remove();
      }
    }
    myDescriptors.addAll(options);
    */
    myDescriptors.sort((o1, o2) -> {
        if (pluginDescriptorMap.get(o1) != pluginDescriptorMap.get(o2))
            return 0;
        return Comparing.compare(o1.getName(), o2.getName());
    });
    PluginDescriptor current = null;
    for (GutterIconDescriptor descriptor : myDescriptors) {
        PluginDescriptor pluginDescriptor = pluginDescriptorMap.get(descriptor);
        if (pluginDescriptor != current) {
            myFirstDescriptors.put(descriptor, pluginDescriptor);
            current = pluginDescriptor;
        }
    }
    myList.setItems(myDescriptors, GutterIconDescriptor::getName);
    myShowGutterIconsJBCheckBox.addChangeListener(e -> myList.setEnabled(myShowGutterIconsJBCheckBox.isSelected()));
    return myPanel;
}
Also used : java.util(java.util) ContainerUtil(com.intellij.util.containers.ContainerUtil) Nls(org.jetbrains.annotations.Nls) ProjectManager(com.intellij.openapi.project.ProjectManager) Comparing(com.intellij.openapi.util.Comparing) CheckBoxList(com.intellij.ui.CheckBoxList) EditorSettingsExternalizable(com.intellij.openapi.editor.ex.EditorSettingsExternalizable) Project(com.intellij.openapi.project.Project) HashSet(com.intellij.util.containers.hash.HashSet) ChangeListener(javax.swing.event.ChangeListener) MultiMap(com.intellij.util.containers.MultiMap) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) Extensions(com.intellij.openapi.extensions.Extensions) EmptyIcon(com.intellij.util.ui.EmptyIcon) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) JBCheckBox(com.intellij.ui.components.JBCheckBox) NullableFunction(com.intellij.util.NullableFunction) Configurable(com.intellij.openapi.options.Configurable) SeparatorWithText(com.intellij.ui.SeparatorWithText) com.intellij.codeInsight.daemon(com.intellij.codeInsight.daemon) TestOnly(org.jetbrains.annotations.TestOnly) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) HashSet(com.intellij.util.containers.hash.HashSet) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with PluginDescriptor

use of com.intellij.openapi.extensions.PluginDescriptor in project intellij-community by JetBrains.

the class FileTemplatesLoader method loadDefaultTemplates.

private void loadDefaultTemplates() {
    final Set<URL> processedUrls = new HashSet<>();
    for (PluginDescriptor plugin : PluginManagerCore.getPlugins()) {
        if (plugin instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl) plugin).isEnabled()) {
            final ClassLoader loader = plugin.getPluginClassLoader();
            if (loader instanceof PluginClassLoader && ((PluginClassLoader) loader).getUrls().isEmpty()) {
                // development mode, when IDEA_CORE's loader contains all the classpath
                continue;
            }
            try {
                final Enumeration<URL> systemResources = loader.getResources(DEFAULT_TEMPLATES_ROOT);
                if (systemResources.hasMoreElements()) {
                    while (systemResources.hasMoreElements()) {
                        final URL url = systemResources.nextElement();
                        if (processedUrls.contains(url)) {
                            continue;
                        }
                        processedUrls.add(url);
                        loadDefaultsFromRoot(url);
                    }
                }
            } catch (IOException e) {
                LOG.error(e);
            }
        }
    }
}
Also used : PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) PluginClassLoader(com.intellij.ide.plugins.cl.PluginClassLoader) UrlClassLoader(com.intellij.util.lang.UrlClassLoader) IOException(java.io.IOException) URL(java.net.URL) IdeaPluginDescriptorImpl(com.intellij.ide.plugins.IdeaPluginDescriptorImpl) PluginClassLoader(com.intellij.ide.plugins.cl.PluginClassLoader)

Example 5 with PluginDescriptor

use of com.intellij.openapi.extensions.PluginDescriptor in project intellij-community by JetBrains.

the class Configuration method loadDefaultInjections.

private static List<BaseInjection> loadDefaultInjections() {
    final List<Configuration> cfgList = new ArrayList<>();
    final Set<Object> visited = new THashSet<>();
    for (LanguageInjectionConfigBean configBean : Extensions.getExtensions(LanguageInjectionSupport.CONFIG_EP_NAME)) {
        PluginDescriptor descriptor = configBean.getPluginDescriptor();
        final ClassLoader loader = descriptor.getPluginClassLoader();
        try {
            final Enumeration<URL> enumeration = loader.getResources(configBean.getConfigUrl());
            if (enumeration == null || !enumeration.hasMoreElements()) {
                LOG.warn(descriptor.getPluginId() + ": " + configBean.getConfigUrl() + " was not found");
            } else {
                while (enumeration.hasMoreElements()) {
                    URL url = enumeration.nextElement();
                    // for DEBUG mode
                    if (!visited.add(url.getFile()))
                        continue;
                    InputStream stream = null;
                    try {
                        stream = url.openStream();
                        cfgList.add(load(stream));
                    } catch (Exception e) {
                        LOG.warn(e);
                    } finally {
                        if (stream != null) {
                            stream.close();
                        }
                    }
                }
            }
        } catch (Exception e) {
            LOG.warn(e);
        }
    }
    final List<BaseInjection> defaultInjections = new ArrayList<>();
    for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
        for (Configuration cfg : cfgList) {
            final List<BaseInjection> imported = cfg.getInjections(supportId);
            defaultInjections.addAll(imported);
        }
    }
    return defaultInjections;
}
Also used : InputStream(java.io.InputStream) THashSet(gnu.trove.THashSet) URL(java.net.URL) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) BaseInjection(org.intellij.plugins.intelliLang.inject.config.BaseInjection) PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) LanguageInjectionConfigBean(org.intellij.plugins.intelliLang.inject.LanguageInjectionConfigBean)

Aggregations

PluginDescriptor (com.intellij.openapi.extensions.PluginDescriptor)6 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)4 IOException (java.io.IOException)3 URL (java.net.URL)3 Nullable (org.jetbrains.annotations.Nullable)3 LanguageExtensionPoint (com.intellij.lang.LanguageExtensionPoint)2 ExtensionPoint (com.intellij.openapi.extensions.ExtensionPoint)2 SeparatorWithText (com.intellij.ui.SeparatorWithText)2 EmptyIcon (com.intellij.util.ui.EmptyIcon)2 com.intellij.codeInsight.daemon (com.intellij.codeInsight.daemon)1 IdeaPluginDescriptorImpl (com.intellij.ide.plugins.IdeaPluginDescriptorImpl)1 PluginClassLoader (com.intellij.ide.plugins.cl.PluginClassLoader)1 EditorSettingsExternalizable (com.intellij.openapi.editor.ex.EditorSettingsExternalizable)1 Extensions (com.intellij.openapi.extensions.Extensions)1 PluginId (com.intellij.openapi.extensions.PluginId)1 Configurable (com.intellij.openapi.options.Configurable)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Project (com.intellij.openapi.project.Project)1 ProjectManager (com.intellij.openapi.project.ProjectManager)1 Comparing (com.intellij.openapi.util.Comparing)1