[recent files] Introduce backend model that accumulates changes received from all the registered listeners and combines them into an end-user-visible files list

This is required to be able to filter out irrelevant changes, e.g. when a file not present among recently opened files is modified. Thus the model now consists of the gateway that processes all changes and the state that stores the resulting list. On the frontend side only the resulting state is present as well, and it is accumulated just the same way as on the backend side.

GitOrigin-RevId: 5657dd604b7fec128481c76d452e4c31d3af22c2
This commit is contained in:
Nikita Katkov
2025-04-28 18:22:49 +02:00
committed by intellij-monorepo-bot
parent 380a40db32
commit 1963905fd8
5 changed files with 24 additions and 4 deletions

View File

@@ -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.recentFiles.backend
import com.intellij.openapi.components.Service
import com.intellij.openapi.project.Project
@Service(Service.Level.PROJECT)
internal class BackendRecentFilesModel(project: Project) {
private val state = BackendRecentFilesMutableState(project)
companion object {
@JvmStatic
fun getInstance(project: Project): BackendRecentFilesModel {
return project.getService(BackendRecentFilesModel::class.java)
}
}
}

View File

@@ -40,10 +40,10 @@ import com.intellij.platform.recentFiles.frontend.SwitcherLogger.NAVIGATED_ORIGI
import com.intellij.platform.recentFiles.frontend.SwitcherLogger.SHOWN_TIME_ACTIVITY
import com.intellij.platform.recentFiles.frontend.SwitcherSpeedSearch.Companion.installOn
import com.intellij.platform.recentFiles.frontend.model.FrontendRecentFilesModel
import com.intellij.platform.recentFiles.frontend.model.RecentFilesCoroutineScopeProvider
import com.intellij.platform.recentFiles.shared.FileSwitcherApi
import com.intellij.platform.recentFiles.shared.RecentFileKind
import com.intellij.platform.recentFiles.shared.RecentFilesBackendRequest
import com.intellij.platform.recentFiles.shared.RecentFilesCoroutineScopeProvider
import com.intellij.platform.util.coroutines.childScope
import com.intellij.ui.*
import com.intellij.ui.components.JBList

View File

@@ -5,6 +5,7 @@ import com.intellij.openapi.diagnostic.fileLogger
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
import com.intellij.platform.recentFiles.shared.RecentFileKind
import com.intellij.platform.recentFiles.shared.RecentFilesCoroutineScopeProvider
import com.intellij.platform.util.coroutines.childScope
import kotlinx.coroutines.launch

View File

@@ -6,8 +6,8 @@ import com.intellij.openapi.application.EDT
import com.intellij.openapi.project.Project
import com.intellij.platform.recentFiles.frontend.Switcher.SwitcherPanel
import com.intellij.platform.recentFiles.frontend.model.FrontendRecentFilesModel
import com.intellij.platform.recentFiles.frontend.model.RecentFilesCoroutineScopeProvider
import com.intellij.platform.recentFiles.shared.FileSwitcherApi
import com.intellij.platform.recentFiles.shared.RecentFilesCoroutineScopeProvider
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

View File

@@ -1,14 +1,16 @@
// 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.recentFiles.frontend.model
package com.intellij.platform.recentFiles.shared
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.components.serviceAsync
import com.intellij.openapi.project.Project
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
@Service(Service.Level.PROJECT)
internal class RecentFilesCoroutineScopeProvider(val coroutineScope: CoroutineScope) {
class RecentFilesCoroutineScopeProvider(val coroutineScope: CoroutineScope) {
companion object {
fun getInstance(project: Project): RecentFilesCoroutineScopeProvider {
return project.service<RecentFilesCoroutineScopeProvider>()