IDEA-295555 Add null checks for PredefinedIconOverlayService

GitOrigin-RevId: c70a8b62313c78c6fa756bdff961e9a891c2f8d9
This commit is contained in:
Sergei Tachenov
2024-03-01 09:53:21 +02:00
committed by intellij-monorepo-bot
parent 0e966247ae
commit 8e6c2bc064
3 changed files with 9 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package com.intellij.ui.icons
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.openapi.components.serviceOrNull
import org.jetbrains.annotations.ApiStatus.Internal
import javax.swing.Icon
@@ -11,6 +12,9 @@ interface PredefinedIconOverlayService {
companion object {
@JvmStatic
fun getInstance(): PredefinedIconOverlayService = ApplicationManager.getApplication().service()
@JvmStatic
fun getInstanceOrNull(): PredefinedIconOverlayService? = ApplicationManager.getApplication().serviceOrNull()
}
fun createSymlinkIcon(icon: Icon): Icon

View File

@@ -573,7 +573,7 @@ private fun computeFileIconImpl(file: VirtualFile, project: Project?, flags: Int
}
}
if (file.`is`(VFileProperty.SYMLINK)) {
icon = PredefinedIconOverlayService.getInstance().createSymlinkIcon(icon)
icon = PredefinedIconOverlayService.getInstanceOrNull()?.createSymlinkIcon(icon) ?: icon
}
if (BitUtil.isSet(flags, Iconable.ICON_FLAG_READ_STATUS) &&
Registry.`is`("ide.locked.icon.enabled", false) &&

View File

@@ -242,7 +242,10 @@ public abstract class AbstractPsiBasedNode<Value> extends ProjectViewNode<Value>
Icon icon = original;
if (file.is(VFileProperty.SYMLINK)) {
icon = PredefinedIconOverlayService.getInstance().createSymlinkIcon(icon);
PredefinedIconOverlayService iconOverlayService = PredefinedIconOverlayService.getInstanceOrNull();
if (iconOverlayService != null) {
icon = iconOverlayService.createSymlinkIcon(icon);
}
}
Icon bookmarkIcon = getBookmarkIcon(project, file);