diff --git a/platform/vcs-api/api-dump.txt b/platform/vcs-api/api-dump.txt index 95d6e14f31f6..b730983c50bd 100644 --- a/platform/vcs-api/api-dump.txt +++ b/platform/vcs-api/api-dump.txt @@ -1209,7 +1209,8 @@ c:com.intellij.openapi.vcs.changes.ExternallyRenamedChange - setRenamedOrMovedTarget(com.intellij.openapi.vcs.FilePath):V com.intellij.openapi.vcs.changes.FilePathIconProvider - sf:EP_NAME:com.intellij.openapi.extensions.ExtensionPointName -- a:getIcon(com.intellij.openapi.vcs.FilePath,com.intellij.openapi.project.Project):javax.swing.Icon +- getIcon(com.intellij.openapi.vcs.FilePath,com.intellij.openapi.project.Project):javax.swing.Icon +- getIcon(com.intellij.openapi.vcs.FilePath,Z,com.intellij.openapi.project.Project):javax.swing.Icon f:com.intellij.openapi.vcs.changes.FilePathsHelper - s:convertPath(com.intellij.openapi.vcs.FilePath):java.lang.String - s:convertPath(java.lang.String):java.lang.String diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/FilePathIconProvider.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/FilePathIconProvider.java index 6d5c5aa46c4f..fffdd194397e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/FilePathIconProvider.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/FilePathIconProvider.java @@ -22,10 +22,25 @@ public interface FilePathIconProvider { ExtensionPointName.create("com.intellij.openapi.vcs.changes.ui.filePathIconProvider"); /** + * @deprecated Do not call this method directly because the `isDirectory` property of filePath is not reliable enough. + * Use {@link #getIcon(FilePath, boolean, Project)} instead. + * * @param filePath file for which icon is shown * @param project current opened project * @return {@code null} if there is no appropriate icon for given file path */ - @Nullable - Icon getIcon(@NotNull FilePath filePath, @Nullable Project project); + @Deprecated(forRemoval = true) + default @Nullable Icon getIcon(@NotNull FilePath filePath, @Nullable Project project) { + throw new UnsupportedOperationException("Implementors must override at least one of getIcon() methods"); + } + + /** + * @param filePath file for which icon is shown + * @param isDirectory flag that indicates if file is directory or not + * @param project current opened project + * @return {@code null} if there is no appropriate icon for given file path + */ + default @Nullable Icon getIcon(@NotNull FilePath filePath, boolean isDirectory, @Nullable Project project) { + return getIcon(filePath, project); + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNodeRenderer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNodeRenderer.java index 978c9c57c428..79818826e231 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNodeRenderer.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNodeRenderer.java @@ -103,7 +103,7 @@ public class ChangesBrowserNodeRenderer extends ColoredTreeCellRenderer { * @param isDirectory directory flag is specified explicitly, as {@link FilePath#isDirectory()} can be unreliable */ public void setIcon(@NotNull FilePath filePath, boolean isDirectory) { - Icon icon = FilePathIconProvider.EP_NAME.computeSafeIfAny(provider -> provider.getIcon(filePath, myProject)); + Icon icon = FilePathIconProvider.EP_NAME.computeSafeIfAny(provider -> provider.getIcon(filePath, isDirectory, myProject)); if (icon != null) { setIcon(icon); return; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/RepositoryBrowser.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/RepositoryBrowser.kt index 99a9513d41bc..f50a9c804797 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/RepositoryBrowser.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/RepositoryBrowser.kt @@ -102,7 +102,7 @@ class RepositoryBrowserPanel( } if (file is VcsVirtualFile) { val localPath = getLocalFilePath(file) - val icon = FilePathIconProvider.EP_NAME.computeSafeIfAny { it.getIcon(localPath, project) } + val icon = FilePathIconProvider.EP_NAME.computeSafeIfAny { it.getIcon(localPath, false, project) } if (icon != null) return icon } return FileTypeManager.getInstance().getFileTypeByFileName(file.nameSequence).icon