Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Deprecated APIs #208

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# vscode-theme Changelog

## Unreleased
### Added
- Support k2 compiler
### Changed
- Removing Deprecated APIs
- Min intellj Platform SDK is now 242
- JDK version to 21

## 1.10.13 - 2024-11-23

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ version = providers.gradleProperty("pluginVersion").get()

// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(17)
jvmToolchain(21)
}

// Configure project's dependencies
Expand Down
17 changes: 11 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ pluginGroup = com.github.dinbtechit.vscodetheme
pluginName = VSCode Theme
# SemVer format -> https://semver.org

pluginVersion = 1.10.14
pluginVersion = 1.11.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 233
pluginSinceBuild = 242
pluginUntilBuild = 243.*

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IU
platformVersion = 2023.3
platformVersion = 2024.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
#platformPlugins = JavaScript, com.intellij.java, io.flutter:75.1.4, Dart:232.9559.10, PsiViewer:232.2, \
Expand All @@ -21,9 +21,14 @@ platformVersion = 2023.3

# 2023.3
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
platformPlugins = io.flutter:77.0.1, Dart:233.11799.172, PsiViewer:233.2, \
Pythonid:233.11799.300, PythonCore:233.11799.241, com.jetbrains.php:233.11799.300, org.jetbrains.plugins.go:233.11799.196, \
com.jetbrains.rust:233.21799.284
#platformPlugins = io.flutter:77.0.1, Dart:233.11799.172, PsiViewer:233.2, \
#Pythonid:233.11799.300, PythonCore:233.11799.241, com.jetbrains.php:233.11799.300, org.jetbrains.plugins.go:233.11799.196, \
#com.jetbrains.rust:233.21799.284

#2024.3
platformPlugins = io.flutter:82.2.4, Dart:243.22562.3, PsiViewer:243.7768, org.jetbrains.android:243.21565.214, \
Pythonid:243.21565.211, PythonCore:243.21565.211, com.jetbrains.php:243.21565.211, org.jetbrains.plugins.go:243.21565.211, \
com.jetbrains.rust:243.21565.245

# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins = JavaScript, com.intellij.java, com.jetbrains.sh, org.jetbrains.kotlin
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ junit = "4.13.2"
# plugins
changelog = "2.2.1"
intelliJPlatform = "2.1.0"
kotlin = "1.9.25"
kotlin = "2.1.0"
kover = "0.8.3"
qodana = "2024.2.3"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
package com.github.dinbtechit.vscodetheme

import com.github.dinbtechit.vscodetheme.settings.VSCodeThemeSettingsStore
import com.intellij.ide.plugins.IdeaPluginDescriptor
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.ide.ui.LafManager
import com.intellij.openapi.extensions.PluginId
import com.intellij.util.containers.ContainerUtil

/*enum class VSCodeTheme(val theme: String) {
UNKNOWN("UNKNOWN"),
DARK("VSCode Dark"),
DARK_MODERN("VSCode Dark Modern");
}*/

object VSCodeTheme {
const val UNKNOWN = "UNKNOWN"
const val DARK = "VSCode Dark"
const val DARK_MODERN = "VSCode Dark Modern"
}

