File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
kotlin/com/github/pyvenvmanage Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 33## [ Unreleased]
44
55- Extend compatibility for PyCharm Professional
6+ - Fix Icon provider did not survive migration to v2
67
78## [ 2.0.0] - 2024-08-12
89
Original file line number Diff line number Diff line change 1+ package com.github.pyvenvmanage
2+
3+ import javax.swing.Icon
4+
5+ import com.intellij.ide.IconLayerProvider
6+ import com.intellij.ide.IconProvider
7+ import com.intellij.openapi.util.Iconable
8+ import com.intellij.psi.PsiDirectory
9+ import com.intellij.psi.PsiElement
10+
11+ import com.jetbrains.python.icons.PythonIcons.Python.Virtualenv
12+ import com.jetbrains.python.sdk.PythonSdkUtil
13+
14+ class VenvIconProvider :
15+ IconProvider (),
16+ IconLayerProvider {
17+ override fun getLayerDescription (): String = " Python virtual environment"
18+
19+ override fun getIcon (
20+ element : PsiElement ,
21+ flags : Int ,
22+ ): Icon ? = determineIcon(element)
23+
24+ override fun getLayerIcon (
25+ element : Iconable ,
26+ isLocked : Boolean ,
27+ ): Icon ? = determineIcon(element)
28+
29+ private fun determineIcon (element : Any ): Icon ? {
30+ if (element is PsiDirectory ) {
31+ val venvRootPath = element.virtualFile.path
32+ if (PythonSdkUtil .getPythonExecutable(venvRootPath) != null ) {
33+ return Virtualenv
34+ }
35+ }
36+ return null
37+ }
38+ }
Original file line number Diff line number Diff line change 88
99 <extensions defaultExtensionNs =" com.intellij" >
1010 <notificationGroup id =" Python SDK change" displayType =" BALLOON" />
11+ <iconProvider implementation =" com.github.pyvenvmanage.VenvIconProvider" />
12+ <iconLayerProvider implementation =" com.github.pyvenvmanage.VenvIconProvider" />
1113 </extensions >
1214
1315 <actions >
3032 <add-to-group group-id =" ProjectViewPopupMenu" anchor =" last" />
3133 </action >
3234 </actions >
35+
3336</idea-plugin >
You can’t perform that action at this time.
0 commit comments