Skip to content

Commit

Permalink
Merge pull request #228 from pontem-network/is-disposed-deprecated
Browse files Browse the repository at this point in the history
Fix deprecations for disposables, bump versions
  • Loading branch information
mkurnikov authored Nov 5, 2024
2 parents a918266 + e112ae9 commit 069a603
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
13 changes: 3 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun gitTimestamp(): String {

val shortPlatformVersion = prop("shortPlatformVersion")
val useInstaller = prop("useInstaller").toBooleanStrict()
val codeVersion = "1.39.0"
val codeVersion = "1.40.0"

var pluginVersion = "$codeVersion.$shortPlatformVersion"
if (publishingChannel != "default") {
Expand All @@ -59,11 +59,9 @@ if (publishingChannel != "default") {

val pluginGroup = "org.move"
val pluginName = "intellij-move"
val pluginJarName = "intellij-move-$pluginVersion"

val javaVersion = JavaVersion.VERSION_21
val kotlinReflectVersion = "1.9.10"
val aptosVersion = "4.2.6"
val kotlinReflectVersion = "2.0.21"
val aptosVersion = "4.3.0"

group = pluginGroup
version = pluginVersion
Expand Down Expand Up @@ -118,11 +116,6 @@ allprojects {
}
}

// configure<JavaPluginExtension> {
// sourceCompatibility = javaVersion
// targetCompatibility = javaVersion
// }

sourceSets {
main {
java.srcDirs("src/main/gen")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import java.nio.file.Paths

data class Aptos(val cliLocation: Path, val parentDisposable: Disposable?): Disposable {

private val innerDisposable = Disposer.newCheckedDisposable("Aptos CLI disposable")

init {
Disposer.register(this, innerDisposable)

if (parentDisposable != null) {
Disposer.register(parentDisposable, this)
}
Expand Down Expand Up @@ -184,7 +188,7 @@ data class Aptos(val cliLocation: Path, val parentDisposable: Disposable?): Disp
): RsProcessResult<ProcessOutput> {
return commandLine
.toGeneralCommandLine(this.cliLocation)
.execute(this, stdIn = null, listener = listener, runner = runner)
.execute(innerDisposable, stdIn = null, listener = listener, runner = runner)
}

override fun dispose() {}
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/move/cli/settings/VersionLabel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.move.cli.settings

import com.intellij.openapi.Disposable
import com.intellij.openapi.util.CheckedDisposable
import com.intellij.ui.JBColor
import com.intellij.ui.components.JBLabel
import org.move.cli.runConfigurations.AptosCommandLine
Expand Down Expand Up @@ -30,7 +31,7 @@ open class TextOrErrorLabel(icon: Icon?): JBLabel(icon) {
}

class VersionLabel(
parentDisposable: Disposable,
parentDisposable: CheckedDisposable,
private val versionUpdateListener: (() -> Unit)? = null
):
TextOrErrorLabel(null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.move.cli.settings.isValidExecutable
import org.move.ide.actions.DownloadAptosSDKAction
import org.move.ide.notifications.logOrShowBalloon
import org.move.openapiext.BundledAptosManager
import org.move.openapiext.SUPPORTED_PLATFORMS
import org.move.openapiext.pathField
import org.move.stdext.blankToNull
import org.move.stdext.toPathOrNull
Expand Down Expand Up @@ -63,6 +62,13 @@ enum class AptosExecType {

class ChooseAptosCliPanel(versionUpdateListener: (() -> Unit)?): Disposable {

private val innerDisposable =
Disposer.newCheckedDisposable("Internal checked disposable for ChooseAptosCliPanel")

init {
Disposer.register(this, innerDisposable)
}

data class Data(
val aptosExecType: AptosExecType,
val localAptosPath: String?
Expand Down Expand Up @@ -100,7 +106,7 @@ class ChooseAptosCliPanel(versionUpdateListener: (() -> Unit)?): Disposable {
onTextChanged = { _ ->
updateVersion()
})
private val versionLabel = VersionLabel(this, versionUpdateListener)
private val versionLabel = VersionLabel(innerDisposable, versionUpdateListener)

private val bundledRadioButton = JBRadioButton("Bundled")
private val localRadioButton = JBRadioButton("Local")
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/move/openapiext/CommandLineExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.util.CheckedDisposable
import com.intellij.openapi.util.Disposer
import com.intellij.util.SystemProperties
import org.move.cli.runConfigurations.MvCapturingProcessHandler
Expand All @@ -38,7 +39,7 @@ fun GeneralCommandLine.execute(): ProcessOutput? {

/// `owner` parameter represents the object whose lifetime it's using for the process lifetime
fun GeneralCommandLine.execute(
owner: Disposable,
owner: CheckedDisposable,
stdIn: ByteArray? = null,
runner: CapturingProcessHandler.() -> ProcessOutput = { runProcessWithGlobalProgress() },
listener: ProcessListener? = null
Expand All @@ -55,11 +56,10 @@ fun GeneralCommandLine.execute(
}
}

@Suppress("DEPRECATION")
val ownerIsAlreadyDisposed =
runReadAction {
// check that owner is disposed, kill process then
if (Disposer.isDisposed(owner)) {
if (owner.isDisposed) {
true
} else {
Disposer.register(owner, processKiller)
Expand Down
9 changes: 4 additions & 5 deletions src/main/kotlin/org/move/openapiext/ui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.intellij.openapi.editor.ScrollType
import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.ui.TextComponentAccessor
import com.intellij.openapi.ui.TextFieldWithBrowseButton
import com.intellij.openapi.util.CheckedDisposable
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.NlsContexts.DialogTitle
import com.intellij.ui.DocumentAdapter
Expand All @@ -22,7 +23,7 @@ import javax.swing.JTextField
import javax.swing.event.DocumentEvent

class UiDebouncer(
private val parentDisposable: Disposable,
private val parentDisposable: CheckedDisposable,
private val delayMillis: Int = 200
) {
private val alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, parentDisposable)
Expand All @@ -32,14 +33,12 @@ class UiDebouncer(
* Use it only for UI updates
*/
fun <T> update(onPooledThread: () -> T, onUiThread: (T) -> Unit) {
@Suppress("DEPRECATION")
if (Disposer.isDisposed(parentDisposable)) return
if (parentDisposable.isDisposed) return
alarm.cancelAllRequests()
alarm.addRequest({
val r = onPooledThread()
invokeLater(ModalityState.any()) {
@Suppress("DEPRECATION")
if (!Disposer.isDisposed(parentDisposable)) {
if (!parentDisposable.isDisposed) {
onUiThread(r)
}
}
Expand Down

0 comments on commit 069a603

Please sign in to comment.