IDEA-314842 Shellcheck for ARM64, update to 0.10.0

Also improve notifications handling

GitOrigin-RevId: aefec0eb4fb82166e23edfaea987f7107a974550
This commit is contained in:
Vladislav Rassokhin
2024-03-20 14:54:06 +01:00
committed by intellij-monorepo-bot
parent 89ca23e9fd
commit 349ec79fbf
3 changed files with 32 additions and 30 deletions

View File

@@ -8,7 +8,6 @@ import com.intellij.execution.util.ExecUtil;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationAction;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
@@ -204,21 +203,19 @@ public final class ShShfmtFormatterUtil {
NotificationAction.createSimple(messagePointer("sh.update"), () -> {
notification.expire();
download(project,
() -> Notifications.Bus
.notify(NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.fmt.success.update"),
NotificationType.INFORMATION)
.setDisplayId(ShNotificationDisplayIds.UPDATE_FORMATTER_SUCCESS)),
() -> Notifications.Bus
.notify(NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.fmt.cannot.update"),
NotificationType.ERROR)
.setDisplayId(ShNotificationDisplayIds.UPDATE_FORMATTER_ERROR)),
() -> NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.fmt.success.update"),
NotificationType.INFORMATION)
.setDisplayId(ShNotificationDisplayIds.UPDATE_FORMATTER_SUCCESS).notify(project),
() -> NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.fmt.cannot.update"),
NotificationType.ERROR)
.setDisplayId(ShNotificationDisplayIds.UPDATE_FORMATTER_ERROR).notify(project),
true);
}));
notification.addAction(NotificationAction.createSimple(messagePointer("sh.skip.version"), () -> {
notification.expire();
ShSettings.setSkippedShfmtVersion(SHFMT_VERSION);
}));
Notifications.Bus.notify(notification, project);
notification.notify(project);
}
/**

View File

@@ -8,7 +8,6 @@ import com.intellij.execution.util.ExecUtil;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationAction;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
@@ -52,7 +51,7 @@ public final class ShShellcheckUtil {
private static final Key<Boolean> UPDATE_NOTIFICATION_SHOWN = Key.create("SHELLCHECK_UPDATE");
static final @NlsSafe String SHELLCHECK = "shellcheck";
static final @NlsSafe String SHELLCHECK_BIN = SystemInfo.isWindows ? SHELLCHECK + ".exe" : SHELLCHECK;
private static final String SHELLCHECK_VERSION = "0.7.1";
private static final String SHELLCHECK_VERSION = "0.10.0";
private static final String SHELLCHECK_ARTIFACT_VERSION = SHELLCHECK_VERSION + "-1";
private static final String SHELLCHECK_ARCHIVE_EXTENSION = ".tar.gz";
private static final String SHELLCHECK_URL =
@@ -212,21 +211,21 @@ public final class ShShellcheckUtil {
NotificationAction.createSimple(messagePointer("sh.update"), () -> {
notification.expire();
download(project,
() -> Notifications.Bus
.notify(NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.shellcheck.success.update"),
NotificationType.INFORMATION)
.setDisplayId(ShNotificationDisplayIds.UPDATE_SHELLCHECK_SUCCESS)),
() -> Notifications.Bus
.notify(NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.shellcheck.cannot.update"),
NotificationType.ERROR)
.setDisplayId(ShNotificationDisplayIds.UPDATE_SHELLCHECK_ERROR)),
() -> NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.shellcheck.success.update"),
NotificationType.INFORMATION)
.setDisplayId(ShNotificationDisplayIds.UPDATE_SHELLCHECK_SUCCESS)
.notify(project),
() -> NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.shellcheck.cannot.update"),
NotificationType.ERROR)
.setDisplayId(ShNotificationDisplayIds.UPDATE_SHELLCHECK_ERROR)
.notify(project),
true);
}));
notification.addAction(NotificationAction.createSimple(messagePointer("sh.skip.version"), () -> {
notification.expire();
ShSettings.setSkippedShellcheckVersion(SHELLCHECK_VERSION);
}));
Notifications.Bus.notify(notification, project);
notification.notify(project);
}
/**
@@ -289,7 +288,14 @@ public final class ShShellcheckUtil {
static @NlsSafe @Nullable String getShellcheckDistributionLink() {
String platform = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : SystemInfo.isLinux ? "linux" : null;
if (platform == null) return null;
return SHELLCHECK_URL + SHELLCHECK_ARTIFACT_VERSION + "/shellcheck-" + SHELLCHECK_ARTIFACT_VERSION + '-' + platform + SHELLCHECK_ARCHIVE_EXTENSION;
String arch = SystemInfo.isAarch64 ? "arm64" : "amd64";
if (platform.equals("windows") && arch.equals("arm64")) {
// Unsupported OS + Arch
return null;
}
return SHELLCHECK_URL +
SHELLCHECK_ARTIFACT_VERSION +
"/shellcheck-" + SHELLCHECK_ARTIFACT_VERSION + '-' + platform + '-' + arch + SHELLCHECK_ARCHIVE_EXTENSION;
}
@SuppressWarnings("SpellCheckingInspection")

View File

@@ -2,9 +2,7 @@
package com.intellij.sh.shellcheck;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
@@ -22,6 +20,7 @@ import javax.swing.*;
import java.util.function.Function;
import static com.intellij.sh.ShBundle.message;
import static com.intellij.sh.ShLanguage.NOTIFICATION_GROUP;
import static com.intellij.sh.shellcheck.ShShellcheckUtil.isValidPath;
public class ShellcheckSetupNotificationProvider implements EditorNotificationProvider {
@@ -37,14 +36,14 @@ public class ShellcheckSetupNotificationProvider implements EditorNotificationPr
EditorNotifications.getInstance(project).updateAllNotifications();
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null) DaemonCodeAnalyzer.getInstance(project).restart(psiFile);
Notifications.Bus.notify(new Notification(message("sh.shell.script"), message("sh.shell.script"), message("sh.shellcheck.success.install"),
NotificationType.INFORMATION));
NOTIFICATION_GROUP.createNotification(message("sh.shell.script"),
message("sh.shellcheck.success.install"),
NotificationType.INFORMATION).notify(project);
};
Runnable onFailure = () -> Notifications.Bus.notify(new Notification(message("sh.shell.script"), message("sh.shell.script"),
message("sh.shellcheck.cannot.download"),
NotificationType.ERROR));
Runnable onFailure = () -> NOTIFICATION_GROUP.createNotification(message("sh.shell.script"),
message("sh.shellcheck.cannot.download"),
NotificationType.ERROR).notify(project);
panel.createActionLabel(message("sh.install"), () -> ShShellcheckUtil.download(project, onSuccess, onFailure));
//noinspection DialogTitleCapitalization
panel.createActionLabel(message("sh.no.thanks"), () -> {
ShSettings.setShellcheckPath(ShSettings.I_DO_MIND_SUPPLIER.get());
EditorNotifications.getInstance(project).updateAllNotifications();