mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-156676 use coroutineScope instead of Disposable
GitOrigin-RevId: 7e6ee2c3efcda2d23797333bd414c299445257a0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
109c77273d
commit
5b95425215
@@ -23,6 +23,7 @@ import com.intellij.psi.impl.PsiElementFactoryImpl;
|
||||
import com.intellij.psi.impl.file.impl.JavaFileManager;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveCache;
|
||||
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
|
||||
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -30,6 +31,7 @@ import java.io.File;
|
||||
/**
|
||||
* Used in Kotlin.
|
||||
*/
|
||||
@Internal
|
||||
public class JavaCoreProjectEnvironment extends CoreProjectEnvironment {
|
||||
private final JavaFileManager myFileManager;
|
||||
private final PackageIndex myPackageIndex;
|
||||
|
||||
@@ -115,38 +115,6 @@ c:com.intellij.concurrency.SensitiveProgressWrapper
|
||||
c:com.intellij.core.CoreASTFactory
|
||||
- com.intellij.lang.DefaultASTFactoryImpl
|
||||
- <init>():V
|
||||
c:com.intellij.core.CoreApplicationEnvironment
|
||||
- pf:application:com.intellij.mock.MockApplication
|
||||
- pf:myJarFileSystem:com.intellij.openapi.vfs.VirtualFileSystem
|
||||
- <init>(com.intellij.openapi.Disposable):V
|
||||
- <init>(com.intellij.openapi.Disposable,Z):V
|
||||
- addExplicitExtension(com.intellij.lang.LanguageExtension,com.intellij.lang.Language,java.lang.Object):V
|
||||
- addExplicitExtension(com.intellij.openapi.fileTypes.FileTypeExtension,com.intellij.openapi.fileTypes.FileType,java.lang.Object):V
|
||||
- addExplicitExtension(com.intellij.openapi.util.ClassExtension,java.lang.Class,java.lang.Object):V
|
||||
- addExtension(com.intellij.openapi.extensions.ExtensionPointName,java.lang.Object):V
|
||||
- p:createApplication(com.intellij.openapi.Disposable):com.intellij.mock.MockApplication
|
||||
- p:createJarFileSystem():com.intellij.openapi.vfs.VirtualFileSystem
|
||||
- p:createJobLauncher():com.intellij.concurrency.JobLauncher
|
||||
- p:createJrtFileSystem():com.intellij.openapi.vfs.VirtualFileSystem
|
||||
- p:createLocalFileSystem():com.intellij.openapi.vfs.local.CoreLocalFileSystem
|
||||
- p:createProgressIndicatorProvider():com.intellij.openapi.progress.ProgressManager
|
||||
- p:createVirtualFilePointerManager():com.intellij.openapi.vfs.pointers.VirtualFilePointerManager
|
||||
- getApplication():com.intellij.mock.MockApplication
|
||||
- getJarFileSystem():com.intellij.openapi.vfs.VirtualFileSystem
|
||||
- getJrtFileSystem():com.intellij.openapi.vfs.VirtualFileSystem
|
||||
- getLocalFileSystem():com.intellij.openapi.vfs.local.CoreLocalFileSystem
|
||||
- getParentDisposable():com.intellij.openapi.Disposable
|
||||
- registerApplicationComponent(java.lang.Class,java.lang.Object):V
|
||||
- s:registerApplicationDynamicExtensionPoint(java.lang.String,java.lang.Class):V
|
||||
- s:registerApplicationExtensionPoint(com.intellij.openapi.extensions.ExtensionPointName,java.lang.Class):V
|
||||
- registerApplicationService(java.lang.Class,java.lang.Object):V
|
||||
- s:registerComponentInstance(com.intellij.util.pico.DefaultPicoContainer,java.lang.Class,java.lang.Object):V
|
||||
- s:registerExtensionPoint(com.intellij.openapi.extensions.ExtensionsArea,com.intellij.openapi.extensions.ExtensionPointName,java.lang.Class):V
|
||||
- s:registerExtensionPoint(com.intellij.openapi.extensions.ExtensionsArea,java.lang.String,java.lang.Class):V
|
||||
- s:registerExtensionPointAndExtensions(java.nio.file.Path,java.lang.String,com.intellij.openapi.extensions.ExtensionsArea):V
|
||||
- registerFileType(com.intellij.openapi.fileTypes.FileType,java.lang.String):V
|
||||
- registerParserDefinition(com.intellij.lang.Language,com.intellij.lang.ParserDefinition):V
|
||||
- registerParserDefinition(com.intellij.lang.ParserDefinition):V
|
||||
f:com.intellij.core.CoreFileTypeRegistry
|
||||
- com.intellij.openapi.fileTypes.FileTypeRegistry
|
||||
- <init>():V
|
||||
@@ -157,20 +125,6 @@ f:com.intellij.core.CoreFileTypeRegistry
|
||||
- getRegisteredFileTypes():com.intellij.openapi.fileTypes.FileType[]
|
||||
- isFileIgnored(com.intellij.openapi.vfs.VirtualFile):Z
|
||||
- registerFileType(com.intellij.openapi.fileTypes.FileType,java.lang.String):V
|
||||
c:com.intellij.core.CoreProjectEnvironment
|
||||
- pf:myFileIndexFacade:com.intellij.openapi.roots.FileIndexFacade
|
||||
- pf:myPsiManager:com.intellij.psi.impl.PsiManagerImpl
|
||||
- pf:project:com.intellij.mock.MockProject
|
||||
- <init>(com.intellij.openapi.Disposable,com.intellij.core.CoreApplicationEnvironment):V
|
||||
- addProjectExtension(com.intellij.openapi.extensions.ExtensionPointName,java.lang.Object):V
|
||||
- p:createFileIndexFacade():com.intellij.openapi.roots.FileIndexFacade
|
||||
- p:createProjectScopeBuilder():com.intellij.psi.search.ProjectScopeBuilder
|
||||
- p:createResolveScopeManager(com.intellij.psi.PsiManager):com.intellij.psi.impl.ResolveScopeManager
|
||||
- getEnvironment():com.intellij.core.CoreApplicationEnvironment
|
||||
- getParentDisposable():com.intellij.openapi.Disposable
|
||||
- getProject():com.intellij.mock.MockProject
|
||||
- p:preregisterServices():V
|
||||
- registerProjectComponent(java.lang.Class,java.lang.Object):V
|
||||
c:com.intellij.core.CoreProjectScopeBuilder
|
||||
- <init>(com.intellij.openapi.project.Project,com.intellij.openapi.roots.FileIndexFacade):V
|
||||
- buildAllScope():com.intellij.psi.search.GlobalSearchScope
|
||||
@@ -867,75 +821,6 @@ c:com.intellij.lexer.StringLiteralLexer
|
||||
- p:locateUnicodeEscapeSequence(I,I):I
|
||||
- p:shouldAllowSlashZero():Z
|
||||
- start(java.lang.CharSequence,I,I,I):V
|
||||
c:com.intellij.mock.MockApplication
|
||||
- com.intellij.mock.MockComponentManager
|
||||
- com.intellij.openapi.application.ex.ApplicationEx
|
||||
- s:INSTANCES_CREATED:I
|
||||
- <init>(com.intellij.openapi.Disposable):V
|
||||
- acquireReadActionLock():com.intellij.openapi.application.AccessToken
|
||||
- acquireWriteActionLock(java.lang.Class):com.intellij.openapi.application.AccessToken
|
||||
- addApplicationListener(com.intellij.openapi.application.ApplicationListener):V
|
||||
- addApplicationListener(com.intellij.openapi.application.ApplicationListener,com.intellij.openapi.Disposable):V
|
||||
- assertIsDispatchThread():V
|
||||
- assertIsDispatchThread(javax.swing.JComponent):V
|
||||
- assertIsNonDispatchThread():V
|
||||
- assertReadAccessAllowed():V
|
||||
- assertReadAccessNotAllowed():V
|
||||
- assertWriteAccessAllowed():V
|
||||
- assertWriteIntentLockAcquired():V
|
||||
- dispose():V
|
||||
- executeOnPooledThread(java.lang.Runnable):java.util.concurrent.Future
|
||||
- executeOnPooledThread(java.util.concurrent.Callable):java.util.concurrent.Future
|
||||
- getAnyModalityState():com.intellij.openapi.application.ModalityState
|
||||
- getCoroutineScope():kotlinx.coroutines.CoroutineScope
|
||||
- getCurrentModalityState():com.intellij.openapi.application.ModalityState
|
||||
- getDefaultModalityState():com.intellij.openapi.application.ModalityState
|
||||
- getIdleTime():J
|
||||
- getModalityStateForComponent(java.awt.Component):com.intellij.openapi.application.ModalityState
|
||||
- getNoneModalityState():com.intellij.openapi.application.ModalityState
|
||||
- f:getService(java.lang.Class):java.lang.Object
|
||||
- f:getServiceIfCreated(java.lang.Class):java.lang.Object
|
||||
- getStartTime():J
|
||||
- hasWriteAction(java.lang.Class):Z
|
||||
- holdsReadLock():Z
|
||||
- invokeAndWait(java.lang.Runnable):V
|
||||
- invokeAndWait(java.lang.Runnable,com.intellij.openapi.application.ModalityState):V
|
||||
- invokeLater(java.lang.Runnable):V
|
||||
- invokeLater(java.lang.Runnable,com.intellij.openapi.application.ModalityState):V
|
||||
- invokeLater(java.lang.Runnable,com.intellij.openapi.application.ModalityState,com.intellij.openapi.util.Condition):V
|
||||
- invokeLater(java.lang.Runnable,com.intellij.openapi.util.Condition):V
|
||||
- invokeLaterOnWriteThread(java.lang.Runnable):V
|
||||
- invokeLaterOnWriteThread(java.lang.Runnable,com.intellij.openapi.application.ModalityState):V
|
||||
- invokeLaterOnWriteThread(java.lang.Runnable,com.intellij.openapi.application.ModalityState,com.intellij.openapi.util.Condition):V
|
||||
- isActive():Z
|
||||
- isCommandLine():Z
|
||||
- isDispatchThread():Z
|
||||
- isEAP():Z
|
||||
- isHeadlessEnvironment():Z
|
||||
- isInternal():Z
|
||||
- isReadAccessAllowed():Z
|
||||
- isRestartCapable():Z
|
||||
- isSaveAllowed():Z
|
||||
- isUnitTestMode():Z
|
||||
- isWriteAccessAllowed():Z
|
||||
- isWriteActionInProgress():Z
|
||||
- isWriteActionPending():Z
|
||||
- isWriteIntentLockAcquired():Z
|
||||
- removeApplicationListener(com.intellij.openapi.application.ApplicationListener):V
|
||||
- restart(Z):V
|
||||
- restart(Z,Z):V
|
||||
- runProcessWithProgressSynchronously(java.lang.Runnable,java.lang.String,Z,Z,com.intellij.openapi.project.Project,javax.swing.JComponent,java.lang.String):Z
|
||||
- runReadAction(com.intellij.openapi.util.Computable):java.lang.Object
|
||||
- runReadAction(com.intellij.openapi.util.ThrowableComputable):java.lang.Object
|
||||
- runReadAction(java.lang.Runnable):V
|
||||
- runWriteAction(com.intellij.openapi.util.Computable):java.lang.Object
|
||||
- runWriteAction(com.intellij.openapi.util.ThrowableComputable):java.lang.Object
|
||||
- runWriteAction(java.lang.Runnable):V
|
||||
- saveAll():V
|
||||
- saveSettings():V
|
||||
- setSaveAllowed(Z):V
|
||||
- s:setUp(com.intellij.openapi.Disposable):com.intellij.mock.MockApplication
|
||||
- tryRunReadAction(java.lang.Runnable):Z
|
||||
c:com.intellij.mock.MockComponentManager
|
||||
- com.intellij.openapi.Disposable
|
||||
- com.intellij.openapi.components.ComponentManager
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
com/intellij/concurrency/JobLauncher
|
||||
com/intellij/diagnostic/ActivityCategory
|
||||
com/intellij/lang/impl/PsiBuilderImpl$MyTreeStructure
|
||||
com/intellij/lang/impl/PsiBuilderImpl$StartMarker
|
||||
com/intellij/openapi/command/impl/CoreCommandProcessor$CommandDescriptor
|
||||
com/intellij/openapi/extensions/impl/ExtensionsAreaImpl
|
||||
com/intellij/psi/impl/DiffLog
|
||||
com/intellij/psi/search/ProjectScopeBuilder
|
||||
com/intellij/psi/stubs/StubBuilderType
|
||||
com/intellij/psi/stubs/StubInconsistencyReporter$EnforcedInconsistencyType
|
||||
com/intellij/psi/stubs/StubInconsistencyReporter$SourceOfCheck
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.intellij.util.KeyedLazyInstanceEP;
|
||||
import com.intellij.util.graph.GraphAlgorithms;
|
||||
import com.intellij.util.graph.impl.GraphAlgorithmsImpl;
|
||||
import com.intellij.util.pico.DefaultPicoContainer;
|
||||
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -61,6 +62,7 @@ import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Internal
|
||||
public class CoreApplicationEnvironment {
|
||||
private final CoreFileTypeRegistry myFileTypeRegistry;
|
||||
protected final MockApplication application;
|
||||
@@ -118,7 +120,7 @@ public class CoreApplicationEnvironment {
|
||||
registerApplicationService(GraphAlgorithms.class, new GraphAlgorithmsImpl());
|
||||
|
||||
registerApplicationExtensionPoint(StubElementRegistryServiceImplKt.STUB_REGISTRY_EP, StubRegistryExtension.class);
|
||||
registerApplicationService(StubElementRegistryService.class, new StubElementRegistryServiceImpl());
|
||||
registerApplicationService(StubElementRegistryService.class, new StubElementRegistryServiceImpl(application.getCoroutineScope()));
|
||||
|
||||
application.registerService(ApplicationInfo.class, ApplicationInfoImpl.class);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.ApiStatus.Internal;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.picocontainer.PicoContainer;
|
||||
|
||||
@Internal
|
||||
public class CoreProjectEnvironment {
|
||||
private final Disposable myParentDisposable;
|
||||
private final CoreApplicationEnvironment myEnvironment;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("OVERRIDE_DEPRECATION")
|
||||
|
||||
package com.intellij.mock
|
||||
|
||||
import com.intellij.lang.MetaLanguage
|
||||
@@ -11,6 +13,7 @@ import com.intellij.openapi.application.ex.ApplicationEx
|
||||
import com.intellij.openapi.application.impl.AnyModalityState
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.extensions.Extensions
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -19,7 +22,9 @@ import com.intellij.openapi.util.Condition
|
||||
import com.intellij.openapi.util.ThrowableComputable
|
||||
import com.intellij.util.concurrency.AppExecutorUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.awt.Component
|
||||
import java.lang.reflect.Modifier
|
||||
@@ -29,35 +34,41 @@ import javax.swing.JComponent
|
||||
import javax.swing.SwingUtilities
|
||||
import kotlin.concurrent.Volatile
|
||||
|
||||
@Internal
|
||||
open class MockApplication(parentDisposable: Disposable) : MockComponentManager(null, parentDisposable), ApplicationEx {
|
||||
companion object {
|
||||
var INSTANCES_CREATED: Int = 0
|
||||
private set
|
||||
|
||||
@TestOnly
|
||||
@JvmStatic
|
||||
fun setUp(parentDisposable: Disposable): MockApplication {
|
||||
val app = MockApplication(parentDisposable)
|
||||
ApplicationManager.setApplication(app, parentDisposable)
|
||||
return app
|
||||
}
|
||||
|
||||
private val logger: Logger
|
||||
get() = Logger.getInstance(MockApplication::class.java)
|
||||
private val LOG: Logger
|
||||
get() = logger<MockApplication>()
|
||||
|
||||
@Volatile
|
||||
private var warningLogged = false
|
||||
}
|
||||
|
||||
@Suppress("RAW_SCOPE_CREATION")
|
||||
private val appCoroutineScope = CoroutineScope(SupervisorJob())
|
||||
|
||||
init {
|
||||
INSTANCES_CREATED++
|
||||
@Suppress("TestOnlyProblems")
|
||||
Extensions.setRootArea(getExtensionArea(), parentDisposable)
|
||||
}
|
||||
|
||||
override fun <T> getServiceIfCreated(serviceClass: Class<T?>): T? = doGetService(serviceClass = serviceClass, createIfNeeded = false)
|
||||
override fun <T> getServiceIfCreated(serviceClass: Class<T>): T? = doGetService(serviceClass = serviceClass, createIfNeeded = false)
|
||||
|
||||
override fun <T> getService(serviceClass: Class<T?>): T? = doGetService(serviceClass = serviceClass, createIfNeeded = true)
|
||||
override fun <T> getService(serviceClass: Class<T>): T? = doGetService(serviceClass = serviceClass, createIfNeeded = true)
|
||||
|
||||
private fun <T> doGetService(serviceClass: Class<T?>, createIfNeeded: Boolean): T? {
|
||||
private fun <T> doGetService(serviceClass: Class<T>, createIfNeeded: Boolean): T? {
|
||||
super.getService(serviceClass)?.let {
|
||||
return it
|
||||
}
|
||||
@@ -78,7 +89,7 @@ open class MockApplication(parentDisposable: Disposable) : MockComponentManager(
|
||||
|
||||
override fun isEAP(): Boolean = false
|
||||
|
||||
override fun getCoroutineScope(): CoroutineScope = GlobalScope
|
||||
override fun getCoroutineScope(): CoroutineScope = appCoroutineScope
|
||||
|
||||
override fun isDispatchThread(): Boolean = SwingUtilities.isEventDispatchThread()
|
||||
|
||||
@@ -276,19 +287,24 @@ open class MockApplication(parentDisposable: Disposable) : MockComponentManager(
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
// A mock application may cause incorrect caching during tests. It does not fire extension point removed events.
|
||||
// Ensure that we have cached against correct application.
|
||||
MetaLanguage.clearAllMatchingMetaLanguagesCache()
|
||||
super.dispose()
|
||||
try {
|
||||
// A mock application may cause incorrect caching during tests. It does not fire extension point removed events.
|
||||
// Ensure that we have cached against correct application.
|
||||
MetaLanguage.clearAllMatchingMetaLanguagesCache()
|
||||
appCoroutineScope.cancel()
|
||||
}
|
||||
finally {
|
||||
super.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
private fun logInsufficientIsolation(methodName: String?, vararg args: Any?) {
|
||||
private fun logInsufficientIsolation(@Suppress("SameParameterValue") methodName: String?, vararg args: Any?) {
|
||||
if (warningLogged || !isUnitTestMode()) {
|
||||
return
|
||||
}
|
||||
|
||||
warningLogged = true
|
||||
logger.warn(
|
||||
LOG.warn(
|
||||
"Attempt to execute method \"" + methodName + "\" with arguments `" + args.contentToString() + "` within a MockApplication.\n" +
|
||||
"This is likely caused by an improper test isolation. Please consider writing tests with JUnit 5 fixtures.",
|
||||
Throwable())
|
||||
|
||||
@@ -4,15 +4,15 @@ package com.intellij.psi.stubs
|
||||
import com.intellij.lang.Language
|
||||
import com.intellij.lang.LanguageExtension
|
||||
import com.intellij.lang.LanguageParserDefinitions
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.psi.tree.IFileElementType
|
||||
import com.intellij.psi.tree.TemplateLanguageStubBaseVersion.dropVersion
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
open class StubElementRegistryServiceImpl : CoreStubElementRegistryServiceImpl(), Disposable.Default {
|
||||
open class StubElementRegistryServiceImpl(coroutineScope: CoroutineScope) : CoreStubElementRegistryServiceImpl() {
|
||||
@Volatile private lateinit var factories: Map<IElementType, StubElementFactory<*, *>>
|
||||
@Volatile private lateinit var lightFactories: Map<IElementType, LightStubElementFactory<*, *>>
|
||||
@Volatile private lateinit var type2serializerMap: Map<IElementType, ObjectStubSerializer<*, *>>
|
||||
@@ -20,8 +20,8 @@ open class StubElementRegistryServiceImpl : CoreStubElementRegistryServiceImpl()
|
||||
private set
|
||||
|
||||
init {
|
||||
STUB_REGISTRY_EP.addChangeListener(Runnable { init() }, this)
|
||||
STUB_DEFINITION_EP.point?.addChangeListener(Runnable { onStubDefinitionChange() }, this)
|
||||
STUB_REGISTRY_EP.addChangeListener(coroutineScope) { init() }
|
||||
STUB_DEFINITION_EP.point?.addChangeListener(coroutineScope) { onStubDefinitionChange() }
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
System.out.println("----- TEST STATISTICS -----");
|
||||
UsefulTestCase.logSetupTeardownCosts();
|
||||
System.out.printf("##teamcity[buildStatisticValue key='ideaTests.appInstancesCreated' value='%d']%n",
|
||||
MockApplication.INSTANCES_CREATED);
|
||||
MockApplication.Companion.getINSTANCES_CREATED());
|
||||
System.out.printf("##teamcity[buildStatisticValue key='ideaTests.projectInstancesCreated' value='%d']%n",
|
||||
TestProjectManagerKt.getTotalCreatedProjectsCount());
|
||||
long totalGcTime = 0;
|
||||
|
||||
Reference in New Issue
Block a user