mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
IJPL-161739: Migrate UserDataHolderEx extension function usages
GitOrigin-RevId: c62c3df22c1a6460e6e9b762bdef32cf96a43886
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0629629994
commit
715a015e69
@@ -38,10 +38,10 @@ private fun BringProcessWindowToForegroundSupport.tryBringTerminalWindow(dataHol
|
||||
// on windows WindowsTerminal.exe process is not a parent of the debuggee, so we have to find the terminal windows associated with the debuggee first
|
||||
return (this as WinBringProcessWindowToForegroundSupport).tryBringWindowsTerminalInForeground(dataHolder, pid)
|
||||
else
|
||||
when (val terminalPid = dataHolder.getOrCreateUserData(terminalPIDKey) {
|
||||
when (val terminalPid = dataHolder.getOrMaybeCreateUserData(terminalPIDKey) {
|
||||
(tryFindParentProcess(pid, listOf("MacOS/Terminal", "gnome-terminal")) ?: run {
|
||||
logger.trace { "Could find neither main window of $pid process, nor parent cmd process. Exiting" };
|
||||
return@getOrCreateUserData null
|
||||
return@getOrMaybeCreateUserData null
|
||||
}
|
||||
).pid().toUInt()
|
||||
}) {
|
||||
@@ -79,7 +79,7 @@ private fun WinBringProcessWindowToForegroundSupport.tryBringWindowsTerminalInFo
|
||||
}
|
||||
|
||||
// On windows only 1 instance of terminal can be launched
|
||||
val windowsTerminalPid = dataHolder.getOrCreateUserData(terminalPIDKey) {
|
||||
val windowsTerminalPid = dataHolder.getOrCreateUserDataUnsafe(terminalPIDKey) {
|
||||
ProcessHandle.allProcesses()
|
||||
.filter {
|
||||
val command = it.info().command().getOrNull() ?: return@filter false
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.intellij.execution.process.window.to.foreground
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.UserDataHolder
|
||||
import com.intellij.openapi.util.getOrCreateUserData
|
||||
import com.intellij.openapi.util.getOrCreateUserDataUnsafe
|
||||
import com.intellij.util.User32Ex
|
||||
import com.intellij.util.findMainWindow
|
||||
import com.intellij.util.findWindowsWithText
|
||||
@@ -25,8 +26,8 @@ internal class WinBringProcessWindowToForegroundSupport : BringProcessWindowToFo
|
||||
}
|
||||
|
||||
private val windowsHandleKey = Key<MutableMap<UInt, WinDef.HWND>>("WindowsHandleKey")
|
||||
fun bringWindowWithName(pid: UInt, dataHolder : UserDataHolder, name : String) : Boolean {
|
||||
val cacheMap = dataHolder.getOrCreateUserData(windowsHandleKey) { mutableMapOf() }
|
||||
fun bringWindowWithName(pid: UInt, dataHolder: UserDataHolder, name: String): Boolean {
|
||||
val cacheMap = dataHolder.getOrCreateUserDataUnsafe(windowsHandleKey) { mutableMapOf() }
|
||||
|
||||
val winHandle = dataHolder.getUserData(windowsHandleKey)?.get(pid) ?: run {
|
||||
val windows = User32Ex.INSTANCE.findWindowsWithText(pid, name)
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.rd.createLifetime
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.UserDataHolder
|
||||
import com.intellij.openapi.util.getOrCreateUserData
|
||||
import com.intellij.openapi.util.getOrCreateUserDataUnsafe
|
||||
import com.jetbrains.rd.util.assert
|
||||
import com.jetbrains.rd.util.lifetime.Lifetime
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -69,7 +70,7 @@ fun <TThis : UserDataHolder, TValue> userData(lazyDefaultValue: (TThis) -> TValu
|
||||
|
||||
override fun getValue(thisRef: TThis, property: KProperty<*>): TValue {
|
||||
return thisRef.getUserData(getKey(property)) ?: synchronized(this) {
|
||||
return thisRef.getOrCreateUserData(getKey(property)) { lazyDefaultValue(thisRef) }
|
||||
return thisRef.getOrCreateUserDataUnsafe(getKey(property)) { lazyDefaultValue(thisRef) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ fun <TThis : UserDataHolder, TValue> userData(key: Key<TValue>, lazyDefaultValue
|
||||
return object : ReadWriteProperty<TThis, TValue> {
|
||||
override fun getValue(thisRef: TThis, property: KProperty<*>): TValue {
|
||||
return thisRef.getUserData(key) ?: synchronized(this) {
|
||||
return thisRef.getOrCreateUserData(key) { lazyDefaultValue(thisRef) }
|
||||
return thisRef.getOrCreateUserDataUnsafe(key) { lazyDefaultValue(thisRef) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user