mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs] use the listener and CLM state to await ignored files refresh
This hides the implementations details better and detaches the client code from the refresh queue GitOrigin-RevId: c254ca2f4f49a18e5f09fc3e7e79957c74751d51
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bda5729f05
commit
1561ebfe55
@@ -34,6 +34,7 @@ jvm_library(
|
||||
"//platform/dvcs-api:vcs-dvcs",
|
||||
"@lib//:miglayout-swing",
|
||||
"@lib//:stream_ex",
|
||||
"//platform/util/jdom",
|
||||
"//platform/util:util-ui",
|
||||
"//platform/core-ui",
|
||||
"//platform/diff-impl",
|
||||
@@ -81,6 +82,7 @@ jvm_library(
|
||||
"//platform/vcs-tests:vcs-testFramework",
|
||||
"@lib//:miglayout-swing",
|
||||
"@lib//:stream_ex",
|
||||
"//platform/util/jdom",
|
||||
"//platform/util:util-ui",
|
||||
"//platform/core-ui",
|
||||
"//platform/diff-impl",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.vcs.testFramework" scope="TEST" />
|
||||
<orderEntry type="library" name="miglayout-swing" level="project" />
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.diff.impl" />
|
||||
|
||||
@@ -33,7 +33,8 @@ import com.intellij.openapi.vcs.VcsConfiguration
|
||||
import com.intellij.openapi.vcs.VcsNotificationIdsHolder.Companion.IGNORED_TO_EXCLUDE_NOT_FOUND
|
||||
import com.intellij.openapi.vcs.VcsNotifier
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager
|
||||
import com.intellij.openapi.vcs.changes.VcsIgnoreManagerImpl
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl
|
||||
import com.intellij.openapi.vcs.changes.VcsManagedFilesHolder
|
||||
import com.intellij.openapi.vcs.changes.ignore.lang.IgnoreFileType
|
||||
import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager
|
||||
import com.intellij.openapi.vcs.changes.ui.SelectFilesDialog
|
||||
@@ -47,9 +48,11 @@ import com.intellij.ui.EditorNotificationPanel
|
||||
import com.intellij.ui.EditorNotificationProvider
|
||||
import com.intellij.ui.EditorNotifications
|
||||
import com.intellij.util.Alarm
|
||||
import com.intellij.util.messages.impl.subscribeAsFlow
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue
|
||||
import com.intellij.util.ui.update.Update
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.*
|
||||
@@ -178,7 +181,7 @@ class IgnoredToExcludedSynchronizer(project: Project, private val cs: CoroutineS
|
||||
|
||||
try {
|
||||
val dirsToExclude = withModalProgress(project, ActionsBundle.message("action.CheckIgnoredAndNotExcludedDirectories.progress")) {
|
||||
VcsIgnoreManagerImpl.getInstanceImpl(project).awaitRefreshQueue()
|
||||
awaitIgnoredFilesUpdate(project)
|
||||
val ignoredFilePaths = ChangeListManager.getInstance(project).ignoredFilePaths
|
||||
determineIgnoredDirsToExclude(project, ignoredFilePaths)
|
||||
}
|
||||
@@ -228,6 +231,20 @@ private fun containsShelfDirectoryOrUnderIt(filePath: FilePath, shelfPath: Strin
|
||||
FileUtil.isAncestor(shelfPath, filePath.path, false) ||
|
||||
FileUtil.isAncestor(filePath.path, shelfPath, false)
|
||||
|
||||
private suspend fun awaitIgnoredFilesUpdate(project: Project) {
|
||||
withContext(Dispatchers.Default) {
|
||||
project.messageBus.subscribeAsFlow(VcsManagedFilesHolder.TOPIC) {
|
||||
send(Unit)
|
||||
VcsManagedFilesHolder.VcsManagedFilesHolderListener {
|
||||
trySend(Unit)
|
||||
}
|
||||
}.first {
|
||||
val clm = ChangeListManagerImpl.getInstanceImpl(project)
|
||||
!clm.isIgnoredInUpdateMode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun determineIgnoredDirsToExclude(project: Project, ignoredPaths: Collection<FilePath>): List<VirtualFile> {
|
||||
val sourceRoots = getProjectSourceRoots(project)
|
||||
val fileIndex = ProjectFileIndex.getInstance(project)
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.runBlockingCancellable
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorUtils
|
||||
import com.intellij.openapi.project.InitialVfsRefreshService
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ProjectCloseListener
|
||||
@@ -31,7 +30,6 @@ import com.intellij.vcsUtil.VcsUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.io.path.invariantSeparatorsPathString
|
||||
|
||||
@@ -88,14 +86,6 @@ class VcsIgnoreManagerImpl(private val project: Project, coroutineScope: Corouti
|
||||
}
|
||||
}
|
||||
|
||||
fun awaitRefreshQueue() {
|
||||
assert(!ApplicationManager.getApplication().isReadAccessAllowed)
|
||||
if (ignoreRefreshQueue.isEmpty) return
|
||||
val waiter = CountDownLatch(1)
|
||||
ignoreRefreshQueue.queue(Update.create(waiter) { waiter.countDown() })
|
||||
ProgressIndicatorUtils.awaitWithCheckCanceled(waiter)
|
||||
}
|
||||
|
||||
fun findIgnoreFileType(vcs: AbstractVcs): IgnoreFileType? {
|
||||
val ignoredFileContentProvider = findIgnoredFileContentProvider(vcs) ?: return null
|
||||
return FileTypeManager.getInstance().getFileTypeByFileName(ignoredFileContentProvider.fileName) as? IgnoreFileType
|
||||
|
||||
Reference in New Issue
Block a user