Skip to content

Commit

Permalink
Replicate internal API code [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-athome committed Jan 27, 2025
1 parent f501cbf commit c22809f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
34 changes: 34 additions & 0 deletions src/main/kotlin/it/casaricci/hass/plugin/internal/PlatformUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package it.casaricci.hass.plugin.internal

/**
* Adapted from IntelliJ SDK because it's an internal API.
*/
object PlatformUtils {
private const val PLATFORM_PREFIX_KEY: String = "idea.platform.prefix"
private const val IDEA_PREFIX: String = "idea"

private fun getPlatformPrefix(): String {
return getPlatformPrefix(IDEA_PREFIX)
}

private fun getPlatformPrefix(defaultPrefix: String?): String {
return System.getProperty(PLATFORM_PREFIX_KEY, defaultPrefix)
}

private fun `is`(idePrefix: String): Boolean {
return idePrefix == getPlatformPrefix()
}

private fun isIdeaUltimate(): Boolean {
return `is`("idea")
}

private fun isIdeaCommunity(): Boolean {
return `is`("Idea")
}

fun isIntelliJ(): Boolean {
return isIdeaUltimate() || isIdeaCommunity() || `is`("IdeaEdu")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package it.casaricci.hass.plugin.settings
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.ConfigurableProvider
import com.intellij.openapi.project.Project
import com.intellij.util.PlatformUtils
import it.casaricci.hass.plugin.internal.PlatformUtils

class ProjectSettingsConfigurableProvider(private val project: Project) : ConfigurableProvider() {

Expand All @@ -20,5 +20,4 @@ class ProjectSettingsConfigurableProvider(private val project: Project) : Config
/**
* Only IntelliJ IDEA supports facets, apparently. For all other IDEs we will use project settings.
*/
@Suppress("UnstableApiUsage")
fun usesProjectSettings(): Boolean = !PlatformUtils.isIntelliJ()

0 comments on commit c22809f

Please sign in to comment.