use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.
the class CheckRequiredPluginsActivity method runCheck.
public static void runCheck(@NotNull final Project project) {
List<DependencyOnPlugin> dependencies = ExternalDependenciesManager.getInstance(project).getDependencies(DependencyOnPlugin.class);
if (dependencies.isEmpty())
return;
List<String> customRepositories = UpdateSettings.getInstance().getStoredPluginHosts();
final List<String> errorMessages = new ArrayList<>();
final List<String> missingCustomRepositories = new ArrayList<>();
final List<IdeaPluginDescriptor> disabled = new ArrayList<>();
final List<PluginId> notInstalled = new ArrayList<>();
for (DependencyOnPlugin dependency : dependencies) {
PluginId pluginId = PluginId.getId(dependency.getPluginId());
String channel = dependency.getChannel();
String customRepository = getCustomRepository(pluginId, channel);
if (!StringUtil.isEmpty(channel) && customRepositoryNotSpecified(customRepositories, customRepository)) {
errorMessages.add("Custom repository '" + customRepository + "' required for '" + project.getName() + "' project isn't installed.");
missingCustomRepositories.add(customRepository);
}
IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
if (plugin == null) {
errorMessages.add("Plugin '" + dependency.getPluginId() + "' required for '" + project.getName() + "' project isn't installed.");
notInstalled.add(pluginId);
continue;
}
if (!plugin.isEnabled()) {
errorMessages.add("Plugin '" + plugin.getName() + "' required for '" + project.getName() + "' project is disabled.");
disabled.add(plugin);
continue;
}
String minVersion = dependency.getMinVersion();
if (minVersion != null && VersionComparatorUtil.compare(plugin.getVersion(), minVersion) < 0) {
errorMessages.add("Project '" + project.getName() + "' requires plugin '" + plugin.getName() + "' version '" + minVersion + "' or higher, but '" + plugin.getVersion() + "' is installed.");
}
String maxVersion = dependency.getMaxVersion();
if (maxVersion != null && VersionComparatorUtil.compare(plugin.getVersion(), maxVersion) > 0) {
errorMessages.add("Project '" + project.getName() + "' requires plugin '" + plugin.getName() + "' version '" + maxVersion + "' or lower, but '" + plugin.getVersion() + "' is installed.");
}
}
if (!errorMessages.isEmpty()) {
if (!missingCustomRepositories.isEmpty()) {
errorMessages.add("<a href=\"addRepositories\">Add custom repositories and install required plugins</a>");
} else if (!disabled.isEmpty() && notInstalled.isEmpty()) {
String plugins = disabled.size() == 1 ? disabled.get(0).getName() : "required plugins";
errorMessages.add("<a href=\"enable\">Enable " + plugins + "</a>");
} else if (!disabled.isEmpty() || !notInstalled.isEmpty()) {
errorMessages.add("<a href=\"install\">Install required plugins</a>");
}
NOTIFICATION_GROUP.createNotification("Required plugins weren't loaded", StringUtil.join(errorMessages, "<br>"), NotificationType.ERROR, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if ("addRepositories".equals(event.getDescription())) {
UpdateSettings.getInstance().getStoredPluginHosts().addAll(missingCustomRepositories);
}
if ("enable".equals(event.getDescription())) {
notification.expire();
for (IdeaPluginDescriptor descriptor : disabled) {
PluginManagerCore.enablePlugin(descriptor.getPluginId().getIdString());
}
PluginManagerMain.notifyPluginsUpdated(project);
} else if ("install".equals(event.getDescription()) || "addRepositories".equals(event.getDescription())) {
Set<String> pluginIds = new HashSet<>();
for (IdeaPluginDescriptor descriptor : disabled) {
pluginIds.add(descriptor.getPluginId().getIdString());
}
for (PluginId pluginId : notInstalled) {
pluginIds.add(pluginId.getIdString());
}
PluginsAdvertiser.installAndEnablePlugins(pluginIds, () -> notification.expire());
}
}
}
}).notify(project);
}
}
use of com.intellij.openapi.extensions.PluginId 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.PluginId 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);
}
use of com.intellij.openapi.extensions.PluginId in project Perl5-IDEA by Camelcade.
the class YoutrackErrorHandler method doSubmit.
private SubmittedReportInfo doSubmit(IdeaLoggingEvent[] ideaLoggingEvents, String addInfo, Component component) {
final DataContext dataContext = DataManager.getInstance().getDataContext(component);
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final IdeaLoggingEvent ideaLoggingEvent = ideaLoggingEvents[0];
final String throwableText = ideaLoggingEvent.getThrowableText();
String description = throwableText.substring(0, Math.min(Math.max(80, throwableText.length()), 80));
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") Integer signature = ideaLoggingEvent.getThrowable().getStackTrace()[0].hashCode();
String existing = findExisting(signature);
if (existing != null) {
final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + existing, existing, DUPLICATE);
popupResultInfo(reportInfo, project);
return reportInfo;
}
@NonNls StringBuilder descBuilder = new StringBuilder();
descBuilder.append("Build: ").append(ApplicationInfo.getInstance().getBuild()).append('\n');
descBuilder.append("OS: ").append(SystemInfo.OS_NAME).append(" ").append(SystemInfo.OS_ARCH).append(" ").append(SystemInfo.OS_VERSION).append('\n');
descBuilder.append("Java Vendor: ").append(SystemInfo.JAVA_VENDOR).append('\n');
descBuilder.append("Java Version: ").append(SystemInfo.JAVA_VERSION).append('\n');
descBuilder.append("Java Arch: ").append(SystemInfo.ARCH_DATA_MODEL).append('\n');
descBuilder.append("Java Runtime Version: ").append(SystemInfo.JAVA_RUNTIME_VERSION).append('\n');
String affectedVersion = null;
Throwable t = ideaLoggingEvent.getThrowable();
final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
if (pluginId != null) {
final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
if (ideaPluginDescriptor != null) {
descBuilder.append("Plugin Version: ").append(ideaPluginDescriptor.getVersion()).append("\n");
affectedVersion = ideaPluginDescriptor.getVersion();
}
}
if (addInfo == null) {
addInfo = "<none>";
}
descBuilder.append("Description: ").append(addInfo);
for (IdeaLoggingEvent e : ideaLoggingEvents) {
descBuilder.append("\n\n").append(e.toString());
}
String result = submit(description, descBuilder.toString(), affectedVersion);
LOGGER.info("Error submitted, response: " + result);
if (result == null) {
return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
}
String ResultString = null;
try {
Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
Matcher regexMatcher = regex.matcher(result);
if (regexMatcher.find()) {
ResultString = regexMatcher.group(1);
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
if (ResultString == null) {
return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
}
final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + ResultString, ResultString, NEW_ISSUE);
if (signature != 0) {
runCommand(ResultString, "Exception Signature " + signature);
}
popupResultInfo(reportInfo, project);
return reportInfo;
}
use of com.intellij.openapi.extensions.PluginId in project moe-ide-integration by multi-os-engine.
the class MOESdkPlugin method getPluginVersion.
public static String getPluginVersion() {
String version = "0.0.0.0";
PluginId pluginId = PluginManager.getPluginByClassName(MOESdkPlugin.class.getCanonicalName());
if (pluginId != null) {
IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
if (plugin != null) {
version = plugin.getVersion();
}
}
return version;
}
Aggregations