Skip to content

Commit 4d6419d

Browse files
committed
Minor fixes
1 parent 7d8b723 commit 4d6419d

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/main/kotlin/insyncwithfoo/ryecharm/APIAvailability.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ import com.intellij.openapi.util.SystemInfo
77
import com.intellij.platform.lsp.api.LspServerSupportProvider
88

99

10+
// https://stackoverflow.com/q/79750919
11+
/**
12+
* Loads the class [C].
13+
*
14+
* This (inline) function is necessary because
15+
* a plain reference would otherwise be optimized away.
16+
*/
17+
private inline fun <reified C> load() {
18+
C::class.qualifiedName
19+
}
20+
21+
1022
/**
1123
* Whether LSP4IJ is both installed and enabled.
1224
*/
@@ -21,13 +33,12 @@ internal val lsp4ijIsAvailable: Boolean
2133
* Whether the native client is available.
2234
*
2335
* According to [the docs](https://plugins.jetbrains.com/docs/intellij/language-server-protocol.html#supported-ides),
24-
* it is part of IntelliJ IDEA Ultimate, WebStorm, PhpStorm, PyCharm Professional,
36+
* it is part of IntelliJ IDEA Ultimate, WebStorm, PhpStorm, Unified PyCharm,
2537
* DataSpell, RubyMine, CLion, Aqua, DataGrip, GoLand, Rider, and RustRover.
2638
*/
27-
@Suppress("UnusedExpression")
2839
internal val lspIsAvailable by lazy {
2940
try {
30-
LspServerSupportProvider
41+
load<LspServerSupportProvider>()
3142
true
3243
} catch (_: NoClassDefFoundError) {
3344
false
@@ -38,10 +49,9 @@ internal val lspIsAvailable by lazy {
3849
/**
3950
* Whether the IDE has WSL-specific support.
4051
*/
41-
@Suppress("UNUSED_EXPRESSION")
4252
internal val wslIsSupported by lazy {
4353
SystemInfo.isWindows && try {
44-
WslTargetEnvironmentConfiguration::class
54+
load<WslTargetEnvironmentConfiguration>()
4555
true
4656
} catch (_: NoClassDefFoundError) {
4757
false

src/main/kotlin/insyncwithfoo/ryecharm/Module.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,17 @@ internal val Module.path: Path?
3232
get() = basePath?.toPathOrNull()
3333

3434

35+
/**
36+
* The [pythonSDK] associated with this module,
37+
* or that of the project.
38+
*/
3539
internal val Module.interpreterPath: Path?
3640
get() = pythonSDK?.homePath?.let { Path.of(it) } ?: project.interpreterPath
3741

3842

43+
/**
44+
* The module associated with this element,
45+
* or the only module in the project.
46+
*/
3947
internal val PsiElement.module: Module?
4048
get() = ModuleUtilCore.findModuleForPsiElement(this) ?: project.modules.singleOrNull()

src/test/kotlin/insyncwithfoo/ryecharm/ruff/folding/RuffRuleFoldingBuilderTest.kt renamed to src/test/kotlin/insyncwithfoo/ryecharm/ruff/folding/RuffRuleFoldingTest.kt

File renamed without changes.

0 commit comments

Comments
 (0)