1+ @file:Suppress(" UnstableApiUsage" )
2+
13package space.whitememory.pythoninlayparams
24
35import com.intellij.codeInsight.hints.InlayInfo
@@ -14,12 +16,6 @@ import com.jetbrains.python.psi.types.TypeEvalContext
1416@Suppress(" UnstableApiUsage" )
1517class PythonInlayParameterHintsProvider : InlayParameterHintsProvider {
1618
17- companion object {
18- val classHints = Option (" hints.classes.parameters" , { " Class hints" }, true )
19- val functionHints = Option (" hints.functions.parameters" , { " Function hints" }, true )
20- val hideOverlaps = Option (" hints.overlaps.parameters" , { " Hide overlaps" }, true )
21- }
22-
2319 private val forbiddenBuiltinFiles = setOf (" builtins.pyi" , " typing.pyi" )
2420
2521 override fun getDefaultBlackList () = setOf<String >()
@@ -28,7 +24,7 @@ class PythonInlayParameterHintsProvider : InlayParameterHintsProvider {
2824
2925 override fun getDescription () = " Help you pass correct arguments by showing parameter names at call sites"
3026
31- override fun getSupportedOptions () = listOf (classHints, functionHints, hideOverlaps )
27+ override fun getSupportedOptions () = listOf (classHints, functionHints, showOverlaps, showSingleHints )
3228
3329 override fun getProperty (key : String? ): String? {
3430 val prefix = " inlay.parameters.hints"
@@ -69,9 +65,9 @@ class PythonInlayParameterHintsProvider : InlayParameterHintsProvider {
6965 ! it.isSelf && it.parameter !is PySingleStarParameter && it.parameter !is PySlashParameter
7066 } ? : return inlayInfos
7167
72- // Don't need a hint if there's only one parameter,
73- // Make an exception for *args
74- if (resolvedParameters.size == 1 && ! resolvedParameters[ 0 ].isPositionalContainer) return inlayInfos
68+ // Don't need a hint if there's only one parameter, unless required by the settings or contains *args
69+ if (resolvedParameters.size == 1 && ! showSingleHints.isEnabled() && ! resolvedParameters[ 0 ].isPositionalContainer)
70+ return inlayInfos
7571
7672 resolvedParameters.zip(element.arguments).forEach { (param, arg) ->
7773 val paramName = param.name ? : return @forEach
@@ -115,7 +111,7 @@ class PythonInlayParameterHintsProvider : InlayParameterHintsProvider {
115111 argument.name?.lowercase() ? : return true
116112 }
117113
118- if (hideOverlaps .isEnabled() && paramName in argumentName) return false
114+ if (! showOverlaps .isEnabled() && paramName in argumentName) return false
119115 return paramName != argumentName
120116 }
121117
@@ -128,4 +124,9 @@ class PythonInlayParameterHintsProvider : InlayParameterHintsProvider {
128124 val fileName = callableType.callable?.containingFile?.name ? : return false
129125 return fileName in forbiddenBuiltinFiles
130126 }
131- }
127+ }
128+
129+ val classHints = Option (" hints.classes.parameters" , { " Class hints" }, true )
130+ val functionHints = Option (" hints.functions.parameters" , { " Function hints" }, true )
131+ val showOverlaps = Option (" hints.overlaps.parameters" , { " Show overlaps" }, false )
132+ val showSingleHints = Option (" hints.single.parameters" , { " Show single hints" }, false )
0 commit comments