[debugger-rd] IJPL-160146: Register entities using EntityTypeProvider EP

GitOrigin-RevId: bf10e84a5d8a2eb155dbe41342d7a7d0a55a7a1f
This commit is contained in:
Nikolay Rykunov
2024-09-04 16:29:59 +02:00
committed by intellij-monorepo-bot
parent 3e5f254be6
commit 70bd6c8850
3 changed files with 16 additions and 18 deletions

View File

@@ -19,11 +19,6 @@ import kotlinx.coroutines.withContext
internal fun subscribeForDebuggingStart(cs: CoroutineScope, project: Project, onStartListening: () -> Unit) {
cs.launch(Dispatchers.Default) {
withKernel {
change {
shared {
register(XDebuggerValueLookupListeningStartedEntity)
}
}
XDebuggerValueLookupListeningStartedEntity.each().filter { it.projectEntity.asProject() === project }.collect {
withContext(Dispatchers.Main) {
onStartListening()
@@ -36,11 +31,6 @@ internal fun subscribeForDebuggingStart(cs: CoroutineScope, project: Project, on
internal fun subscribeForValueHintHideRequest(cs: CoroutineScope, project: Project, onHintHidden: () -> Unit) {
cs.launch(Dispatchers.Default) {
withKernel {
change {
shared {
register(XDebuggerValueLookupHideHintsRequestEntity)
}
}
XDebuggerValueLookupHideHintsRequestEntity.each().filter { it.projectEntity.asProject() === project }.collect { entity ->
withContext(Dispatchers.Main) {
onHintHidden()

View File

@@ -143,6 +143,7 @@
<runDashboardCustomizer implementation="com.intellij.xdebugger.impl.dashboard.XDebuggerRunDashboardCustomizer" order="first"/>
<registryKey defaultValue="false" key="debugger.valueLookupFrontendBackend"
description="Provides a way to use frontend-backend implementation of debugger's evaluation popup"/>
<platform.entityTypes implementation="com.intellij.xdebugger.impl.evaluate.XDebuggerValueLookupEntityTypesProvider"/>
</extensions>
<actions>

View File

@@ -5,11 +5,13 @@ import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.platform.kernel.EntityTypeProvider
import com.intellij.platform.kernel.withKernel
import com.intellij.platform.project.ProjectEntity
import com.intellij.platform.project.asEntity
import com.jetbrains.rhizomedb.EID
import com.jetbrains.rhizomedb.Entity
import com.jetbrains.rhizomedb.EntityType
import fleet.kernel.DurableEntityType
import fleet.kernel.change
import fleet.kernel.shared
@@ -19,6 +21,15 @@ import kotlinx.coroutines.launch
import org.jetbrains.annotations.ApiStatus
import java.util.concurrent.atomic.AtomicReference
private class XDebuggerValueLookupEntityTypesProvider : EntityTypeProvider {
override fun entityTypes(): List<EntityType<*>> {
return listOf(
XDebuggerValueLookupListeningStartedEntity,
XDebuggerValueLookupHideHintsRequestEntity,
)
}
}
@ApiStatus.Internal
class XDebuggerValueLookupListeningStartedEntity(override val eid: EID) : Entity {
companion object : DurableEntityType<XDebuggerValueLookupListeningStartedEntity>(
@@ -59,17 +70,13 @@ class ValueLookupManagerController(private val project: Project, private val cs:
}
cs.launch(Dispatchers.Main) {
withKernel {
change {
shared {
register(XDebuggerValueLookupListeningStartedEntity)
}
}
val entities = XDebuggerValueLookupListeningStartedEntity.all()
if (entities.isEmpty()) {
change {
val projectEntity = project.asEntity()
shared {
XDebuggerValueLookupListeningStartedEntity.new {
it[XDebuggerValueLookupListeningStartedEntity.Project] = project.asEntity()
it[XDebuggerValueLookupListeningStartedEntity.Project] = projectEntity
}
}
}
@@ -86,10 +93,10 @@ class ValueLookupManagerController(private val project: Project, private val cs:
cs.launch(Dispatchers.Main) {
withKernel {
change {
val projectEntity = project.asEntity()
shared {
register(XDebuggerValueLookupHideHintsRequestEntity)
XDebuggerValueLookupHideHintsRequestEntity.new {
it[XDebuggerValueLookupHideHintsRequestEntity.Project] = project.asEntity()
it[XDebuggerValueLookupHideHintsRequestEntity.Project] = projectEntity
}
}
}