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;
}
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());
}
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;
}
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);
}
}
}
}
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;
}
Aggregations