mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-206503 Search Everywhere for RD: Hide Rhizome SeSessionEntity from API
GitOrigin-RevId: 100f1b5d0fe31f1e44f90c2d3256159905e283ef
This commit is contained in:
committed by
intellij-monorepo-bot
parent
afec56bb4b
commit
4ef112783a
@@ -19,7 +19,6 @@ import com.intellij.platform.searchEverywhere.providers.SeProvidersHolder
|
||||
import com.intellij.platform.searchEverywhere.providers.target.SeTypeVisibilityStatePresentation
|
||||
import com.intellij.platform.searchEverywhere.utils.SeResultsCountBalancer
|
||||
import com.jetbrains.rhizomedb.EID
|
||||
import fleet.kernel.DurableRef
|
||||
import fleet.kernel.onDispose
|
||||
import fleet.kernel.rete.Rete
|
||||
import kotlinx.coroutines.*
|
||||
@@ -40,14 +39,14 @@ class SeBackendService(val project: Project, private val coroutineScope: Corouti
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
suspend fun getItems(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
params: SeParams,
|
||||
dataContextId: DataContextId?,
|
||||
requestedCountChannel: ReceiveChannel<Int>,
|
||||
): Flow<SeTransferEvent> {
|
||||
val providerHolder = getProvidersHolder(sessionRef, dataContextId) ?: return emptyFlow()
|
||||
val providerHolder = getProvidersHolder(session, dataContextId) ?: return emptyFlow()
|
||||
|
||||
val requestedCountState = MutableStateFlow(0)
|
||||
val receivingJob = coroutineScope.launch {
|
||||
@@ -98,10 +97,10 @@ class SeBackendService(val project: Project, private val coroutineScope: Corouti
|
||||
}
|
||||
|
||||
suspend fun getAvailableProviderIds(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId
|
||||
) : Map<String, Set<SeProviderId>> {
|
||||
val providersHolder = getProvidersHolder(sessionRef, dataContextId) ?: return emptyMap()
|
||||
val providersHolder = getProvidersHolder(session, dataContextId) ?: return emptyMap()
|
||||
return providersHolder.splitToEssentialAndNonEssential(
|
||||
SeItemsProviderFactory.EP_NAME.extensionList.map { it.id.toProviderId() }
|
||||
)
|
||||
@@ -114,12 +113,12 @@ class SeBackendService(val project: Project, private val coroutineScope: Corouti
|
||||
}
|
||||
|
||||
private suspend fun getProvidersHolder(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId?,
|
||||
): SeProvidersHolder? =
|
||||
mutex.withLock {
|
||||
val session = sessionRef.derefOrNull() ?: return@withLock null
|
||||
sessionIdToProviderHolders[session.eid]?.let { return@withLock it }
|
||||
val sessionEntity = session.asRef().derefOrNull() ?: return@withLock null
|
||||
sessionIdToProviderHolders[sessionEntity.eid]?.let { return@withLock it }
|
||||
|
||||
if (dataContextId == null) {
|
||||
SeLog.error("Cannot create providers on the backend: no serialized data context")
|
||||
@@ -134,31 +133,31 @@ class SeBackendService(val project: Project, private val coroutineScope: Corouti
|
||||
}
|
||||
|
||||
val actionEvent = AnActionEvent.createEvent(dataContext, null, "", ActionUiKind.NONE, null)
|
||||
val providersHolder = SeProvidersHolder.initialize(actionEvent, project, sessionRef, "Backend")
|
||||
sessionIdToProviderHolders[session.eid] = providersHolder
|
||||
val providersHolder = SeProvidersHolder.initialize(actionEvent, project, session, "Backend")
|
||||
sessionIdToProviderHolders[sessionEntity.eid] = providersHolder
|
||||
|
||||
session.onDispose(coroutineScope.coroutineContext[Rete]!!) {
|
||||
sessionEntity.onDispose(coroutineScope.coroutineContext[Rete]!!) {
|
||||
Disposer.dispose(providersHolder)
|
||||
sessionIdToProviderHolders.remove(session.eid)
|
||||
sessionIdToProviderHolders.remove(sessionEntity.eid)
|
||||
}
|
||||
|
||||
return@withLock providersHolder
|
||||
}
|
||||
|
||||
suspend fun itemSelected(sessionRef: DurableRef<SeSessionEntity>, itemData: SeItemData, modifiers: Int, searchText: String, isAllTab: Boolean): Boolean {
|
||||
val provider = getProvidersHolder(sessionRef, null)?.get(itemData.providerId, isAllTab) ?: return false
|
||||
suspend fun itemSelected(session: SeSession, itemData: SeItemData, modifiers: Int, searchText: String, isAllTab: Boolean): Boolean {
|
||||
val provider = getProvidersHolder(session, null)?.get(itemData.providerId, isAllTab) ?: return false
|
||||
|
||||
return provider.itemSelected(itemData, modifiers, searchText)
|
||||
}
|
||||
|
||||
suspend fun getSearchScopesInfoForProviders(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
): Map<SeProviderId, SearchScopesInfo> {
|
||||
return providerIds.mapNotNull { providerId ->
|
||||
val provider = getProvidersHolder(sessionRef, dataContextId)?.get(providerId, isAllTab)
|
||||
val provider = getProvidersHolder(session, dataContextId)?.get(providerId, isAllTab)
|
||||
provider?.getSearchScopesInfo()?.let {
|
||||
providerId to it
|
||||
}
|
||||
@@ -167,23 +166,23 @@ class SeBackendService(val project: Project, private val coroutineScope: Corouti
|
||||
|
||||
suspend fun getTypeVisibilityStatesForProviders(
|
||||
index: Int,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
): List<SeTypeVisibilityStatePresentation> {
|
||||
return providerIds.mapNotNull { providerId ->
|
||||
val provider = getProvidersHolder(sessionRef, dataContextId)?.get(providerId, isAllTab)
|
||||
val provider = getProvidersHolder(session, dataContextId)?.get(providerId, isAllTab)
|
||||
provider?.getTypeVisibilityStates(index)
|
||||
}.flatten()
|
||||
}
|
||||
|
||||
suspend fun getDisplayNameForProvider(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
): Map<SeProviderId, @Nls String> {
|
||||
val providersHolder = getProvidersHolder(sessionRef, dataContextId) ?: return emptyMap()
|
||||
val providersHolder = getProvidersHolder(session, dataContextId) ?: return emptyMap()
|
||||
return providerIds.mapNotNull { id ->
|
||||
providersHolder.get(id, true)?.displayName?.let { displayName ->
|
||||
id to displayName
|
||||
@@ -192,34 +191,34 @@ class SeBackendService(val project: Project, private val coroutineScope: Corouti
|
||||
}
|
||||
|
||||
suspend fun canBeShownInFindResults(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
): Boolean {
|
||||
return providerIds.any { providerId ->
|
||||
val provider = getProvidersHolder(sessionRef, dataContextId)?.get(providerId, isAllTab)
|
||||
val provider = getProvidersHolder(session, dataContextId)?.get(providerId, isAllTab)
|
||||
provider?.canBeShownInFindResults() ?: false
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun isShownInSeparateTab(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerId: SeProviderId,
|
||||
): Boolean {
|
||||
return getProvidersHolder(sessionRef, dataContextId)?.getLegacyContributor(providerId, false)?.isShownInSeparateTab ?: false
|
||||
return getProvidersHolder(session, dataContextId)?.getLegacyContributor(providerId, false)?.isShownInSeparateTab ?: false
|
||||
}
|
||||
|
||||
suspend fun openInFindToolWindow(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId?,
|
||||
providerIds: List<SeProviderId>,
|
||||
params: SeParams,
|
||||
isAllTab: Boolean,
|
||||
): Boolean {
|
||||
val providersHolder = getProvidersHolder(sessionRef, dataContextId)
|
||||
val providersHolder = getProvidersHolder(session, dataContextId)
|
||||
if (providersHolder == null) return false
|
||||
|
||||
SeFindToolWindowManager(project).openInFindToolWindow(
|
||||
@@ -232,8 +231,8 @@ class SeBackendService(val project: Project, private val coroutineScope: Corouti
|
||||
return item.fetchItemIfExists()?.presentation()
|
||||
}
|
||||
|
||||
suspend fun performExtendedAction(sessionRef: DurableRef<SeSessionEntity>, itemData: SeItemData, isAllTab: Boolean): Boolean {
|
||||
val provider = getProvidersHolder(sessionRef, null)?.get(itemData.providerId, isAllTab) ?: return false
|
||||
suspend fun performExtendedAction(session: SeSession, itemData: SeItemData, isAllTab: Boolean): Boolean {
|
||||
val provider = getProvidersHolder(session, null)?.get(itemData.providerId, isAllTab) ?: return false
|
||||
return provider.performExtendedAction(itemData)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.platform.scopes.SearchScopesInfo
|
||||
import com.intellij.platform.searchEverywhere.*
|
||||
import com.intellij.platform.searchEverywhere.impl.SeRemoteApi
|
||||
import com.intellij.platform.searchEverywhere.providers.target.SeTypeVisibilityStatePresentation
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
@@ -18,29 +17,29 @@ import org.jetbrains.annotations.Nls
|
||||
@ApiStatus.Internal
|
||||
class SeRemoteApiImpl: SeRemoteApi {
|
||||
override suspend fun itemSelected(projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
itemData: SeItemData,
|
||||
modifiers: Int,
|
||||
searchText: String,
|
||||
isAllTab: Boolean): Boolean {
|
||||
val project = projectId.findProjectOrNull() ?: return false
|
||||
return SeBackendService.getInstance(project).itemSelected(sessionRef, itemData, modifiers, searchText, isAllTab)
|
||||
return SeBackendService.getInstance(project).itemSelected(session, itemData, modifiers, searchText, isAllTab)
|
||||
}
|
||||
|
||||
override suspend fun canBeShownInFindResults(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
): Boolean {
|
||||
val project = projectId.findProjectOrNull() ?: return false
|
||||
return SeBackendService.getInstance(project).canBeShownInFindResults(sessionRef, dataContextId, providerIds, isAllTab)
|
||||
return SeBackendService.getInstance(project).canBeShownInFindResults(session, dataContextId, providerIds, isAllTab)
|
||||
}
|
||||
|
||||
override suspend fun openInFindToolWindow(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId?,
|
||||
providerIds: List<SeProviderId>,
|
||||
params: SeParams,
|
||||
@@ -48,17 +47,17 @@ class SeRemoteApiImpl: SeRemoteApi {
|
||||
): Boolean {
|
||||
val project = projectId.findProjectOrNull() ?: return false
|
||||
return SeBackendService.getInstance(project)
|
||||
.openInFindToolWindow(projectId, sessionRef, dataContextId, providerIds, params, isAllTab)
|
||||
.openInFindToolWindow(projectId, session, dataContextId, providerIds, params, isAllTab)
|
||||
}
|
||||
|
||||
override suspend fun isShownInSeparateTab(projectId: ProjectId, sessionRef: DurableRef<SeSessionEntity>, dataContextId: DataContextId, providerId: SeProviderId): Boolean {
|
||||
override suspend fun isShownInSeparateTab(projectId: ProjectId, session: SeSession, dataContextId: DataContextId, providerId: SeProviderId): Boolean {
|
||||
val project = projectId.findProjectOrNull() ?: return false
|
||||
return SeBackendService.getInstance(project).isShownInSeparateTab(sessionRef, dataContextId, providerId)
|
||||
return SeBackendService.getInstance(project).isShownInSeparateTab(session, dataContextId, providerId)
|
||||
}
|
||||
|
||||
override suspend fun getItems(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
params: SeParams,
|
||||
@@ -67,49 +66,49 @@ class SeRemoteApiImpl: SeRemoteApi {
|
||||
): Flow<SeTransferEvent> {
|
||||
val project = projectId.findProjectOrNull() ?: return emptyFlow()
|
||||
return SeBackendService.getInstance(project)
|
||||
.getItems(sessionRef, providerIds, isAllTab, params, dataContextId, requestedCountChannel)
|
||||
.getItems(session, providerIds, isAllTab, params, dataContextId, requestedCountChannel)
|
||||
}
|
||||
|
||||
override suspend fun getAvailableProviderIds(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId
|
||||
) : Map<String, Set<SeProviderId>> {
|
||||
val project = projectId.findProjectOrNull() ?: return emptyMap()
|
||||
return SeBackendService.getInstance(project).getAvailableProviderIds(sessionRef, dataContextId)
|
||||
return SeBackendService.getInstance(project).getAvailableProviderIds(session, dataContextId)
|
||||
}
|
||||
|
||||
override suspend fun getSearchScopesInfoForProviders(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
): Map<SeProviderId, SearchScopesInfo> {
|
||||
val project = projectId.findProjectOrNull() ?: return emptyMap()
|
||||
return SeBackendService.getInstance(project).getSearchScopesInfoForProviders(sessionRef, dataContextId, providerIds, isAllTab)
|
||||
return SeBackendService.getInstance(project).getSearchScopesInfoForProviders(session, dataContextId, providerIds, isAllTab)
|
||||
}
|
||||
|
||||
override suspend fun getTypeVisibilityStatesForProviders(
|
||||
index: Int,
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
): List<SeTypeVisibilityStatePresentation> {
|
||||
val project = projectId.findProjectOrNull() ?: return emptyList()
|
||||
return SeBackendService.getInstance(project).getTypeVisibilityStatesForProviders(index, sessionRef, dataContextId, providerIds, isAllTab)
|
||||
return SeBackendService.getInstance(project).getTypeVisibilityStatesForProviders(index, session, dataContextId, providerIds, isAllTab)
|
||||
}
|
||||
|
||||
override suspend fun getDisplayNameForProviders(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
): Map<SeProviderId, @Nls String> {
|
||||
val project = projectId.findProjectOrNull() ?: return emptyMap()
|
||||
return SeBackendService.getInstance(project).getDisplayNameForProvider(sessionRef, dataContextId, providerIds)
|
||||
return SeBackendService.getInstance(project).getDisplayNameForProvider(session, dataContextId, providerIds)
|
||||
}
|
||||
|
||||
override suspend fun getUpdatedPresentation(projectId: ProjectId, item: SeItemData): SeItemPresentation? {
|
||||
@@ -119,11 +118,11 @@ class SeRemoteApiImpl: SeRemoteApi {
|
||||
|
||||
override suspend fun performExtendedAction(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
itemData: SeItemData,
|
||||
isAllTab: Boolean,
|
||||
): Boolean {
|
||||
val project = projectId.findProjectOrNull() ?: return false
|
||||
return SeBackendService.getInstance(project).performExtendedAction(sessionRef, itemData, isAllTab)
|
||||
return SeBackendService.getInstance(project).performExtendedAction(session, itemData, isAllTab)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.platform.searchEverywhere.impl.SeRemoteApi
|
||||
import com.intellij.platform.searchEverywhere.providers.SeLog
|
||||
import com.intellij.platform.searchEverywhere.providers.SeLog.ITEM_EMIT
|
||||
import com.intellij.platform.searchEverywhere.providers.target.SeTypeVisibilityStatePresentation
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -21,7 +20,7 @@ import org.jetbrains.annotations.Nls
|
||||
@Internal
|
||||
class SeFrontendItemDataProvidersFacade(private val projectId: ProjectId,
|
||||
val idsWithDisplayNames: Map<SeProviderId, @Nls String>,
|
||||
private val sessionRef: DurableRef<SeSessionEntity>,
|
||||
private val session: SeSession,
|
||||
private val dataContextId: DataContextId,
|
||||
private val isAllTab: Boolean,
|
||||
val essentialProviderIds: Set<SeProviderId>) {
|
||||
@@ -39,7 +38,7 @@ class SeFrontendItemDataProvidersFacade(private val projectId: ProjectId,
|
||||
channel.send(DEFAULT_CHUNK_SIZE)
|
||||
var pendingCount = DEFAULT_CHUNK_SIZE
|
||||
|
||||
SeRemoteApi.getInstance().getItems(projectId, sessionRef, ids, isAllTab, params, dataContextId, channel).collect { transferEvent ->
|
||||
SeRemoteApi.getInstance().getItems(projectId, session, ids, isAllTab, params, dataContextId, channel).collect { transferEvent ->
|
||||
pendingCount--
|
||||
if (pendingCount == 0) {
|
||||
pendingCount += DEFAULT_CHUNK_SIZE
|
||||
@@ -66,7 +65,7 @@ class SeFrontendItemDataProvidersFacade(private val projectId: ProjectId,
|
||||
modifiers: Int,
|
||||
searchText: String,
|
||||
): Boolean {
|
||||
return SeRemoteApi.getInstance().itemSelected(projectId, sessionRef, itemData, modifiers, searchText, isAllTab = isAllTab)
|
||||
return SeRemoteApi.getInstance().itemSelected(projectId, session, itemData, modifiers, searchText, isAllTab = isAllTab)
|
||||
}
|
||||
|
||||
suspend fun getUpdatedPresentation(item: SeItemData): SeItemPresentation? =
|
||||
@@ -74,22 +73,22 @@ class SeFrontendItemDataProvidersFacade(private val projectId: ProjectId,
|
||||
|
||||
suspend fun getSearchScopesInfos(): Map<SeProviderId, SearchScopesInfo> =
|
||||
SeRemoteApi.getInstance().getSearchScopesInfoForProviders(
|
||||
projectId, providerIds = providerIds, sessionRef = sessionRef, dataContextId = dataContextId, isAllTab = isAllTab
|
||||
projectId, providerIds = providerIds, session = session, dataContextId = dataContextId, isAllTab = isAllTab
|
||||
)
|
||||
|
||||
suspend fun getTypeVisibilityStates(index: Int): List<SeTypeVisibilityStatePresentation> =
|
||||
SeRemoteApi.getInstance().getTypeVisibilityStatesForProviders(
|
||||
index = index, projectId = projectId, providerIds = providerIds, sessionRef = sessionRef, dataContextId = dataContextId, isAllTab = isAllTab
|
||||
index = index, projectId = projectId, providerIds = providerIds, session = session, dataContextId = dataContextId, isAllTab = isAllTab
|
||||
)
|
||||
|
||||
suspend fun canBeShownInFindResults(): Boolean {
|
||||
return SeRemoteApi.getInstance().canBeShownInFindResults(
|
||||
projectId, providerIds = providerIds, sessionRef = sessionRef, dataContextId = dataContextId, isAllTab = isAllTab
|
||||
projectId, providerIds = providerIds, session = session, dataContextId = dataContextId, isAllTab = isAllTab
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun performExtendedAction(itemData: SeItemData): Boolean {
|
||||
return SeRemoteApi.getInstance().performExtendedAction(projectId, sessionRef, itemData, isAllTab)
|
||||
return SeRemoteApi.getInstance().performExtendedAction(projectId, session, itemData, isAllTab)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -14,7 +14,9 @@ import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.WindowStateService
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.asRef
|
||||
import com.intellij.platform.searchEverywhere.frontend.tabs.actions.SeActionsTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.tabs.all.SeAllTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.tabs.classes.SeClassesTab
|
||||
@@ -37,7 +39,6 @@ import com.intellij.ui.popup.AbstractPopup
|
||||
import com.intellij.util.ui.EDT
|
||||
import com.intellij.util.ui.StartupUiUtil
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import fleet.kernel.DurableRef
|
||||
import fleet.kernel.change
|
||||
import fleet.kernel.shared
|
||||
import kotlinx.coroutines.*
|
||||
@@ -80,12 +81,12 @@ class SeFrontendService(val project: Project?, private val coroutineScope: Corou
|
||||
|
||||
coroutineScope.launch {
|
||||
val popupScope = coroutineScope.childScope("SearchEverywhereFrontendService popup scope")
|
||||
val sessionRef = SeSessionEntity.createRef()
|
||||
val session = SeSessionEntity.createSession()
|
||||
|
||||
try {
|
||||
popupSemaphore.withPermit {
|
||||
localProvidersHolder = SeProvidersHolder.initialize(initEvent, project, sessionRef, "Frontend")
|
||||
val completable = doShowPopup(popupFuture, tabId, searchText, initEvent, popupScope, sessionRef)
|
||||
localProvidersHolder = SeProvidersHolder.initialize(initEvent, project, session, "Frontend")
|
||||
val completable = doShowPopup(popupFuture, tabId, searchText, initEvent, popupScope, session)
|
||||
completable.await()
|
||||
}
|
||||
}
|
||||
@@ -99,7 +100,7 @@ class SeFrontendService(val project: Project?, private val coroutineScope: Corou
|
||||
if (removeSessionRef.get()) {
|
||||
change {
|
||||
shared {
|
||||
sessionRef.derefOrNull()?.delete()
|
||||
session.asRef().derefOrNull()?.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,7 +115,7 @@ class SeFrontendService(val project: Project?, private val coroutineScope: Corou
|
||||
searchText: String?,
|
||||
initEvent: AnActionEvent,
|
||||
popupScope: CoroutineScope,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
): CompletableDeferred<Unit> {
|
||||
val startTime = System.currentTimeMillis()
|
||||
val tabInitializationTimoutMillis: Long = 50
|
||||
@@ -125,7 +126,7 @@ class SeFrontendService(val project: Project?, private val coroutineScope: Corou
|
||||
val tabsOrDeferredTabs = tabFactories.map {
|
||||
it.id to initAsync(popupScope) {
|
||||
computeCatchingOrNull({ e -> "Error while getting tab from ${it.id} tab factory: ${e.message}" }) {
|
||||
it.getTab(popupScope, project, sessionRef, initEvent) { action ->
|
||||
it.getTab(popupScope, project, session, initEvent) { action ->
|
||||
popupInstance?.registerShortcut?.invoke(action)
|
||||
}
|
||||
}
|
||||
@@ -157,7 +158,7 @@ class SeFrontendService(val project: Project?, private val coroutineScope: Corou
|
||||
val deferredTabs = tabsOrDeferredTabs.filterIsInstance<SuspendLazyProperty<SeTab?>>()
|
||||
|
||||
var popup: JBPopup? = null
|
||||
val popupVm = SePopupVm(popupScope, project, sessionRef, tabs, deferredTabs, searchText, tabId, historyList) {
|
||||
val popupVm = SePopupVm(popupScope, project, tabs, deferredTabs, searchText, tabId, historyList) {
|
||||
popup?.cancel()
|
||||
popup = null
|
||||
}
|
||||
@@ -180,11 +181,11 @@ class SeFrontendService(val project: Project?, private val coroutineScope: Corou
|
||||
popupScope.launch(NonCancellable) {
|
||||
removeSessionRef.set(false)
|
||||
try {
|
||||
popupVm.openInFindWindow(sessionRef, initEvent)
|
||||
popupVm.openInFindWindow(session, initEvent)
|
||||
} finally {
|
||||
change {
|
||||
shared {
|
||||
sessionRef.derefOrNull()?.delete()
|
||||
session.asRef().derefOrNull()?.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.platform.searchEverywhere.*
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
@@ -35,7 +34,7 @@ interface SeTab : Disposable {
|
||||
|
||||
suspend fun canBeShownInFindResults(): Boolean
|
||||
|
||||
suspend fun openInFindToolWindow(sessionRef: DurableRef<SeSessionEntity>, params: SeParams, initEvent: AnActionEvent): Boolean = false
|
||||
suspend fun openInFindToolWindow(session: SeSession, params: SeParams, initEvent: AnActionEvent): Boolean = false
|
||||
|
||||
/**
|
||||
* @return true if the popup should be closed, false otherwise
|
||||
|
||||
@@ -5,8 +5,7 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import fleet.kernel.DurableRef
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -14,7 +13,7 @@ import org.jetbrains.annotations.ApiStatus
|
||||
@ApiStatus.Internal
|
||||
interface SeTabFactory {
|
||||
val id: String
|
||||
suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? = null
|
||||
suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? = null
|
||||
|
||||
companion object {
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.platform.searchEverywhere.providers.SeLog.ITEM_EMIT
|
||||
import com.intellij.platform.searchEverywhere.providers.target.SeTypeVisibilityStatePresentation
|
||||
import com.intellij.platform.searchEverywhere.utils.SeResultsCountBalancer
|
||||
import com.intellij.platform.searchEverywhere.utils.initAsync
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.*
|
||||
@@ -32,14 +31,14 @@ import org.jetbrains.annotations.Nls
|
||||
@Internal
|
||||
class SeTabDelegate(
|
||||
val project: Project?,
|
||||
private val sessionRef: DurableRef<SeSessionEntity>,
|
||||
private val session: SeSession,
|
||||
private val logLabel: String,
|
||||
private val providerIds: List<SeProviderId>,
|
||||
private val initEvent: AnActionEvent,
|
||||
val scope: CoroutineScope,
|
||||
) : Disposable {
|
||||
private val providers = initAsync(scope) {
|
||||
initializeProviders(project, providerIds, initEvent, sessionRef, logLabel)
|
||||
initializeProviders(project, providerIds, initEvent, session, logLabel)
|
||||
}
|
||||
suspend fun getProvidersIdToName(): Map<SeProviderId, @Nls String> = providers.getValue().getProvidersIdToName()
|
||||
|
||||
@@ -124,7 +123,7 @@ class SeTabDelegate(
|
||||
}
|
||||
|
||||
suspend fun openInFindToolWindow(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
params: SeParams,
|
||||
initEvent: AnActionEvent,
|
||||
isAllTab: Boolean,
|
||||
@@ -136,7 +135,7 @@ class SeTabDelegate(
|
||||
initEvent.dataContext.rpcId()
|
||||
}
|
||||
return SeRemoteApi.getInstance().openInFindToolWindow(project.projectId(),
|
||||
sessionRef,
|
||||
session,
|
||||
dataContextId,
|
||||
providers.getValue().getProviderIds(disabledProviders ?: emptyList()),
|
||||
params,
|
||||
@@ -270,20 +269,20 @@ class SeTabDelegate(
|
||||
project: Project,
|
||||
providerId: SeProviderId,
|
||||
initEvent: AnActionEvent,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
): Boolean {
|
||||
val dataContextId = readAction {
|
||||
initEvent.dataContext.rpcId()
|
||||
}
|
||||
return SeFrontendService.getInstance(project).localProvidersHolder?.getLegacyContributor(providerId, false)?.isShownInSeparateTab == true ||
|
||||
SeRemoteApi.getInstance().isShownInSeparateTab(project.projectId(), sessionRef, dataContextId, providerId)
|
||||
SeRemoteApi.getInstance().isShownInSeparateTab(project.projectId(), session, dataContextId, providerId)
|
||||
}
|
||||
|
||||
private suspend fun initializeProviders(
|
||||
project: Project?,
|
||||
providerIds: List<SeProviderId>,
|
||||
initEvent: AnActionEvent,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
logLabel: String,
|
||||
): Providers {
|
||||
val projectId = project?.projectId()
|
||||
@@ -296,7 +295,7 @@ class SeTabDelegate(
|
||||
val localFactories = SeItemsProviderFactory.EP_NAME.extensionList.associateBy { SeProviderId(it.id) }
|
||||
val frontendOnlyIds = localFactories.filter { it.value is SeFrontendOnlyItemsProviderFactory }.map { it.key }.toSet()
|
||||
|
||||
val availableRemoteProviders = if (projectId != null) SeRemoteApi.getInstance().getAvailableProviderIds(projectId, sessionRef, dataContextId) else emptyMap()
|
||||
val availableRemoteProviders = if (projectId != null) SeRemoteApi.getInstance().getAvailableProviderIds(projectId, session, dataContextId) else emptyMap()
|
||||
|
||||
val essentialRemoteProviderIds = availableRemoteProviders[SeProviderIdUtils.ESSENTIAL_KEY]?.filter {
|
||||
!frontendOnlyIds.contains(it)
|
||||
@@ -325,12 +324,12 @@ class SeTabDelegate(
|
||||
|
||||
val frontendProvidersFacade = if (project != null) {
|
||||
val remoteProviderIdToName =
|
||||
SeRemoteApi.getInstance().getDisplayNameForProviders(project.projectId(), sessionRef, dataContextId, remoteProviderIds.toList())
|
||||
SeRemoteApi.getInstance().getDisplayNameForProviders(project.projectId(), session, dataContextId, remoteProviderIds.toList())
|
||||
|
||||
if (remoteProviderIdToName.isEmpty()) null
|
||||
else SeFrontendItemDataProvidersFacade(project.projectId(),
|
||||
remoteProviderIdToName,
|
||||
sessionRef,
|
||||
session,
|
||||
dataContextId,
|
||||
hasWildcard,
|
||||
essentialRemoteProviderIds.filter { remoteProviderIdToName.containsKey(it) }.toSet())
|
||||
|
||||
@@ -6,11 +6,10 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeProviderIdUtils
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -18,9 +17,9 @@ import org.jetbrains.annotations.ApiStatus.Internal
|
||||
class SeActionsTabFactory : SeTabFactory {
|
||||
override val id: String get() = SeActionsTab.ID
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
val delegate = SeTabDelegate(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"Actions",
|
||||
listOf(SeProviderId(SeProviderIdUtils.ACTIONS_ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.platform.searchEverywhere.providers.SeEverywhereFilter
|
||||
import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty
|
||||
import com.intellij.platform.searchEverywhere.utils.initAsync
|
||||
import com.intellij.ui.IdeUICustomization
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
@@ -63,9 +62,9 @@ class SeAllTab(private val delegate: SeTabDelegate) : SeTab {
|
||||
return delegate.canBeShownInFindResults()
|
||||
}
|
||||
|
||||
override suspend fun openInFindToolWindow(sessionRef: DurableRef<SeSessionEntity>, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
override suspend fun openInFindToolWindow(session: SeSession, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
val allTabFilter = SeEverywhereFilter.from(params.filter)
|
||||
return delegate.openInFindToolWindow(sessionRef, params, initEvent, true,allTabFilter.disabledProviderIds)
|
||||
return delegate.openInFindToolWindow(session, params, initEvent, true,allTabFilter.disabledProviderIds)
|
||||
}
|
||||
|
||||
override suspend fun getUpdatedPresentation(item: SeItemData): SeItemPresentation? {
|
||||
|
||||
@@ -6,11 +6,10 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeProviderIdUtils
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -18,11 +17,11 @@ import org.jetbrains.annotations.ApiStatus
|
||||
class SeAllTabFactory : SeTabFactory {
|
||||
override val id: String get() = SeAllTab.ID
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
project ?: return null
|
||||
|
||||
val delegate = SeTabDelegate(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"All",
|
||||
listOf(SeProviderId(SeProviderIdUtils.WILDCARD_ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.searchEverywhere.SeItemData
|
||||
import com.intellij.platform.searchEverywhere.SeParams
|
||||
import com.intellij.platform.searchEverywhere.SeResultEvent
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeEmptyResultInfo
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeEmptyResultInfoProvider
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeFilterEditor
|
||||
@@ -17,7 +17,6 @@ import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDe
|
||||
import com.intellij.platform.searchEverywhere.frontend.tabs.target.SeTargetsFilterEditor
|
||||
import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty
|
||||
import com.intellij.platform.searchEverywhere.utils.initAsync
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -50,8 +49,8 @@ class SeClassesTab(private val delegate: SeTabDelegate) : SeTab {
|
||||
return delegate.canBeShownInFindResults()
|
||||
}
|
||||
|
||||
override suspend fun openInFindToolWindow(sessionRef: DurableRef<SeSessionEntity>, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(sessionRef, params, initEvent, false)
|
||||
override suspend fun openInFindToolWindow(session: SeSession, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(session, params, initEvent, false)
|
||||
}
|
||||
|
||||
override suspend fun performExtendedAction(item: SeItemData): Boolean {
|
||||
|
||||
@@ -6,11 +6,10 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeProviderIdUtils
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -18,11 +17,11 @@ import org.jetbrains.annotations.ApiStatus
|
||||
class SeClassesTabFactory : SeTabFactory {
|
||||
override val id: String get() = SeClassesTab.ID
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
project ?: return null
|
||||
|
||||
val delegate = SeTabDelegate(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"Classes",
|
||||
listOf(SeProviderId(SeProviderIdUtils.CLASSES_ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.searchEverywhere.SeItemData
|
||||
import com.intellij.platform.searchEverywhere.SeParams
|
||||
import com.intellij.platform.searchEverywhere.SeResultEvent
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeEmptyResultInfo
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeEmptyResultInfoProvider
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeFilterEditor
|
||||
@@ -17,7 +17,6 @@ import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDe
|
||||
import com.intellij.platform.searchEverywhere.frontend.tabs.target.SeTargetsFilterEditor
|
||||
import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty
|
||||
import com.intellij.platform.searchEverywhere.utils.initAsync
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -51,8 +50,8 @@ class SeFilesTab(private val delegate: SeTabDelegate) : SeTab {
|
||||
return delegate.canBeShownInFindResults()
|
||||
}
|
||||
|
||||
override suspend fun openInFindToolWindow(sessionRef: DurableRef<SeSessionEntity>, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(sessionRef, params, initEvent, false)
|
||||
override suspend fun openInFindToolWindow(session: SeSession, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(session, params, initEvent, false)
|
||||
}
|
||||
|
||||
override suspend fun performExtendedAction(item: SeItemData): Boolean {
|
||||
|
||||
@@ -6,11 +6,10 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeProviderIdUtils
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -18,11 +17,11 @@ import org.jetbrains.annotations.ApiStatus.Internal
|
||||
class SeFilesTabFactory : SeTabFactory {
|
||||
override val id: String get() = SeFilesTab.ID
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
project ?: return null
|
||||
|
||||
val delegate = SeTabDelegate(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"Files",
|
||||
listOf(SeProviderId(SeProviderIdUtils.FILES_ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -5,11 +5,10 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.providers.mocks.SeItemsProviderFactoryMockAlphaLocal
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -17,9 +16,9 @@ import org.jetbrains.annotations.ApiStatus.Internal
|
||||
class SeTabFactoryMockAlphaLocal : SeTabFactory {
|
||||
override val id: String get() = "AlphaLocal"
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? =
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? =
|
||||
SeTabMock.create(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"AlphaLocal",
|
||||
listOf(SeProviderId(SeItemsProviderFactoryMockAlphaLocal.ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -5,11 +5,10 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.providers.mocks.SeItemsProviderFactoryMockBetaLocal
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -17,9 +16,9 @@ import org.jetbrains.annotations.ApiStatus.Internal
|
||||
class SeTabFactoryMockBetaLocal : SeTabFactory {
|
||||
override val id: String get() = "BetaLocal"
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? =
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? =
|
||||
SeTabMock.create(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"BetaLocal",
|
||||
listOf(SeProviderId(SeItemsProviderFactoryMockBetaLocal.ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -5,10 +5,9 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
@@ -17,10 +16,10 @@ import org.jetbrains.annotations.ApiStatus.Internal
|
||||
class SeTabFactoryMockCharlieRemote : SeTabFactory {
|
||||
override val id: String get() = "Charlie-Remote"
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
delay(1000)
|
||||
return SeTabMock.create(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"Charlie-Remote",
|
||||
listOf(SeProviderId("SearchEverywhereItemsProviderMock_MockBackend")),
|
||||
initEvent,
|
||||
|
||||
@@ -5,12 +5,11 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.providers.mocks.SeItemsProviderFactoryMockAlphaLocal
|
||||
import com.intellij.platform.searchEverywhere.providers.mocks.SeItemsProviderFactoryMockBetaLocal
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -18,9 +17,9 @@ import org.jetbrains.annotations.ApiStatus.Internal
|
||||
class SeTabFactoryMockDeltaMixed : SeTabFactory {
|
||||
override val id: String get() = "DeltaMixed"
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? =
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? =
|
||||
SeTabMock.create(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"DeltaMixed",
|
||||
listOf(SeProviderId(SeItemsProviderFactoryMockAlphaLocal.ID),
|
||||
SeProviderId(SeItemsProviderFactoryMockBetaLocal.ID),
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.platform.searchEverywhere.*
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeFilterEditor
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
@@ -46,13 +45,13 @@ class SeTabMock(
|
||||
companion object {
|
||||
fun create(
|
||||
project: Project?,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
name: String,
|
||||
providerIds: List<SeProviderId>,
|
||||
initEvent: AnActionEvent,
|
||||
scope: CoroutineScope,
|
||||
): SeTabMock {
|
||||
val delegate = SeTabDelegate(project, sessionRef, name, providerIds, initEvent, scope)
|
||||
val delegate = SeTabDelegate(project, session, name, providerIds, initEvent, scope)
|
||||
return SeTabMock(name, delegate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.searchEverywhere.SeItemData
|
||||
import com.intellij.platform.searchEverywhere.SeParams
|
||||
import com.intellij.platform.searchEverywhere.SeResultEvent
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeEmptyResultInfo
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeEmptyResultInfoProvider
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeFilterEditor
|
||||
@@ -17,7 +17,6 @@ import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDe
|
||||
import com.intellij.platform.searchEverywhere.frontend.tabs.target.SeTargetsFilterEditor
|
||||
import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty
|
||||
import com.intellij.platform.searchEverywhere.utils.initAsync
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -50,8 +49,8 @@ class SeSymbolsTab(private val delegate: SeTabDelegate) : SeTab {
|
||||
return delegate.canBeShownInFindResults()
|
||||
}
|
||||
|
||||
override suspend fun openInFindToolWindow(sessionRef: DurableRef<SeSessionEntity>, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(sessionRef, params, initEvent, false)
|
||||
override suspend fun openInFindToolWindow(session: SeSession, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(session, params, initEvent, false)
|
||||
}
|
||||
|
||||
override suspend fun performExtendedAction(item: SeItemData): Boolean {
|
||||
|
||||
@@ -6,11 +6,10 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeProviderIdUtils
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -18,11 +17,11 @@ import org.jetbrains.annotations.ApiStatus
|
||||
class SeSymbolsTabFactory : SeTabFactory {
|
||||
override val id: String get() = SeSymbolsTab.ID
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
project ?: return null
|
||||
|
||||
val delegate = SeTabDelegate(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"Symbols",
|
||||
listOf(SeProviderId(SeProviderIdUtils.SYMBOLS_ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -7,16 +7,11 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.searchEverywhere.SeItemData
|
||||
import com.intellij.platform.searchEverywhere.SeParams
|
||||
import com.intellij.platform.searchEverywhere.SeResultEvent
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeTextSearchOptions
|
||||
import com.intellij.platform.searchEverywhere.*
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeEmptyResultInfo
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeFilterEditor
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty
|
||||
import com.intellij.platform.searchEverywhere.utils.initAsync
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -49,8 +44,8 @@ class SeTextTab(private val delegate: SeTabDelegate, registerShortcut: (AnAction
|
||||
return delegate.canBeShownInFindResults()
|
||||
}
|
||||
|
||||
override suspend fun openInFindToolWindow(sessionRef: DurableRef<SeSessionEntity>, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(sessionRef, params, initEvent, false)
|
||||
override suspend fun openInFindToolWindow(session: SeSession, params: SeParams, initEvent: AnActionEvent): Boolean {
|
||||
return delegate.openInFindToolWindow(session, params, initEvent, false)
|
||||
}
|
||||
|
||||
private fun getTextSearchOptions(): SeTextSearchOptions? {
|
||||
|
||||
@@ -7,11 +7,10 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.searchEverywhere.SeProviderId
|
||||
import com.intellij.platform.searchEverywhere.SeProviderIdUtils
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTabFactory
|
||||
import com.intellij.platform.searchEverywhere.frontend.resultsProcessing.SeTabDelegate
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -19,11 +18,11 @@ import org.jetbrains.annotations.ApiStatus
|
||||
class SeTextTabFactory : SeTabFactory {
|
||||
override val id: String get() = SeTextTab.ID
|
||||
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
override suspend fun getTab(scope: CoroutineScope, project: Project?, session: SeSession, initEvent: AnActionEvent, registerShortcut: (AnAction) -> Unit): SeTab? {
|
||||
if (project == null || !TextSearchContributor.enabled()) return null
|
||||
|
||||
val delegate = SeTabDelegate(project,
|
||||
sessionRef,
|
||||
session,
|
||||
"Text",
|
||||
listOf(SeProviderId(SeProviderIdUtils.TEXT_ID)),
|
||||
initEvent,
|
||||
|
||||
@@ -15,11 +15,10 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.wm.ToolWindowManager.Companion.getInstance
|
||||
import com.intellij.platform.searchEverywhere.SeItemData
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty
|
||||
import com.intellij.util.SystemProperties
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -29,7 +28,6 @@ import org.jetbrains.annotations.ApiStatus
|
||||
class SePopupVm(
|
||||
val coroutineScope: CoroutineScope,
|
||||
private val project: Project?,
|
||||
private val sessionRef: DurableRef<SeSessionEntity>,
|
||||
tabs: List<SeTab>,
|
||||
deferredTabs: List<SuspendLazyProperty<SeTab?>>,
|
||||
initialSearchPattern: String?,
|
||||
@@ -139,8 +137,8 @@ class SePopupVm(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun openInFindWindow(sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent): Boolean {
|
||||
return currentTab.openInFindWindow(sessionRef, initEvent)
|
||||
suspend fun openInFindWindow(session: SeSession, initEvent: AnActionEvent): Boolean {
|
||||
return currentTab.openInFindWindow(session, initEvent)
|
||||
}
|
||||
|
||||
fun selectNextTab() {
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.platform.searchEverywhere.frontend.SeTab
|
||||
import com.intellij.platform.searchEverywhere.providers.SeLog
|
||||
import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty
|
||||
import com.intellij.platform.searchEverywhere.utils.initAsync
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -184,10 +183,10 @@ class SeTabVm(
|
||||
return tab.canBeShownInFindResults()
|
||||
}
|
||||
|
||||
suspend fun openInFindWindow(sessionRef: DurableRef<SeSessionEntity>, initEvent: AnActionEvent): Boolean {
|
||||
suspend fun openInFindWindow(session: SeSession, initEvent: AnActionEvent): Boolean {
|
||||
val params = SeParams(searchPattern.value,
|
||||
(filterEditor.getValue()?.resultFlow?.value ?: SeFilterState.Empty))
|
||||
return tab.openInFindToolWindow(sessionRef, params, initEvent)
|
||||
return tab.openInFindToolWindow(session, params, initEvent)
|
||||
}
|
||||
|
||||
suspend fun getSearchEverywhereToggleAction(): SearchEverywhereToggleAction? {
|
||||
|
||||
@@ -17,3 +17,7 @@
|
||||
- a:isMultiSelectionSupported():Z
|
||||
*f:com.intellij.platform.searchEverywhere.SeItemPresentation$Companion
|
||||
- f:serializer():kotlinx.serialization.KSerializer
|
||||
*:com.intellij.platform.searchEverywhere.SeSession
|
||||
- *sf:Companion:com.intellij.platform.searchEverywhere.SeSession$Companion
|
||||
*f:com.intellij.platform.searchEverywhere.SeSession$Companion
|
||||
- f:serializer():kotlinx.serialization.KSerializer
|
||||
|
||||
@@ -37,7 +37,7 @@ class SeItemData(
|
||||
@ApiStatus.Internal
|
||||
companion object {
|
||||
suspend fun createItemData(
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
uuid: String,
|
||||
item: SeItem,
|
||||
providerId: SeProviderId,
|
||||
@@ -46,7 +46,7 @@ class SeItemData(
|
||||
additionalInfo: Map<String, String>,
|
||||
uuidToReplace: List<String>,
|
||||
): SeItemData? {
|
||||
val entityRef = SeItemEntity.createWith(sessionRef, item) ?: return null
|
||||
val entityRef = SeItemEntity.createWith(session, item) ?: return null
|
||||
val additionalInfo = additionalInfo.toMutableMap()
|
||||
|
||||
if (item is SeLegacyItem) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.searchEverywhere
|
||||
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Experimental
|
||||
@Serializable
|
||||
sealed interface SeSession
|
||||
|
||||
@ApiStatus.Internal
|
||||
@Serializable
|
||||
class SeSessionImpl(val ref: DurableRef<SeSessionEntity>): SeSession
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun SeSession.asRef(): DurableRef<SeSessionEntity> = (this as SeSessionImpl).ref
|
||||
@@ -3,7 +3,10 @@ package com.intellij.platform.searchEverywhere
|
||||
|
||||
import com.jetbrains.rhizomedb.EID
|
||||
import com.jetbrains.rhizomedb.Entity
|
||||
import fleet.kernel.*
|
||||
import fleet.kernel.DurableEntityType
|
||||
import fleet.kernel.change
|
||||
import fleet.kernel.ref
|
||||
import fleet.kernel.shared
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -13,10 +16,12 @@ class SeSessionEntity(override val eid: EID) : Entity {
|
||||
@Internal
|
||||
companion object : DurableEntityType<SeSessionEntity>(SeSessionEntity::class, ::SeSessionEntity) {
|
||||
|
||||
suspend fun createRef(): DurableRef<SeSessionEntity> = change {
|
||||
suspend fun createSession(): SeSession = change {
|
||||
shared {
|
||||
SeSessionEntity.new {}
|
||||
}
|
||||
}.ref()
|
||||
}.ref().let {
|
||||
SeSessionImpl(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ package com.intellij.platform.searchEverywhere.impl
|
||||
|
||||
import com.intellij.platform.kernel.withKernel
|
||||
import com.intellij.platform.searchEverywhere.SeItem
|
||||
import com.intellij.platform.searchEverywhere.SeSession
|
||||
import com.intellij.platform.searchEverywhere.SeSessionEntity
|
||||
import com.intellij.platform.searchEverywhere.asRef
|
||||
import com.intellij.platform.searchEverywhere.impl.SeItemEntityHolder.Companion.Item
|
||||
import com.intellij.platform.searchEverywhere.impl.SeItemEntityHolder.Companion.ItemEntity
|
||||
import com.jetbrains.rhizomedb.*
|
||||
@@ -23,10 +25,10 @@ class SeItemEntity(override val eid: EID) : Entity {
|
||||
companion object : DurableEntityType<SeItemEntity>(SeItemEntity::class, ::SeItemEntity) {
|
||||
private val Session = requiredRef<SeSessionEntity>("session", RefFlags.CASCADE_DELETE_BY)
|
||||
|
||||
suspend fun createWith(sessionRef: DurableRef<SeSessionEntity>, item: SeItem): DurableRef<SeItemEntity>? {
|
||||
suspend fun createWith(session: SeSession, item: SeItem): DurableRef<SeItemEntity>? {
|
||||
@Suppress("DEPRECATION")
|
||||
return withKernel {
|
||||
val session = sessionRef.derefOrNull() ?: return@withKernel null
|
||||
val session = session.asRef().derefOrNull() ?: return@withKernel null
|
||||
|
||||
change {
|
||||
val entity = shared {
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.intellij.platform.rpc.RemoteApiProviderService
|
||||
import com.intellij.platform.scopes.SearchScopesInfo
|
||||
import com.intellij.platform.searchEverywhere.*
|
||||
import com.intellij.platform.searchEverywhere.providers.target.SeTypeVisibilityStatePresentation
|
||||
import fleet.kernel.DurableRef
|
||||
import fleet.rpc.RemoteApi
|
||||
import fleet.rpc.Rpc
|
||||
import fleet.rpc.remoteApiDescriptor
|
||||
@@ -31,7 +30,7 @@ interface SeRemoteApi : RemoteApi<Unit> {
|
||||
// 4. BE sends the next batch of items
|
||||
suspend fun getItems(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
params: SeParams,
|
||||
@@ -41,7 +40,7 @@ interface SeRemoteApi : RemoteApi<Unit> {
|
||||
|
||||
suspend fun itemSelected(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
itemData: SeItemData,
|
||||
modifiers: Int,
|
||||
searchText: String,
|
||||
@@ -52,19 +51,19 @@ interface SeRemoteApi : RemoteApi<Unit> {
|
||||
* Defines if results can be shown in <i>Find</i> toolwindow.
|
||||
*/
|
||||
suspend fun canBeShownInFindResults(projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean): Boolean
|
||||
|
||||
suspend fun isShownInSeparateTab(projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerId: SeProviderId): Boolean
|
||||
|
||||
suspend fun openInFindToolWindow(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId?,
|
||||
providerIds: List<SeProviderId>,
|
||||
params: SeParams,
|
||||
@@ -73,13 +72,13 @@ interface SeRemoteApi : RemoteApi<Unit> {
|
||||
|
||||
suspend fun getAvailableProviderIds(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId
|
||||
): Map<String, Set<SeProviderId>>
|
||||
|
||||
suspend fun getSearchScopesInfoForProviders(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
@@ -88,7 +87,7 @@ interface SeRemoteApi : RemoteApi<Unit> {
|
||||
suspend fun getTypeVisibilityStatesForProviders(
|
||||
index: Int,
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
isAllTab: Boolean,
|
||||
@@ -96,7 +95,7 @@ interface SeRemoteApi : RemoteApi<Unit> {
|
||||
|
||||
suspend fun getDisplayNameForProviders(
|
||||
projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
dataContextId: DataContextId,
|
||||
providerIds: List<SeProviderId>,
|
||||
): Map<SeProviderId, @Nls String>
|
||||
@@ -104,7 +103,7 @@ interface SeRemoteApi : RemoteApi<Unit> {
|
||||
suspend fun getUpdatedPresentation(projectId: ProjectId, item: SeItemData): SeItemPresentation?
|
||||
|
||||
suspend fun performExtendedAction(projectId: ProjectId,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
itemData: SeItemData,
|
||||
isAllTab: Boolean): Boolean
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.scopes.SearchScopesInfo
|
||||
import com.intellij.platform.searchEverywhere.*
|
||||
import com.intellij.platform.searchEverywhere.providers.target.SeTypeVisibilityStatePresentation
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
@@ -25,7 +24,7 @@ import kotlin.concurrent.atomics.incrementAndFetch
|
||||
@ApiStatus.Internal
|
||||
class SeLocalItemDataProvider(
|
||||
private val provider: SeItemsProvider,
|
||||
private val sessionRef: DurableRef<SeSessionEntity>,
|
||||
private val session: SeSession,
|
||||
private val logLabel: String = "Local",
|
||||
) : Disposable {
|
||||
val id: SeProviderId
|
||||
@@ -42,7 +41,7 @@ class SeLocalItemDataProvider(
|
||||
fun getItems(params: SeParams): Flow<SeItemData> {
|
||||
val counter = AtomicInt(0)
|
||||
return getRawItems(params).mapNotNull { item ->
|
||||
val itemData = SeItemData.createItemData(sessionRef, UUID.randomUUID().toString(), item, id, item.weight(), item.presentation(), infoWithReportableId, emptyList())
|
||||
val itemData = SeItemData.createItemData(session, UUID.randomUUID().toString(), item, id, item.weight(), item.presentation(), infoWithReportableId, emptyList())
|
||||
itemData?.also {
|
||||
SeLog.log(SeLog.ITEM_EMIT) {
|
||||
val count = counter.incrementAndFetch()
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.searchEverywhere.*
|
||||
import com.intellij.platform.searchEverywhere.providers.SeProvidersHolder.Companion.initialize
|
||||
import fleet.kernel.DurableRef
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -54,7 +53,7 @@ class SeProvidersHolder(
|
||||
suspend fun initialize(
|
||||
initEvent: AnActionEvent,
|
||||
project: Project?,
|
||||
sessionRef: DurableRef<SeSessionEntity>,
|
||||
session: SeSession,
|
||||
logLabel: String,
|
||||
providerIds: List<SeProviderId>? = null,
|
||||
): SeProvidersHolder {
|
||||
@@ -96,11 +95,11 @@ class SeProvidersHolder(
|
||||
}
|
||||
|
||||
provider?.let {
|
||||
providers[SeProviderId(it.id)] = SeLocalItemDataProvider(it, sessionRef, logLabel)
|
||||
providers[SeProviderId(it.id)] = SeLocalItemDataProvider(it, session, logLabel)
|
||||
}
|
||||
|
||||
separateTabProvider?.let {
|
||||
separateTabProviders[SeProviderId(it.id)] = SeLocalItemDataProvider(it, sessionRef, logLabel)
|
||||
separateTabProviders[SeProviderId(it.id)] = SeLocalItemDataProvider(it, session, logLabel)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user