mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
[threading] IJPL-190260: Remove blockingContext #4
GitOrigin-RevId: f4c7e6b93b7ffec26c0f6702baf2c691342fb516
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f56f2f22d5
commit
2b56c468e9
@@ -6,7 +6,6 @@ import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -32,12 +31,10 @@ interface ExternalSystemUnlinkedProjectAware {
|
||||
|
||||
suspend fun linkAndLoadProjectAsync(project: Project, externalProjectPath: String) {
|
||||
withContext(Dispatchers.EDT) {
|
||||
blockingContext {
|
||||
@Suppress("DEPRECATION")
|
||||
linkAndLoadProject(project, externalProjectPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun unlinkProject(project: Project, externalProjectPath: String) {
|
||||
throw UnsupportedOperationException("'unlinkProject' method in ${this::class.qualifiedName} is not implemented")
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjec
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemActivityKey
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemInProgressService
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.ProjectActivity
|
||||
import com.intellij.openapi.startup.StartupActivity
|
||||
@@ -29,9 +28,7 @@ internal class ExternalSystemStartupActivity : ProjectActivity {
|
||||
val esProjectsManager = readAction {
|
||||
ExternalProjectsManagerImpl.getInstance(project)
|
||||
}
|
||||
blockingContext {
|
||||
esProjectsManager.init()
|
||||
}
|
||||
|
||||
// do not compute in EDT
|
||||
val managers = ExternalSystemManager.EP_NAME.extensionList
|
||||
@@ -39,10 +36,8 @@ internal class ExternalSystemStartupActivity : ProjectActivity {
|
||||
for (manager in managers) {
|
||||
runCatching {
|
||||
if (manager is StartupActivity) {
|
||||
blockingContext {
|
||||
manager.runActivity(project)
|
||||
}
|
||||
}
|
||||
else if (manager is ProjectActivity) {
|
||||
manager.execute(project)
|
||||
}
|
||||
@@ -54,16 +49,12 @@ internal class ExternalSystemStartupActivity : ProjectActivity {
|
||||
if (!isNewlyImportedProject && isNewlyCreatedProject) {
|
||||
for (manager in managers) {
|
||||
runCatching {
|
||||
blockingContext {
|
||||
ExternalSystemUtil.refreshProjects(ImportSpecBuilder(project, manager.systemId).createDirectoriesForEmptyContentRoots())
|
||||
}
|
||||
}.getOrLogException(logger<ExternalSystemStartupActivity>())
|
||||
}
|
||||
}
|
||||
|
||||
blockingContext {
|
||||
ProjectRenameAware.beAware(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.intellij.ide.actions.cache.RecoveryScope
|
||||
import com.intellij.openapi.externalSystem.settings.workspaceModel.ExternalProjectsBuildClasspathEntity
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.progress.blockingContextScope
|
||||
import com.intellij.openapi.util.io.NioFiles
|
||||
import com.intellij.platform.backend.workspace.workspaceModel
|
||||
@@ -35,14 +34,12 @@ class ExternalProjectDataRecoveryContributor : ExternalSystemRecoveryContributor
|
||||
}
|
||||
|
||||
private suspend fun invalidateLocalExternalSystemCache(recoveryScope: RecoveryScope) {
|
||||
blockingContext {
|
||||
val project = recoveryScope.project
|
||||
for (manager in ExternalSystemApiUtil.getAllManagers()) {
|
||||
val localSettings = manager.getLocalSettingsProvider().`fun`(project)
|
||||
localSettings.invalidateCaches()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun invalidateProjectBuildClasspathCache(recoveryScope: RecoveryScope) {
|
||||
recoveryScope.project.workspaceModel.update("Invalidate project build classpath cache") { storage ->
|
||||
@@ -52,7 +49,6 @@ class ExternalProjectDataRecoveryContributor : ExternalSystemRecoveryContributor
|
||||
}
|
||||
|
||||
private suspend fun invalidateExternalSystemDataStorage(recoveryScope: RecoveryScope) {
|
||||
blockingContext {
|
||||
val project = recoveryScope.project
|
||||
val dataStorage = ExternalProjectsDataStorage.getInstance(project)
|
||||
for (manager in ExternalSystemApiUtil.getAllManagers()) {
|
||||
@@ -64,7 +60,6 @@ class ExternalProjectDataRecoveryContributor : ExternalSystemRecoveryContributor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun invalidateExternalSystemToolwindow(recoveryScope: RecoveryScope) {
|
||||
blockingContextScope {
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.getCanonicalPath
|
||||
|
||||
@@ -27,7 +26,6 @@ class ExternalSystemWorkingDirectoryInfo(
|
||||
override val emptyFieldError: String = ExternalSystemBundle.message("run.configuration.project.path.empty.error", readableName)
|
||||
|
||||
override suspend fun collectExternalProjects(): List<ExternalProject> {
|
||||
return blockingContext {
|
||||
val externalProjects = ArrayList<ExternalProject>()
|
||||
val localSettings = ExternalSystemApiUtil.getLocalSettings<AbstractExternalSystemLocalSettings<*>>(project, externalSystemId)
|
||||
val uiAware = ExternalSystemUiUtil.getUiAware(externalSystemId)
|
||||
@@ -42,7 +40,6 @@ class ExternalSystemWorkingDirectoryInfo(
|
||||
externalProjects.add(ExternalProject(childName, childPath))
|
||||
}
|
||||
}
|
||||
return@blockingContext externalProjects
|
||||
}
|
||||
return externalProjects
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.openapi.fileEditor.impl
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
@@ -35,11 +34,9 @@ interface EditorTabTitleProvider : DumbAware {
|
||||
// Because it is quite extensively used when tabs are restored during project opening.
|
||||
// While implementations may perform long-running blocking operations, that may block all the threads of the coroutine pool.
|
||||
return withContext(limitedDispatcher) {
|
||||
blockingContext {
|
||||
getEditorTabTitle(project, file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getEditorTabTooltipText(project: Project, virtualFile: VirtualFile): @NlsContexts.Tooltip String? = null
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.intellij.facet.impl.pointers
|
||||
|
||||
import com.intellij.facet.pointers.FacetPointersManager
|
||||
import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.ProjectActivity
|
||||
@@ -12,11 +11,9 @@ private class FacetPointersPostStartupActivity : ProjectActivity {
|
||||
override suspend fun execute(project: Project) {
|
||||
val manager = project.serviceAsync<FacetPointersManager>()
|
||||
if (manager is FacetPointersManagerImpl) {
|
||||
blockingContext {
|
||||
DumbService.getInstance(project).smartInvokeLater {
|
||||
manager.refreshPointers()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,13 @@ package com.intellij.ide.environment.impl
|
||||
import com.fasterxml.jackson.core.JsonFactory
|
||||
import com.fasterxml.jackson.core.util.DefaultIndenter
|
||||
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
|
||||
import com.intellij.ide.environment.EnvironmentKey
|
||||
import com.intellij.ide.environment.EnvironmentKeyProvider
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.ModernApplicationStarter
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.platform.util.ArgsParser
|
||||
import com.intellij.util.io.createParentDirectories
|
||||
import com.intellij.util.io.write
|
||||
@@ -19,6 +19,7 @@ import kotlinx.coroutines.withContext
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.nio.file.FileAlreadyExistsException
|
||||
import java.nio.file.Path
|
||||
import java.util.function.Supplier
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.absolute
|
||||
import kotlin.io.path.createFile
|
||||
@@ -61,9 +62,7 @@ class EnvironmentKeyStubGenerator : ModernApplicationStarter() {
|
||||
}
|
||||
|
||||
private suspend fun generateKeyConfig(generateDescriptions: Boolean, configuration: EnvironmentConfiguration): ByteArray {
|
||||
val environmentKeys = blockingContext {
|
||||
EnvironmentKeyProvider.EP_NAME.extensionList.flatMap { it.knownKeys.toList() }
|
||||
}.sortedBy { it.first.id }
|
||||
val environmentKeys = EnvironmentKeyProvider.EP_NAME.extensionList.flatMap { it.knownKeys.toList() }.sortedBy { it.first.id }
|
||||
|
||||
val registeredKeys = environmentKeys.mapTo(HashSet()) { it.first }
|
||||
val unregisteredValues = configuration.map.entries.filter { it.key !in registeredKeys }
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
import com.intellij.openapi.fileEditor.impl.EditorWindow
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorOpenOptions
|
||||
import com.intellij.openapi.fileEditor.impl.NonProjectFileWritingAccessProvider
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -111,7 +110,6 @@ class FileDropManager(
|
||||
}
|
||||
|
||||
withContext(Dispatchers.EDT) {
|
||||
blockingContext {
|
||||
for (vFile in vFiles) {
|
||||
if (editorWindow != null && !editorWindow.isDisposed) {
|
||||
val fileEditorManager = FileEditorManager.getInstance(project) as FileEditorManagerEx
|
||||
@@ -126,7 +124,6 @@ class FileDropManager(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private class CustomFileDropHandlerBridge : FileDropHandler {
|
||||
@@ -135,7 +132,6 @@ private class CustomFileDropHandlerBridge : FileDropHandler {
|
||||
if (extensions.isEmpty()) return false
|
||||
|
||||
return withContext(Dispatchers.EDT) {
|
||||
blockingContext {
|
||||
extensions.any {
|
||||
it.canHandle(e.transferable, e.editor)
|
||||
&& it.handleDrop(e.transferable, e.editor, e.project)
|
||||
@@ -143,4 +139,3 @@ private class CustomFileDropHandlerBridge : FileDropHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager
|
||||
import com.intellij.openapi.fileTypes.INativeFileType
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.pom.Navigatable
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -89,10 +88,8 @@ class FileNavigatorImpl : FileNavigator {
|
||||
}
|
||||
|
||||
withContext(Dispatchers.EDT) {
|
||||
blockingContext {
|
||||
OpenFileDescriptor.navigateInEditor(descriptor, e)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.fileEditor.impl.HistoryEntry.Companion.FILE_ATTRIBUT
|
||||
import com.intellij.openapi.fileEditor.impl.HistoryEntry.Companion.TAG
|
||||
import com.intellij.openapi.fileEditor.impl.text.AsyncEditorLoader
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorImpl
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.project.PossiblyDumbAware
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -220,13 +219,11 @@ open class EditorComposite internal constructor(
|
||||
val (goodPublisher, deprecatedPublisher) = deferredPublishers.await()
|
||||
span("file opening in EDT and repaint", Dispatchers.ui(UiDispatcherKind.RELAX)) {
|
||||
span("beforeFileOpened event executing") {
|
||||
blockingContext {
|
||||
computeOrLogException(
|
||||
lambda = { beforePublisher!!.beforeFileOpened(fileEditorManager, file) },
|
||||
errorMessage = { "exception during beforeFileOpened notification" },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
applyFileEditorsInEdt(
|
||||
states = states,
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.intellij.openapi.fileEditor.impl.text.FileEditorDropHandler
|
||||
import com.intellij.openapi.keymap.Keymap
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener
|
||||
import com.intellij.openapi.keymap.KeymapUtil
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ProjectLocator
|
||||
import com.intellij.openapi.ui.Divider
|
||||
@@ -1090,7 +1089,6 @@ private fun computeFileEntry(
|
||||
val fileProviderDeferred = compositeCoroutineScope.async(start = if (fileEntry.currentInTab) CoroutineStart.DEFAULT else CoroutineStart.LAZY) {
|
||||
// https://youtrack.jetbrains.com/issue/IJPL-157845/Incorrect-encoding-of-file-during-project-opening
|
||||
if (notFullyPreparedFile !is VirtualFileWithoutContent && !notFullyPreparedFile.isCharsetSet) {
|
||||
blockingContext {
|
||||
ProjectLocator.withPreferredProject(notFullyPreparedFile, fileEditorManager.project).use {
|
||||
try {
|
||||
notFullyPreparedFile.contentsToByteArray(true)
|
||||
@@ -1105,7 +1103,6 @@ private fun computeFileEntry(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
notFullyPreparedFile
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorWithProvider
|
||||
import com.intellij.openapi.fileTypes.FileType
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -104,7 +103,7 @@ class FileEditorProviderManagerImpl
|
||||
|
||||
val sharedProviders = coroutineScope {
|
||||
val fileType = async {
|
||||
blockingContext { file.fileType }
|
||||
file.fileType
|
||||
}
|
||||
|
||||
var hasDocument: Boolean? = null
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.waitForSmartMode
|
||||
import kotlinx.coroutines.*
|
||||
@@ -116,18 +115,16 @@ class FUStateUsagesLogger private constructor(coroutineScope: CoroutineScope) :
|
||||
val data = mergeWithEventData(groupData, metric.data)
|
||||
val eventData = data?.build() ?: emptyMap()
|
||||
launch {
|
||||
blockingContext { logger.logAsync(group, metric.eventId, eventData, true) }.asDeferred().join()
|
||||
logger.logAsync(group, metric.eventId, eventData, true).asDeferred().join()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
blockingContext {
|
||||
logger.logAsync(group, EventLogSystemEvents.STATE_COLLECTOR_INVOKED, FeatureUsageData(group.recorder).addProject(project).build(), true).join()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addProject(project: Project?, recorder: String): FeatureUsageData? {
|
||||
return if (project == null) null else FeatureUsageData(recorder).addProject(project)
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.codeWithMe.ClientId
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ComponentManagerEx
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.openapi.progress.runBlockingMaybeCancellable
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.platform.util.coroutines.childScope
|
||||
@@ -87,11 +86,9 @@ class CoroutineDispatcherBackedExecutor(coroutineScope: CoroutineScope, name: St
|
||||
override fun execute(command: Runnable) {
|
||||
childScope.coroutineContext.ensureActive()
|
||||
childScope.launch(ClientId.coroutineContext()) {
|
||||
blockingContext {
|
||||
command.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
for (job in childScope.coroutineContext.job.children.toList()) {
|
||||
|
||||
@@ -27,7 +27,6 @@ object GitCodeReviewUtils {
|
||||
|
||||
suspend fun testRevisionsExist(repository: GitRepository, revisions: List<String>) =
|
||||
withContext(Dispatchers.IO) {
|
||||
blockingContext {
|
||||
val h = GitLineHandler(repository.project, repository.root, GitCommand.CAT_FILE)
|
||||
h.setSilent(true)
|
||||
h.addParameters("--batch-check=%(objecttype)")
|
||||
@@ -36,15 +35,12 @@ object GitCodeReviewUtils {
|
||||
|
||||
!Git.getInstance().runCommand(h).getOutputOrThrow().contains("missing")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun testIsAncestor(repository: GitRepository, potentialAncestorRev: String, rev: String): Boolean =
|
||||
withContext(Dispatchers.IO) {
|
||||
blockingContext {
|
||||
val h = GitLineHandler(repository.project, repository.root, GitCommand.MERGE_BASE)
|
||||
h.setSilent(true)
|
||||
h.addParameters("--is-ancestor", potentialAncestorRev, rev)
|
||||
Git.getInstance().runCommand(h).success()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user