-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replicate internal API code [skip ci]
- Loading branch information
1 parent
f501cbf
commit c22809f
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/it/casaricci/hass/plugin/internal/PlatformUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters