Search in sources :

Example 1 with StringUtils

use of org.sonarlint.eclipse.core.internal.utils.StringUtils in project sonarlint-eclipse by SonarSource.

the class SkippedPluginsNotifier method notifyForSkippedPlugins.

public static void notifyForSkippedPlugins(Collection<PluginDetails> allPlugins, @Nullable String connectionId) {
    var skippedPlugins = allPlugins.stream().filter(p -> p.skipReason().isPresent() && !(p.skipReason().get() instanceof SkipReason.UnsatisfiedRuntimeRequirement)).collect(toList());
    if (!skippedPlugins.isEmpty()) {
        var skippedLanguages = skippedPlugins.stream().flatMap(p -> getLanguagesByPluginKey(p.key()).stream()).filter(l -> getEnabledLanguages().contains(l)).collect(toList());
        var longMessage = buildLongMessage(connectionId, skippedPlugins, skippedLanguages);
        String notificationTitle;
        String notificationMsg;
        if (skippedLanguages.isEmpty()) {
            notificationTitle = "Rules not available";
            notificationMsg = "Some rules are not available until some requirements are satisfied";
        } else {
            notificationTitle = "Language analysis not available";
            notificationMsg = String.format("%s analysis will not be available until some requirements are satisfied", skippedLanguages.stream().map(Language::getLanguageKey).map(StringUtils::capitalize).collect(Collectors.joining(", ")));
        }
        SonarLintNotifications.get().showNotification(new Notification(notificationTitle, notificationMsg, longMessage));
    }
}
Also used : Language.getLanguagesByPluginKey(org.sonarsource.sonarlint.core.commons.Language.getLanguagesByPluginKey) Collection(java.util.Collection) PluginDetails(org.sonarsource.sonarlint.core.client.api.common.PluginDetails) Language(org.sonarsource.sonarlint.core.commons.Language) StringUtils(org.sonarlint.eclipse.core.internal.utils.StringUtils) SkipReason(org.sonarsource.sonarlint.core.plugin.commons.SkipReason) Collectors(java.util.stream.Collectors) SonarLintUtils.getEnabledLanguages(org.sonarlint.eclipse.core.internal.utils.SonarLintUtils.getEnabledLanguages) Notification(org.sonarlint.eclipse.core.SonarLintNotifications.Notification) SonarLintNotifications(org.sonarlint.eclipse.core.SonarLintNotifications) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Nullable(org.eclipse.jdt.annotation.Nullable) Language(org.sonarsource.sonarlint.core.commons.Language) SkipReason(org.sonarsource.sonarlint.core.plugin.commons.SkipReason) Notification(org.sonarlint.eclipse.core.SonarLintNotifications.Notification)

Aggregations

Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 SonarLintNotifications (org.sonarlint.eclipse.core.SonarLintNotifications)1 Notification (org.sonarlint.eclipse.core.SonarLintNotifications.Notification)1 SonarLintUtils.getEnabledLanguages (org.sonarlint.eclipse.core.internal.utils.SonarLintUtils.getEnabledLanguages)1 StringUtils (org.sonarlint.eclipse.core.internal.utils.StringUtils)1 PluginDetails (org.sonarsource.sonarlint.core.client.api.common.PluginDetails)1 Language (org.sonarsource.sonarlint.core.commons.Language)1 Language.getLanguagesByPluginKey (org.sonarsource.sonarlint.core.commons.Language.getLanguagesByPluginKey)1 SkipReason (org.sonarsource.sonarlint.core.plugin.commons.SkipReason)1