From 2685e716dc722ccc0100ae5df4e1580c09fc8f5c Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Wed, 15 May 2019 15:30:47 +0300 Subject: [PATCH] fix NPE in installers, in headless mode we don't have editor notifications GitOrigin-RevId: 889dd1d777fea95fcfe862732262709c8d867815 --- .../sh/shellcheck/ShShellcheckInspection.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/sh/src/com/intellij/sh/shellcheck/ShShellcheckInspection.java b/plugins/sh/src/com/intellij/sh/shellcheck/ShShellcheckInspection.java index 9871b1f18588..bbb52efe6d52 100644 --- a/plugins/sh/src/com/intellij/sh/shellcheck/ShShellcheckInspection.java +++ b/plugins/sh/src/com/intellij/sh/shellcheck/ShShellcheckInspection.java @@ -17,7 +17,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; public class ShShellcheckInspection extends LocalInspectionTool implements ExternalAnnotatorBatchInspection { public static final String SHORT_NAME = "ShellCheck"; @@ -48,7 +51,10 @@ public class ShShellcheckInspection extends LocalInspectionTool implements Exter } Project project = ProjectUtil.guessCurrentProject(myOptionsPanel); - EditorNotifications.getInstance(project).updateAllNotifications(); + EditorNotifications editorNotifications = EditorNotifications.getInstance(project); + if (editorNotifications != null) { + editorNotifications.updateAllNotifications(); + } } @Nullable @@ -79,7 +85,7 @@ public class ShShellcheckInspection extends LocalInspectionTool implements Exter @NotNull static ShShellcheckInspection findShShellcheckInspection(@NotNull PsiElement element) { InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getCurrentProfile(); - ShShellcheckInspection tool = (ShShellcheckInspection) profile.getUnwrappedTool(SHORT_NAME, element); + ShShellcheckInspection tool = (ShShellcheckInspection)profile.getUnwrappedTool(SHORT_NAME, element); return tool == null ? new ShShellcheckInspection() : tool; } } \ No newline at end of file