Skip to content

Commit

Permalink
Fix NPE in LocalChangesWouldBeOverwrittenHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Apr 30, 2024
1 parent a9ddb43 commit b12890f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
build/
*.class
*.crt
.DS_Store
/.DS_Store/
**/.gradle/
/gradlew.bat
/*.hprof
/*.hprof.*/
/.idea/
/.intellijPlatform/
*.pem
.sdkmanrc
2 changes: 2 additions & 0 deletions CHANGE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 6 additions & 7 deletions config/checker/com.intellij.astub
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 1 addition & 5 deletions config/checker/git4idea.astub
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> relativePaths,
@Untainted String operation, @Tainted @Nullable String description);
}

class LocalChangesWouldBeOverwrittenHelper {
static void showErrorNotification(Project project, @Nullable String displayId,
VirtualFile root, String operationName, Collection<String> relativeFilePaths);
}
1 change: 1 addition & 0 deletions config/checker/java.lang.astub
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ class Constructor<T> {
}

class Method {
// The first param may be null in case of static method calls.
Object invoke(@Nullable Object obj, Object... args);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +169,7 @@ private void handleResult(

} else if (localChangesDetector.wasMessageDetected()) {
LocalChangesWouldBeOverwrittenHelper.showErrorNotification(project,
/* displayId */ null,
LOCAL_CHANGES_DETECTED,
gitRepository.getRoot(),
getOperationName(),
localChangesDetector.getRelativeFilePaths());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit b12890f

Please sign in to comment.