Skip to content

Commit

Permalink
Merge pull request #664 from JetBrains/231-mb-663
Browse files Browse the repository at this point in the history
No icons shown for item templates in Rider 2023.1 #663
maartenba authored Feb 17, 2023
2 parents e869c0b + 88d072a commit 72828a2
Showing 4 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
<ul>
<li>Azure Functions: Publish using wrong dotnet version (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/661">#661</a>)</li>
<li>Rider 2023.1 EAP 1 makes corelibs.log grow infinitely (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/657">#657</a>)</li>
<li>No icons shown for item templates in Rider 2023.1 (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/663">#663</a>)</li>
</ul>
</html>
]]>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022 JetBrains s.r.o.
// Copyright (c) 2020-2023 JetBrains s.r.o.
//
// All rights reserved.
//
@@ -33,14 +33,11 @@
using JetBrains.UI.RichText;
using JetBrains.UI.ThemedIcons;
using JetBrains.Util;
using JetBrains.Util.Logging;

namespace JetBrains.ReSharper.Azure.Daemon.RunMarkers
{
public abstract class FunctionAppRunMarkerGutterMark : IconGutterMarkType
public abstract class FunctionAppRunMarkerGutterMark : RunMarkerGutterMark
{
private static readonly ILogger ourLogger = Logger.GetLogger<FunctionAppRunMarkerGutterMark>();

public override IAnchor Priority => BulbMenuAnchors.PermanentBackgroundItems;

protected FunctionAppRunMarkerGutterMark([NotNull] IconId iconId) : base(iconId)
@@ -115,4 +112,4 @@ public FunctionAppMethodRunMarkerGutterMark() : base(FunctionAppRunMarkersThemed
{
}
}
}
}
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
<ul>
<li>Azure Functions: Publish using wrong dotnet version (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/661">#661</a>)</li>
<li>Rider 2023.1 EAP 1 makes corelibs.log grow infinitely (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/657">#657</a>)</li>
<li>No icons shown for item templates in Rider 2023.1 (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/663">#663</a>)</li>
</ul>
<p>[3.50.0-2022.3]</p>
<ul>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020 JetBrains s.r.o.
* Copyright (c) 2020-2023 JetBrains s.r.o.
*
* All rights reserved.
*
@@ -23,10 +23,9 @@
package org.jetbrains.icons

import com.intellij.httpClient.RestClientIcons
import com.intellij.openapi.util.CachedImageIcon
import com.intellij.openapi.util.IconLoader
import com.intellij.openapi.util.IconPathPatcher
import com.intellij.ui.RetrievableIcon
import com.intellij.util.ReflectionUtil
import icons.CommonIcons
import javax.swing.Icon

@@ -44,17 +43,14 @@ internal class RiderIconsPatcher : IconPathPatcher() {
IconLoader.installPathPatcher(RiderIconsPatcher())
}

private fun path(icon: Icon): String? {
val iconToProcess =
if (icon is RetrievableIcon) icon.retrieveIcon()
else icon
private data class IconAndClassLoader(val icon: Icon?, val classLoader: ClassLoader?)

if (iconToProcess is IconLoader.CachedImageIcon) {
return ReflectionUtil.getField(iconToProcess.javaClass, iconToProcess, String::class.java, "originalPath")
?: throw RuntimeException("originalPath field wasn't found in ${iconToProcess.javaClass.simpleName}")
}
private fun common(icon: Icon): IconAndClassLoader {
return IconAndClassLoader(icon, CommonIcons::class.java.classLoader)
}

return null
private fun restClient(icon: Icon): IconAndClassLoader {
return IconAndClassLoader(icon, RestClientIcons::class.java.classLoader)
}

private fun normalize(path: String) : String {
@@ -65,15 +61,19 @@ internal class RiderIconsPatcher : IconPathPatcher() {
}
}

override fun patchPath(path: String, classLoader: ClassLoader?): String? = myIconsOverrideMap[normalize(path)]
override fun patchPath(path: String, classLoader: ClassLoader?): String? {
val iconAndClassLoader = myIconsOverrideMap[normalize(path)] ?: return null
return (iconAndClassLoader.icon as? CachedImageIcon)?.originalPath
}

override fun getContextClassLoader(path: String, originalClassLoader: ClassLoader?): ClassLoader? =
if (myIconsOverrideMap.containsKey(normalize(path))) javaClass.classLoader
else originalClassLoader
override fun getContextClassLoader(path: String, originalClassLoader: ClassLoader?): ClassLoader? {
val iconAndClassLoader = myIconsOverrideMap[normalize(path)] ?: return null
return iconAndClassLoader.classLoader ?: originalClassLoader
}

private val myIconsOverrideMap = mapOf(
"/resharper/FunctionAppRunMarkers/RunFunctionApp.svg" to path(CommonIcons.AzureFunctions.FunctionAppRunConfiguration),
"/resharper/FunctionAppRunMarkers/Trigger.svg" to path(RestClientIcons.Http_requests_filetype),
"/resharper/FunctionAppTemplates/AzureFunctionsTrigger.svg" to path(CommonIcons.AzureFunctions.FunctionApp)
"/resharper/FunctionAppRunMarkers/RunFunctionApp.svg" to common(CommonIcons.AzureFunctions.FunctionAppRunConfiguration),
"/resharper/FunctionAppRunMarkers/Trigger.svg" to restClient(RestClientIcons.Http_requests_filetype),
"/resharper/FunctionAppTemplates/AzureFunctionsTrigger.svg" to common(CommonIcons.AzureFunctions.FunctionApp)
)
}

0 comments on commit 72828a2

Please sign in to comment.