Skip to content

Commit

Permalink
Handle null function returned from CLion code (#5248)
Browse files Browse the repository at this point in the history
method is declared as @nullable in CLion SDK
though sdkcompat ignores this hint. fixes #5247.
  • Loading branch information
ujohnny authored Aug 31, 2023
1 parent 7fff912 commit 916324c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.cidr.cpp.cmake.workspace.CMakeNotificationProvider;

import java.util.function.Function;
import javax.annotation.Nullable;
import javax.swing.*;

// #api223
Expand All @@ -16,7 +18,15 @@ public CMakeNotificationProviderWrapper(){
this.value = new CMakeNotificationProvider();
}

@Nullable
public JComponent createNotificationPanel(VirtualFile virtualFile, FileEditor fileEditor, Project project) {
return this.value.collectNotificationData(project, virtualFile).apply(fileEditor);
Function<? super FileEditor, ? extends JComponent> notificationProducer =
this.value.collectNotificationData(project, virtualFile);

if (notificationProducer != null) {
return notificationProducer.apply(fileEditor);
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.cidr.cpp.cmake.workspace.CMakeNotificationProvider;

import java.util.function.Function;
import javax.annotation.Nullable;
import javax.swing.*;

// #api223
Expand All @@ -16,7 +18,15 @@ public CMakeNotificationProviderWrapper(){
this.value = new CMakeNotificationProvider();
}

@Nullable
public JComponent createNotificationPanel(VirtualFile virtualFile, FileEditor fileEditor, Project project) {
return this.value.collectNotificationData(project, virtualFile).apply(fileEditor);
Function<? super FileEditor, ? extends JComponent> notificationProducer =
this.value.collectNotificationData(project, virtualFile);

if (notificationProducer != null) {
return notificationProducer.apply(fileEditor);
}

return null;
}
}

0 comments on commit 916324c

Please sign in to comment.