class VSCodeThemeManager {
companion object {
Expand All @@ -33,60 +18,6 @@ class VSCodeThemeManager {

private fun getPlugin(): IdeaPluginDescriptor? = PluginManagerCore.getPlugin(PluginId.getId(pluginId))
fun isVSCodeThemeReady(): Boolean {
try {
if (getPlugin()?.isEnabled != null) {
val vscodeTheme =
LafManager.getInstance().installedLookAndFeels.firstOrNull { it.toString().contains(VSCodeTheme.DARK) }
return vscodeTheme != null
}
return false
} catch (e: Exception) {
return false
}
}

fun switchToVSCodeTheme(always: Boolean = false, selectedVSCodeTheme: String = VSCodeTheme.DARK) {
try {
if (isVSCodeThemeReady()) {
val convertedSelectedVSCodeTheme = convertOldToNewTheme(selectedVSCodeTheme)

val vscodeTheme =
LafManager.getInstance().installedLookAndFeels.firstOrNull { it.toString().contains(convertedSelectedVSCodeTheme) }
ContainerUtil.find(LafManager.getInstance().installedLookAndFeels) { it.name === convertedSelectedVSCodeTheme}
if (vscodeTheme != null) {
LafManager.getInstance().currentLookAndFeel = vscodeTheme
}
if (always) {
val settings = VSCodeThemeSettingsStore.instance
settings.alwaysApply = true
settings.themeName = selectedVSCodeTheme
}
}
} catch (e: Exception) {
throw (Error("Unable to select the default theme $selectedVSCodeTheme", e))
}
}

fun isVSCodeThemeSelected(): Boolean {
val theme = LafManager.getInstance().currentLookAndFeel
if (theme != null) {
return theme.toString().contains(VSCodeTheme.DARK) && !theme.toString().contains("Modern")
}
return false
}

fun isVSCodeDarkModernThemeSelected(): Boolean {
val theme = LafManager.getInstance().currentLookAndFeel
return theme?.toString()?.contains(VSCodeTheme.DARK_MODERN) ?: false
}



private fun convertOldToNewTheme(theme: String): String {
return when (theme) {
"DARK_MODERN" -> "VSCode Dark Modern"
"DARK" -> "VSCode Dark"
else -> theme
}
return getPlugin() != null
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.dinbtechit.vscodetheme.settings

import com.github.dinbtechit.vscodetheme.VSCodeTheme
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
Expand All @@ -16,10 +15,8 @@
get() = ApplicationManager.getApplication().getService(VSCodeThemeSettingsStore::class.java)
}
var isVSCodeEnabled = true
var alwaysApply = false
var showNotificationOnUpdate = true

Check warning on line 18 in src/main/kotlin/com/github/dinbtechit/vscodetheme/settings/VSCodeThemeSettingsStore.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "showNotificationOnUpdate" is never used
var version = "unknown"
var themeName = VSCodeTheme.UNKNOWN

@Nullable
override fun getState() = this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.github.dinbtechit.vscodetheme.startup

import com.github.dinbtechit.vscodetheme.VSCodeTheme
import com.github.dinbtechit.vscodetheme.VSCodeThemeManager
import com.github.dinbtechit.vscodetheme.actions.AlwaysApplyThemeAction

import com.github.dinbtechit.vscodetheme.actions.DonateAction
import com.github.dinbtechit.vscodetheme.actions.StarGithubRepoAction
import com.github.dinbtechit.vscodetheme.actions.WhatsNewAction
Expand All @@ -13,23 +12,17 @@ import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.notification.Notification
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.startup.ProjectActivity


/*enum class DisplayActionType {
DONATION_ONLY,
SHOW_ALL_THEMES_FOR_DEFAULT,
SHOW_NEW_DARK_MODERN_THEME
}*/
object DisplayActionType {
const val DONATION_ONLY = "DONATION_ONLY"
const val SHOW_ALL_THEMES_FOR_DEFAULT = "SHOW_ALL_THEMES_FOR_DEFAULT"
const val SHOW_NEW_DARK_MODERN_THEME = "SHOW_NEW_DARK_MODERN_THEME"
}

class VSCodeStartupNotifyActivity : StartupActivity {
class VSCodeStartupNotifyActivity : ProjectActivity {


private val updateContent: String by lazy {
Expand All @@ -43,16 +36,7 @@ class VSCodeStartupNotifyActivity : StartupActivity {
private val switchThemeQuestion: String by lazy {
//language=HTML
"""
Set one of the <b>VSCode Theme(s)</b> as a default theme.
<br/>
$updateContent
""".trimIndent()
}

private val tryNewDarkModernThemeQuestion: String by lazy {
//language=HTML
"""
Would you like to set the <b>VSCode Dark Modern</b> as a default theme?
Select <b>VSCode Theme(s)</b> from themes.
<br/>
$updateContent
""".trimIndent()
Expand All @@ -67,23 +51,15 @@ class VSCodeStartupNotifyActivity : StartupActivity {
const val pluginId = "com.github.dinbtechit.vscodetheme"
}

override fun runActivity(project: Project) {
override suspend fun execute(project: Project) {
val settings = VSCodeThemeSettingsStore.instance
val isReady = VSCodeThemeManager.getInstance().isVSCodeThemeReady()
if (isReady && getPlugin()?.version != VSCodeThemeSettingsStore.instance.version) {
settings.version = getPlugin()!!.version
if (settings.alwaysApply) {
if (settings.themeName != VSCodeTheme.UNKNOWN) {
VSCodeThemeManager.getInstance().switchToVSCodeTheme(selectedVSCodeTheme = settings.themeName)
}
showNotificationPopup(project)
} else if (settings.showNotificationOnUpdate) {
showNotificationPopup(project)
}
showNotificationPopup(project)
}
// Uncomment for Testing popup
//showNotificationPopup(project)

}

private fun updateMsg(): String {
Expand All @@ -105,17 +81,8 @@ class VSCodeStartupNotifyActivity : StartupActivity {
}

private fun notificationContent(): String {
if (!VSCodeThemeManager.getInstance().isVSCodeThemeSelected() && !VSCodeThemeManager.getInstance()
.isVSCodeDarkModernThemeSelected()
) {
Util.displayActionType = DisplayActionType.SHOW_ALL_THEMES_FOR_DEFAULT
return switchThemeQuestion
} else if (VSCodeThemeManager.getInstance().isVSCodeThemeSelected()) {
Util.displayActionType = DisplayActionType.SHOW_NEW_DARK_MODERN_THEME
return tryNewDarkModernThemeQuestion
}
Util.displayActionType = DisplayActionType.DONATION_ONLY
return updateContent
Util.displayActionType = DisplayActionType.SHOW_ALL_THEMES_FOR_DEFAULT
return switchThemeQuestion
}

private fun getPlugin(): IdeaPluginDescriptor? = PluginManagerCore.getPlugin(PluginId.getId(pluginId))
Expand All @@ -127,21 +94,7 @@ class VSCodeStartupNotifyActivity : StartupActivity {
.getNotificationGroup("VSCode Theme Notification Group")
.createNotification(content, type)
.setTitle(title)
.setIcon(VSCodeIcons.Logo).apply {
if (Util.displayActionType == DisplayActionType.SHOW_ALL_THEMES_FOR_DEFAULT) {
addAction(DefaultActionGroup("Show All", false).apply {
add(
AlwaysApplyThemeAction(
text = VSCodeTheme.DARK_MODERN,
vscodeTheme = VSCodeTheme.DARK_MODERN
)
)
add(AlwaysApplyThemeAction(text = VSCodeTheme.DARK, vscodeTheme = VSCodeTheme.DARK))
})
} else if (Util.displayActionType == DisplayActionType.SHOW_NEW_DARK_MODERN_THEME) {
addAction(AlwaysApplyThemeAction(text = "Switch Now", vscodeTheme = VSCodeTheme.DARK_MODERN))
}
}
.setIcon(VSCodeIcons.Logo)
.addAction(DonateAction())
.addAction(StarGithubRepoAction())
.addAction(WhatsNewAction())
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/lang-config/dinbtechit-kotlin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
implementationClass="com.github.dinbtechit.vscodetheme.annotators.KotlinAnnotator"/>
<colorSettingsPage order="last" implementation="com.github.dinbtechit.vscodetheme.annotators.settings.KtColorSettingsPage"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<supportsKotlinPluginMode supportsK2="true"/>
</extensions>
</idea-plugin>
5 changes: 0 additions & 5 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<depends config-file="lang-config/dinbtechit-rust.xml" optional="true">com.jetbrains.rust</depends>
<depends config-file="lang-config/dinbtechit-sh.xml" optional="true">com.jetbrains.sh</depends>
<!--<depends config-file="lang-config/dinbtechit-typescript.xml" optional="true">JavaScript</depends>-->

<extensions defaultExtensionNs="com.intellij">
<themeProvider order="first" id="dinbtechit-2179230b863b9b1d9f1eeb27ca4a3a70" path="themes/vscode_dark_modern.theme.json"/>
<themeProvider order="last" id="dinbtechit-7ef0c378d737e162955f3e028dcf9ccb" path="themes/vscode_dark.theme.json"/>
Expand All @@ -37,10 +36,6 @@
<errorHandler implementation="com.github.dinbtechit.vscodetheme.diagostic.VSCodeErrorReportSubmitter"/>
</extensions>
<actions>
<action id="com.github.dinbtechit.vscodetheme.actions.AlwaysApplyThemeAction"
class="com.github.dinbtechit.vscodetheme.actions.AlwaysApplyThemeAction"
text="Always Apply" description="Always action">
</action>
<action id="com.github.dinbtechit.vscodetheme.actions.DismissNotification"
class="com.github.dinbtechit.vscodetheme.actions.DismissNotification"
text="Dismiss" description="Dismiss notification">
Expand Down
24 changes: 5 additions & 19 deletions src/test/kotlin/com/github/dinbtechit/vscodetheme/MyPluginTest.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
/*
package com.github.dinbtechit.vscodetheme

import com.intellij.ide.highlighter.XmlFileType
import com.intellij.psi.xml.XmlFile
import com.intellij.testFramework.TestDataPath
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.util.PsiErrorElementUtil
import junit.framework.TestCase

@TestDataPath("\$CONTENT_ROOT/src/test/testData")
class MyPluginTest : BasePlatformTestCase() {

fun testXMLFile() {
val psiFile = myFixture.configureByText(XmlFileType.INSTANCE, "<foo>bar</foo>")
val xmlFile = assertInstanceOf(psiFile, XmlFile::class.java)

assertFalse(PsiErrorElementUtil.hasErrors(project, xmlFile.virtualFile))

assertNotNull(xmlFile.rootTag)

xmlFile.rootTag?.let {
assertEquals("foo", it.name)
assertEquals("bar", it.value.text)
}
}

override fun getTestDataPath() = "src/test/testData/rename"

fun testRename() {
myFixture.testRename("foo.xml", "foo_after.xml", "a2")
fun testRename() {
TestCase.assertTrue(true)
}
}
*/
Loading