Skip to content

Commit c07ac4f

Browse files
committed
Minor packaging improvements and fixes
1 parent ec3fb73 commit c07ac4f

10 files changed

Lines changed: 34 additions & 36 deletions

src/main/kotlin/space/whitememory/pythoninlayparams/PythonInlayParameterHintsProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class PythonInlayParameterHintsProvider : InlayParameterHintsProvider {
2929
override fun getSupportedOptions() = listOf(classHints, functionHints, lambdaHints)
3030

3131
override fun getProperty(key: String?): String? {
32-
val prefix = "inlay.parameters"
32+
val prefix = "inlay.parameters.hints"
3333
return when (key) {
34-
"$prefix.hints.classes.parameters" -> "Show parameter names for class constructors and dataclasses."
35-
"$prefix.hints.functions.parameters" -> "Show parameter names for function and method calls."
36-
"$prefix.hints.lambdas.parameters" -> "Show parameter names for lambda calls."
34+
"$prefix.classes.parameters" -> "Show parameter names for class constructors and dataclasses."
35+
"$prefix.functions.parameters" -> "Show parameter names for function and method calls."
36+
"$prefix.lambdas.parameters" -> "Show parameter names for lambda calls."
3737
else -> null
3838
}
3939
}

src/main/kotlin/space/whitememory/pythoninlayparams/AbstractPythonInlayTypeHintsCollector.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/AbstractPythonInlayTypeHintsCollector.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package space.whitememory.pythoninlayparams
1+
package space.whitememory.pythoninlayparams.types
22

33
import com.intellij.codeInsight.hints.FactoryInlayHintsCollector
44
import com.intellij.codeInsight.hints.InlayHintsSink
55
import com.intellij.openapi.editor.Editor
66
import com.intellij.psi.PsiElement
77
import com.jetbrains.python.psi.PyElement
88
import com.jetbrains.python.psi.types.TypeEvalContext
9-
import space.whitememory.pythoninlayparams.hints.HintGenerator
10-
import space.whitememory.pythoninlayparams.hints.HintResolver
9+
import space.whitememory.pythoninlayparams.types.hints.HintGenerator
10+
import space.whitememory.pythoninlayparams.types.hints.HintResolver
1111

1212
@Suppress("UnstableApiUsage")
1313
abstract class AbstractPythonInlayTypeHintsCollector(editor: Editor, open val settings: Any): FactoryInlayHintsCollector(editor) {

src/main/kotlin/space/whitememory/pythoninlayparams/functions/PythonFunctionInlayTypeHintsCollector.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/functions/PythonFunctionInlayTypeHintsCollector.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package space.whitememory.pythoninlayparams.functions
1+
package space.whitememory.pythoninlayparams.types.functions
22

33
import com.intellij.codeInsight.hints.InlayHintsSink
44
import com.intellij.openapi.editor.Editor
@@ -8,10 +8,8 @@ import com.intellij.refactoring.suggested.endOffset
88
import com.jetbrains.python.psi.PyElement
99
import com.jetbrains.python.psi.PyFunction
1010
import com.jetbrains.python.psi.PyParameterList
11-
import com.jetbrains.python.psi.PyStatementList
12-
import space.whitememory.pythoninlayparams.AbstractPythonInlayTypeHintsCollector
13-
import space.whitememory.pythoninlayparams.hints.HintGenerator
14-
import space.whitememory.pythoninlayparams.hints.HintResolver
11+
import space.whitememory.pythoninlayparams.types.AbstractPythonInlayTypeHintsCollector
12+
import space.whitememory.pythoninlayparams.types.hints.HintResolver
1513

1614
@Suppress("UnstableApiUsage")
1715
class PythonFunctionInlayTypeHintsCollector(editor: Editor, settings: Any) :

src/main/kotlin/space/whitememory/pythoninlayparams/functions/PythonFunctionInlayTypeHintsProvider.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/functions/PythonFunctionInlayTypeHintsProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package space.whitememory.pythoninlayparams.functions
1+
package space.whitememory.pythoninlayparams.types.functions
22

33
import com.intellij.codeInsight.hints.*
44
import com.intellij.openapi.editor.Editor
@@ -7,7 +7,7 @@ import com.intellij.ui.dsl.builder.panel
77
import javax.swing.JComponent
88

99
@Suppress("UnstableApiUsage")
10-
class PythonFunctionInlayTypeHintsProvider: InlayHintsProvider<NoSettings> {
10+
class PythonFunctionInlayTypeHintsProvider : InlayHintsProvider<NoSettings> {
1111

1212
override val key: SettingsKey<NoSettings> = SettingsKey("python.inlay.function.types")
1313
override val name = "Function type hints"
@@ -26,8 +26,8 @@ class PythonFunctionInlayTypeHintsProvider: InlayHintsProvider<NoSettings> {
2626
): InlayHintsCollector = PythonFunctionInlayTypeHintsCollector(editor, settings)
2727

2828
override fun createConfigurable(settings: NoSettings): ImmediateConfigurable {
29-
return object : ImmediateConfigurable {
30-
override fun createComponent(listener: ChangeListener): JComponent = panel { }
29+
return object : ImmediateConfigurable {
30+
override fun createComponent(listener: ChangeListener): JComponent = panel { }
3131
}
3232
}
3333
}

src/main/kotlin/space/whitememory/pythoninlayparams/hints/HintGenerator.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/hints/HintGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package space.whitememory.pythoninlayparams.hints
1+
package space.whitememory.pythoninlayparams.types.hints
22

33
import com.jetbrains.python.PyNames
44
import com.jetbrains.python.psi.PyLambdaExpression

src/main/kotlin/space/whitememory/pythoninlayparams/hints/HintResolver.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/hints/HintResolver.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package space.whitememory.pythoninlayparams.hints
1+
package space.whitememory.pythoninlayparams.types.hints
22

33
import com.intellij.psi.util.PsiTreeUtil
44
import com.jetbrains.python.PyNames
55
import com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider
66
import com.jetbrains.python.psi.*
77
import com.jetbrains.python.psi.impl.PyCallExpressionHelper
88
import com.jetbrains.python.psi.types.*
9-
import space.whitememory.pythoninlayparams.variables.PythonVariablesInlayTypeHintsProvider
9+
import space.whitememory.pythoninlayparams.types.variables.PythonVariablesInlayTypeHintsProvider
1010

1111
enum class HintResolver {
1212

@@ -21,7 +21,7 @@ enum class HintResolver {
2121
): Boolean = element.name != PyNames.UNDERSCORE
2222
},
2323

24-
GLOBALS_HINT() {
24+
GLOBALS_HINT {
2525
override fun isApplicable(settings: PythonVariablesInlayTypeHintsProvider.Settings) = true
2626

2727
override fun shouldShowTypeHint(
@@ -132,7 +132,7 @@ enum class HintResolver {
132132
},
133133

134134
CLASS_ATTRIBUTE_HINT {
135-
override fun isApplicable(settings: PythonVariablesInlayTypeHintsProvider.Settings): Boolean = settings.showClassAttributeHints
135+
override fun isApplicable(settings: PythonVariablesInlayTypeHintsProvider.Settings): Boolean = !settings.showClassAttributeHints
136136

137137
override fun shouldShowTypeHint(
138138
element: PyTargetExpression,

src/main/kotlin/space/whitememory/pythoninlayparams/hints/HintUtil.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/hints/HintUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package space.whitememory.pythoninlayparams.hints
1+
package space.whitememory.pythoninlayparams.types.hints
22

33
import com.jetbrains.python.psi.PyNamedParameter
44
import com.jetbrains.python.psi.PyParameter

src/main/kotlin/space/whitememory/pythoninlayparams/variables/PythonVariablesInlayTypeHintsCollector.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/variables/PythonVariablesInlayTypeHintsCollector.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
package space.whitememory.pythoninlayparams.variables
1+
package space.whitememory.pythoninlayparams.types.variables
22

33
import com.intellij.codeInsight.hints.InlayHintsSink
44
import com.intellij.openapi.editor.Editor
55
import com.intellij.psi.PsiElement
66
import com.intellij.refactoring.suggested.endOffset
77
import com.jetbrains.python.psi.PyElement
88
import com.jetbrains.python.psi.PyTargetExpression
9-
import space.whitememory.pythoninlayparams.AbstractPythonInlayTypeHintsCollector
10-
import space.whitememory.pythoninlayparams.hints.HintGenerator
11-
import space.whitememory.pythoninlayparams.hints.HintResolver
9+
import space.whitememory.pythoninlayparams.types.AbstractPythonInlayTypeHintsCollector
10+
import space.whitememory.pythoninlayparams.types.hints.HintResolver
1211

1312
@Suppress("UnstableApiUsage")
1413
class PythonVariablesInlayTypeHintsCollector(editor: Editor, override val settings: PythonVariablesInlayTypeHintsProvider.Settings) :

src/main/kotlin/space/whitememory/pythoninlayparams/variables/PythonVariablesInlayTypeHintsProvider.kt renamed to src/main/kotlin/space/whitememory/pythoninlayparams/types/variables/PythonVariablesInlayTypeHintsProvider.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package space.whitememory.pythoninlayparams.variables
1+
package space.whitememory.pythoninlayparams.types.variables
22

33
import com.intellij.codeInsight.hints.*
44
import com.intellij.openapi.editor.Editor
@@ -13,25 +13,26 @@ class PythonVariablesInlayTypeHintsProvider : InlayHintsProvider<PythonVariables
1313
private val settingsKey: SettingsKey<Settings> = SettingsKey("python.inlay.types")
1414
}
1515

16-
override fun createSettings(): Settings = Settings()
17-
1816
data class Settings(
1917
var showClassAttributeHints: Boolean = false,
20-
var showGeneralHints: Boolean = true,
18+
var showGeneralHints: Boolean = false,
2119
)
2220

21+
override val key: SettingsKey<Settings> = settingsKey
2322
override val name = "Variables type hints"
2423
override val description = "Show the type of variables in the editor"
2524
override val previewText = null
26-
override val key: SettingsKey<Settings> = settingsKey
25+
2726
override val group: InlayGroup = InlayGroup.TYPES_GROUP
2827

28+
override fun createSettings(): Settings = Settings()
29+
2930
override fun createConfigurable(settings: Settings): ImmediateConfigurable = object : ImmediateConfigurable {
3031
override fun createComponent(listener: ChangeListener): JComponent = panel { }
3132

3233
override val cases: List<ImmediateConfigurable.Case> = listOf(
3334
ImmediateConfigurable.Case(
34-
"Disable class attribute hints",
35+
"Class attribute hints",
3536
"hints.class.attributes",
3637
settings::showClassAttributeHints
3738
),
@@ -44,8 +45,8 @@ class PythonVariablesInlayTypeHintsProvider : InlayHintsProvider<PythonVariables
4445
}
4546

4647
override fun getCaseDescription(case: ImmediateConfigurable.Case): String? = when (case.id) {
47-
"hints.class.attributes" -> "Show type hints for class attributes"
48-
"hints.general" -> """Enable\Disable plugin. Show type hints for all variables"""
48+
"hints.class.attributes" -> "Show type hints for class attributes."
49+
"hints.general" -> """Enable\Disable plugin. Show type hints for all variables."""
4950
else -> null
5051
}
5152

src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<depends>com.intellij.modules.platform</depends>
1010

1111
<extensions defaultExtensionNs="com.intellij">
12-
<codeInsight.inlayProvider language="Python" implementationClass="space.whitememory.pythoninlayparams.variables.PythonVariablesInlayTypeHintsProvider"/>
13-
<codeInsight.inlayProvider language="Python" implementationClass="space.whitememory.pythoninlayparams.functions.PythonFunctionInlayTypeHintsProvider"/>
12+
<codeInsight.inlayProvider language="Python" implementationClass="space.whitememory.pythoninlayparams.types.variables.PythonVariablesInlayTypeHintsProvider"/>
13+
<codeInsight.inlayProvider language="Python" implementationClass="space.whitememory.pythoninlayparams.types.functions.PythonFunctionInlayTypeHintsProvider"/>
1414
<codeInsight.parameterNameHints language="Python" implementationClass="space.whitememory.pythoninlayparams.PythonInlayParameterHintsProvider"/>
1515
</extensions>
1616
</idea-plugin>

0 commit comments

Comments
 (0)