diff --git a/.gitignore b/.gitignore index 50aba17dd..21fad8b89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,12 @@ build/ *.class *.crt -.DS_Store +/.DS_Store/ **/.gradle/ /gradlew.bat /*.hprof /*.hprof.*/ /.idea/ +/.intellijPlatform/ *.pem .sdkmanrc diff --git a/CHANGE-NOTES.md b/CHANGE-NOTES.md index 075dcbab8..c2ce0fac5 100644 --- a/CHANGE-NOTES.md +++ b/CHANGE-NOTES.md @@ -2,6 +2,8 @@ ## v4.2.1 +- Fixed: plugin crashing on `NullPointerException` when a warning about overwriting uncommitted files was going to be displayed + ## v4.2.0 - Added: support for IntelliJ 2024.1. - Fixed: corner cases in determining fork point for a branch. diff --git a/config/checker/com.intellij.astub b/config/checker/com.intellij.astub index b9f6dc309..58976c657 100644 --- a/config/checker/com.intellij.astub +++ b/config/checker/com.intellij.astub @@ -152,7 +152,7 @@ class NotificationAction { } class NotificationGroup { - Notification createNotification(@Tainted String title, @Tainted String content, NotificationType type, @Nullable NotificationListener listener); + Notification createNotification(@Tainted String title, @Tainted String content, NotificationType type, NotificationListener listener); Notification createNotification(@Tainted String title, @Tainted String content, NotificationType type); } @@ -378,6 +378,7 @@ package com.intellij.openapi.vcs; // Experimentally verified that these methods can be called from outside UI thread. @AlwaysSafe class VcsNotifier { + // For some reason, Nullness Checker doesn't see org.jetbrains.annotations.Nullable annotations on displayId arguments here. Notification notifyError(@Nullable String displayId, @Tainted String title, @Tainted String message); Notification notifySuccess(@Nullable String displayId, @Tainted String title, @Tainted String message); Notification notifyWeakError(@Nullable String displayId, @Tainted String title, @Tainted String message); @@ -417,13 +418,11 @@ package com.intellij.openapi.vcs.history; package com.intellij.openapi.vfs; class VirtualFile { - @NonNull VirtualFile createChildData(@Nullable Object requestor, String name); - - void delete(@Nullable Object requestor); + @NonNull VirtualFile createChildData(Object requestor, String name); @Nullable VirtualFile getParent(); - OutputStream getOutputStream(@Nullable Object requestor); + OutputStream getOutputStream(Object requestor); } class VfsUtilCore { @@ -449,7 +448,7 @@ interface BulkFileListener { @UIPackage package com.intellij.openapi.wm; interface ToolWindow { - void activate(@Nullable @UI Runnable runnable); + void activate(@UI Runnable runnable); @SafeEffect @Nullable ContentManager getContentManagerIfCreated(); @@ -680,7 +679,7 @@ class UIUtil { package com.intellij.vcs.log.graph.api.elements; class GraphEdge { - GraphEdge(@NonNegative Integer upNodeIndex, @NonNegative Integer downNodeIndex, @Nullable Integer targetId, GraphEdgeType type); + GraphEdge(@NonNegative Integer upNodeIndex, @NonNegative Integer downNodeIndex, Integer targetId, GraphEdgeType type); GraphEdge createNormalEdge(@NonNegative int nodeIndex1, @NonNegative int nodeIndex2, GraphEdgeType type); } diff --git a/config/checker/git4idea.astub b/config/checker/git4idea.astub index bae8f3139..8a48f903a 100644 --- a/config/checker/git4idea.astub +++ b/config/checker/git4idea.astub @@ -47,11 +47,7 @@ interface GitRepositoryChangeListener { package git4idea.util; class GitUntrackedFilesHelper { + // For some reason, Nullness Checker doesn't see org.jetbrains.annotations.Nullable annotation on description argument here. static void notifyUntrackedFilesOverwrittenBy(Project project, VirtualFile root, Collection relativePaths, @Untainted String operation, @Tainted @Nullable String description); } - -class LocalChangesWouldBeOverwrittenHelper { - static void showErrorNotification(Project project, @Nullable String displayId, - VirtualFile root, String operationName, Collection relativeFilePaths); -} diff --git a/config/checker/java.lang.astub b/config/checker/java.lang.astub index 8c4e6a3aa..e8440ecf2 100644 --- a/config/checker/java.lang.astub +++ b/config/checker/java.lang.astub @@ -7,5 +7,6 @@ class Constructor { } class Method { + // The first param may be null in case of static method calls. Object invoke(@Nullable Object obj, Object... args); } diff --git a/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/GitCommandUpdatingCurrentBranchBackgroundable.java b/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/GitCommandUpdatingCurrentBranchBackgroundable.java index bc6432812..dfb794c4b 100644 --- a/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/GitCommandUpdatingCurrentBranchBackgroundable.java +++ b/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/GitCommandUpdatingCurrentBranchBackgroundable.java @@ -2,6 +2,7 @@ import static com.intellij.notification.NotificationType.INFORMATION; import static com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getString; +import static git4idea.GitNotificationIdsHolder.LOCAL_CHANGES_DETECTED; import static git4idea.commands.GitLocalChangesWouldBeOverwrittenDetector.Operation.MERGE; import static git4idea.update.GitUpdateSessionKt.getBodyForUpdateNotification; import static git4idea.update.GitUpdateSessionKt.getTitleForUpdateNotification; @@ -168,7 +169,7 @@ private void handleResult( } else if (localChangesDetector.wasMessageDetected()) { LocalChangesWouldBeOverwrittenHelper.showErrorNotification(project, - /* displayId */ null, + LOCAL_CHANGES_DETECTED, gitRepository.getRoot(), getOperationName(), localChangesDetector.getRelativeFilePaths()); diff --git a/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/ResetCurrentToRemoteBackgroundable.java b/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/ResetCurrentToRemoteBackgroundable.java index 896979471..721981a01 100644 --- a/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/ResetCurrentToRemoteBackgroundable.java +++ b/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/backgroundables/ResetCurrentToRemoteBackgroundable.java @@ -4,6 +4,7 @@ import static com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getNonHtmlString; import static com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getString; import static com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils.getRootDirectory; +import static git4idea.GitNotificationIdsHolder.LOCAL_CHANGES_DETECTED; import static git4idea.commands.GitLocalChangesWouldBeOverwrittenDetector.Operation.RESET; import com.intellij.dvcs.DvcsUtil; @@ -72,7 +73,7 @@ public void doRun(ProgressIndicator indicator) { } else if (localChangesDetector.wasMessageDetected()) { LocalChangesWouldBeOverwrittenHelper.showErrorNotification(project, - /* displayId */ null, + LOCAL_CHANGES_DETECTED, gitRepository.getRoot(), /* operationName */ "Reset", localChangesDetector.getRelativeFilePaths()); diff --git a/frontend/file/src/main/java/com/virtuslab/gitmachete/frontend/file/MacheteFileWriter.java b/frontend/file/src/main/java/com/virtuslab/gitmachete/frontend/file/MacheteFileWriter.java index ba03affea..f7802a4ca 100644 --- a/frontend/file/src/main/java/com/virtuslab/gitmachete/frontend/file/MacheteFileWriter.java +++ b/frontend/file/src/main/java/com/virtuslab/gitmachete/frontend/file/MacheteFileWriter.java @@ -10,7 +10,6 @@ import lombok.CustomLog; import lombok.val; import org.checkerframework.checker.guieffect.qual.UIEffect; -import org.checkerframework.checker.nullness.qual.Nullable; import com.virtuslab.branchlayout.api.BranchLayout; import com.virtuslab.branchlayout.api.readwrite.IBranchLayoutWriter; @@ -35,7 +34,7 @@ public static void writeBranchLayout( IBranchLayoutWriter branchLayoutWriter, BranchLayout branchLayout, boolean backupOldFile, - @Nullable Object requestor) throws IOException { + Object requestor) throws IOException { LOG.debug(() -> "Writing branch layout to (${path}), branchLayout = ${branchLayout}, backupOldFile = ${backupOldFile}"); val parentPath = path.getParent();