mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
remove deprecated ComponentManager.getPicoContainer
GitOrigin-RevId: bd40e0f4255fcdc014c2591cf3a93b6015ed26ff
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8ef0fe70e6
commit
5754420093
@@ -24,7 +24,7 @@ public class RegExpParsingTest extends ParsingTestCase {
|
|||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
myProject.registerService(SmartPointerManager.class, new MockSmartPointerManager());
|
project.registerService(SmartPointerManager.class, new MockSmartPointerManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment {
|
|||||||
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||||
addExtension(ContainerProvider.EP_NAME, new JavaContainerProvider());
|
addExtension(ContainerProvider.EP_NAME, new JavaContainerProvider());
|
||||||
|
|
||||||
myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
|
application.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
|
||||||
|
|
||||||
myApplication.registerService(PsiSubstitutorFactory.class, new PsiSubstitutorFactoryImpl());
|
application.registerService(PsiSubstitutorFactory.class, new PsiSubstitutorFactoryImpl());
|
||||||
myApplication.registerService(JavaDirectoryService.class, createJavaDirectoryService());
|
application.registerService(JavaDirectoryService.class, createJavaDirectoryService());
|
||||||
myApplication.registerService(JavaVersionService.class, new JavaVersionService());
|
application.registerService(JavaVersionService.class, new JavaVersionService());
|
||||||
|
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiPackage.class, new PackagePresentationProvider());
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiPackage.class, new PackagePresentationProvider());
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
|
||||||
|
|||||||
@@ -37,34 +37,34 @@ public class JavaCoreProjectEnvironment extends CoreProjectEnvironment {
|
|||||||
public JavaCoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) {
|
public JavaCoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) {
|
||||||
super(parentDisposable, applicationEnvironment);
|
super(parentDisposable, applicationEnvironment);
|
||||||
|
|
||||||
myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myProject));
|
project.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(project));
|
||||||
myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
|
project.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
|
||||||
myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myProject));
|
project.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(project));
|
||||||
myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
|
project.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
|
||||||
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myProject));
|
project.registerService(JavaResolveCache.class, new JavaResolveCache(project));
|
||||||
myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
|
project.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
|
||||||
myProject.registerService(JavaFileCodeStyleFacade.class, new CoreJavaFileCodeStyleFacade());
|
project.registerService(JavaFileCodeStyleFacade.class, new CoreJavaFileCodeStyleFacade());
|
||||||
myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
|
project.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
|
||||||
myProject.registerService(ControlFlowFactory.class, new ControlFlowFactory(myProject));
|
project.registerService(ControlFlowFactory.class, new ControlFlowFactory(project));
|
||||||
|
|
||||||
myPackageIndex = createCorePackageIndex();
|
myPackageIndex = createCorePackageIndex();
|
||||||
myProject.registerService(PackageIndex.class, myPackageIndex);
|
project.registerService(PackageIndex.class, myPackageIndex);
|
||||||
|
|
||||||
myFileManager = createCoreFileManager();
|
myFileManager = createCoreFileManager();
|
||||||
myProject.registerService(JavaFileManager.class, myFileManager);
|
project.registerService(JavaFileManager.class, myFileManager);
|
||||||
|
|
||||||
myProject.registerService(JvmPsiConversionHelper.class, new JvmPsiConversionHelperImpl());
|
project.registerService(JvmPsiConversionHelper.class, new JvmPsiConversionHelperImpl());
|
||||||
registerJavaPsiFacade();
|
registerJavaPsiFacade();
|
||||||
myProject.registerService(JvmFacade.class, new JvmFacadeImpl(myProject));
|
project.registerService(JvmFacade.class, new JvmFacadeImpl(project));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerJavaPsiFacade() {
|
protected void registerJavaPsiFacade() {
|
||||||
JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject);
|
JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(project);
|
||||||
myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
|
project.registerService(JavaPsiFacade.class, javaPsiFacade);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CoreJavaPsiImplementationHelper createJavaPsiImplementationHelper() {
|
protected CoreJavaPsiImplementationHelper createJavaPsiImplementationHelper() {
|
||||||
return new CoreJavaPsiImplementationHelper(myProject);
|
return new CoreJavaPsiImplementationHelper(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JavaFileManager createCoreFileManager() {
|
protected JavaFileManager createCoreFileManager() {
|
||||||
|
|||||||
@@ -59,12 +59,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CoreApplicationEnvironment {
|
public class CoreApplicationEnvironment {
|
||||||
private final CoreFileTypeRegistry myFileTypeRegistry;
|
private final CoreFileTypeRegistry myFileTypeRegistry;
|
||||||
protected final MockApplication myApplication;
|
protected final MockApplication application;
|
||||||
private final CoreLocalFileSystem myLocalFileSystem;
|
private final CoreLocalFileSystem myLocalFileSystem;
|
||||||
@NotNull
|
protected final @NotNull VirtualFileSystem myJarFileSystem;
|
||||||
protected final VirtualFileSystem myJarFileSystem;
|
|
||||||
private final VirtualFileSystem myJrtFileSystem;
|
private final VirtualFileSystem myJrtFileSystem;
|
||||||
@NotNull private final Disposable myParentDisposable;
|
private final @NotNull Disposable myParentDisposable;
|
||||||
private final boolean myUnitTestMode;
|
private final boolean myUnitTestMode;
|
||||||
|
|
||||||
public CoreApplicationEnvironment(@NotNull Disposable parentDisposable) {
|
public CoreApplicationEnvironment(@NotNull Disposable parentDisposable) {
|
||||||
@@ -79,8 +78,8 @@ public class CoreApplicationEnvironment {
|
|||||||
|
|
||||||
myFileTypeRegistry = new CoreFileTypeRegistry();
|
myFileTypeRegistry = new CoreFileTypeRegistry();
|
||||||
|
|
||||||
myApplication = createApplication(myParentDisposable);
|
application = createApplication(myParentDisposable);
|
||||||
ApplicationManager.setApplication(myApplication,
|
ApplicationManager.setApplication(application,
|
||||||
() -> myFileTypeRegistry,
|
() -> myFileTypeRegistry,
|
||||||
myParentDisposable);
|
myParentDisposable);
|
||||||
myLocalFileSystem = createLocalFileSystem();
|
myLocalFileSystem = createLocalFileSystem();
|
||||||
@@ -111,22 +110,20 @@ public class CoreApplicationEnvironment {
|
|||||||
registerApplicationService(CommandProcessor.class, new CoreCommandProcessor());
|
registerApplicationService(CommandProcessor.class, new CoreCommandProcessor());
|
||||||
registerApplicationService(GraphAlgorithms.class, new GraphAlgorithmsImpl());
|
registerApplicationService(GraphAlgorithms.class, new GraphAlgorithmsImpl());
|
||||||
|
|
||||||
myApplication.registerService(ApplicationInfo.class, ApplicationInfoImpl.class);
|
application.registerService(ApplicationInfo.class, ApplicationInfoImpl.class);
|
||||||
|
|
||||||
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
|
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void registerApplicationService(@NotNull Class<T> serviceInterface, @NotNull T serviceImplementation) {
|
public <T> void registerApplicationService(@NotNull Class<T> serviceInterface, @NotNull T serviceImplementation) {
|
||||||
myApplication.registerService(serviceInterface, serviceImplementation);
|
application.registerService(serviceInterface, serviceImplementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
protected @NotNull VirtualFilePointerManager createVirtualFilePointerManager() {
|
||||||
protected VirtualFilePointerManager createVirtualFilePointerManager() {
|
|
||||||
return new CoreVirtualFilePointerManager();
|
return new CoreVirtualFilePointerManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
protected @NotNull MockApplication createApplication(@NotNull Disposable parentDisposable) {
|
||||||
protected MockApplication createApplication(@NotNull Disposable parentDisposable) {
|
|
||||||
return new MockApplication(parentDisposable) {
|
return new MockApplication(parentDisposable) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isUnitTestMode() {
|
public boolean isUnitTestMode() {
|
||||||
@@ -135,45 +132,38 @@ public class CoreApplicationEnvironment {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
protected @NotNull JobLauncher createJobLauncher() {
|
||||||
protected JobLauncher createJobLauncher() {
|
|
||||||
return new CoreJobLauncher();
|
return new CoreJobLauncher();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
protected @NotNull ProgressManager createProgressIndicatorProvider() {
|
||||||
protected ProgressManager createProgressIndicatorProvider() {
|
|
||||||
return new CoreProgressManager();
|
return new CoreProgressManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
protected @NotNull VirtualFileSystem createJarFileSystem() {
|
||||||
protected VirtualFileSystem createJarFileSystem() {
|
|
||||||
return new CoreJarFileSystem();
|
return new CoreJarFileSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
protected @NotNull CoreLocalFileSystem createLocalFileSystem() {
|
||||||
protected CoreLocalFileSystem createLocalFileSystem() {
|
|
||||||
return new CoreLocalFileSystem();
|
return new CoreLocalFileSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
protected @Nullable VirtualFileSystem createJrtFileSystem() {
|
||||||
protected VirtualFileSystem createJrtFileSystem() {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
public @NotNull MockApplication getApplication() {
|
||||||
public MockApplication getApplication() {
|
return application;
|
||||||
return myApplication;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
public @NotNull Disposable getParentDisposable() {
|
||||||
public Disposable getParentDisposable() {
|
|
||||||
return myParentDisposable;
|
return myParentDisposable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void registerApplicationComponent(@NotNull Class<T> interfaceClass, @NotNull T implementation) {
|
public <T> void registerApplicationComponent(@NotNull Class<T> interfaceClass, @NotNull T implementation) {
|
||||||
registerComponentInstance(myApplication.getPicoContainer(), interfaceClass, implementation);
|
registerComponentInstance(application.getPicoContainer(), interfaceClass, implementation);
|
||||||
if (implementation instanceof Disposable) {
|
if (implementation instanceof Disposable) {
|
||||||
Disposer.register(myApplication, (Disposable)implementation);
|
Disposer.register(application, (Disposable)implementation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,15 +188,15 @@ public class CoreApplicationEnvironment {
|
|||||||
addExplicitExtension(LanguageParserDefinitions.INSTANCE, language, parserDefinition);
|
addExplicitExtension(LanguageParserDefinitions.INSTANCE, language, parserDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void addExplicitExtension(@NotNull final FileTypeExtension<T> instance, @NotNull final FileType fileType, @NotNull final T object) {
|
public <T> void addExplicitExtension(final @NotNull FileTypeExtension<T> instance, final @NotNull FileType fileType, final @NotNull T object) {
|
||||||
instance.addExplicitExtension(fileType, object, myParentDisposable);
|
instance.addExplicitExtension(fileType, object, myParentDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void addExplicitExtension(@NotNull final ClassExtension<T> instance, @NotNull final Class aClass, @NotNull final T object) {
|
public <T> void addExplicitExtension(final @NotNull ClassExtension<T> instance, final @NotNull Class aClass, final @NotNull T object) {
|
||||||
instance.addExplicitExtension(aClass, object, myParentDisposable);
|
instance.addExplicitExtension(aClass, object, myParentDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void addExtension(@NotNull ExtensionPointName<T> name, @NotNull final T extension) {
|
public <T> void addExtension(@NotNull ExtensionPointName<T> name, final @NotNull T extension) {
|
||||||
final ExtensionPoint<T> extensionPoint = Extensions.getRootArea().getExtensionPoint(name);
|
final ExtensionPoint<T> extensionPoint = Extensions.getRootArea().getExtensionPoint(name);
|
||||||
//noinspection TestOnlyProblems
|
//noinspection TestOnlyProblems
|
||||||
extensionPoint.registerExtension(extension, myParentDisposable);
|
extensionPoint.registerExtension(extension, myParentDisposable);
|
||||||
@@ -255,18 +245,15 @@ public class CoreApplicationEnvironment {
|
|||||||
descriptor.registerExtensions(areaImpl.extensionPoints, descriptor.appContainerDescriptor, null);
|
descriptor.registerExtensions(areaImpl.extensionPoints, descriptor.appContainerDescriptor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
public @NotNull CoreLocalFileSystem getLocalFileSystem() {
|
||||||
public CoreLocalFileSystem getLocalFileSystem() {
|
|
||||||
return myLocalFileSystem;
|
return myLocalFileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
public @NotNull VirtualFileSystem getJarFileSystem() {
|
||||||
public VirtualFileSystem getJarFileSystem() {
|
|
||||||
return myJarFileSystem;
|
return myJarFileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public @Nullable VirtualFileSystem getJrtFileSystem() {
|
||||||
public VirtualFileSystem getJrtFileSystem() {
|
|
||||||
return myJrtFileSystem;
|
return myJrtFileSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,38 +31,38 @@ public class CoreProjectEnvironment {
|
|||||||
|
|
||||||
protected final FileIndexFacade myFileIndexFacade;
|
protected final FileIndexFacade myFileIndexFacade;
|
||||||
protected final PsiManagerImpl myPsiManager;
|
protected final PsiManagerImpl myPsiManager;
|
||||||
protected final MockProject myProject;
|
protected final MockProject project;
|
||||||
|
|
||||||
public CoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) {
|
public CoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) {
|
||||||
myParentDisposable = parentDisposable;
|
myParentDisposable = parentDisposable;
|
||||||
myEnvironment = applicationEnvironment;
|
myEnvironment = applicationEnvironment;
|
||||||
myProject = createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);
|
project = createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);
|
||||||
|
|
||||||
preregisterServices();
|
preregisterServices();
|
||||||
|
|
||||||
myFileIndexFacade = createFileIndexFacade();
|
myFileIndexFacade = createFileIndexFacade();
|
||||||
|
|
||||||
PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
|
PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(project);
|
||||||
myProject.registerService(PsiModificationTracker.class, modificationTracker);
|
project.registerService(PsiModificationTracker.class, modificationTracker);
|
||||||
myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
|
project.registerService(FileIndexFacade.class, myFileIndexFacade);
|
||||||
myProject.registerService(ResolveCache.class, new ResolveCache(myProject));
|
project.registerService(ResolveCache.class, new ResolveCache(project));
|
||||||
|
|
||||||
myPsiManager = new PsiManagerImpl(myProject);
|
myPsiManager = new PsiManagerImpl(project);
|
||||||
myProject.registerService(PsiManager.class, myPsiManager);
|
project.registerService(PsiManager.class, myPsiManager);
|
||||||
myProject.registerService(SmartPointerManager.class, SmartPointerManagerImpl.class);
|
project.registerService(SmartPointerManager.class, SmartPointerManagerImpl.class);
|
||||||
myProject.registerService(DocumentCommitProcessor.class, new MockDocumentCommitProcessor());
|
project.registerService(DocumentCommitProcessor.class, new MockDocumentCommitProcessor());
|
||||||
myProject.registerService(PsiDocumentManager.class, new CorePsiDocumentManager(myProject));
|
project.registerService(PsiDocumentManager.class, new CorePsiDocumentManager(project));
|
||||||
|
|
||||||
myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));
|
project.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));
|
||||||
|
|
||||||
myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
|
project.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
|
||||||
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myProject)));
|
project.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(project, new PsiCachedValuesFactory(project)));
|
||||||
myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myProject));
|
project.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(project));
|
||||||
myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
|
project.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
|
||||||
myProject.registerService(DumbService.class, new MockDumbService(myProject));
|
project.registerService(DumbService.class, new MockDumbService(project));
|
||||||
myProject.registerService(DumbUtil.class, new MockDumbUtil());
|
project.registerService(DumbUtil.class, new MockDumbUtil());
|
||||||
myProject.registerService(CoreEncodingProjectManager.class, CoreEncodingProjectManager.class);
|
project.registerService(CoreEncodingProjectManager.class, CoreEncodingProjectManager.class);
|
||||||
myProject.registerService(InjectedLanguageManager.class, new CoreInjectedLanguageManager());
|
project.registerService(InjectedLanguageManager.class, new CoreInjectedLanguageManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -72,7 +72,7 @@ public class CoreProjectEnvironment {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected ProjectScopeBuilder createProjectScopeBuilder() {
|
protected ProjectScopeBuilder createProjectScopeBuilder() {
|
||||||
return new CoreProjectScopeBuilder(myProject, myFileIndexFacade);
|
return new CoreProjectScopeBuilder(project, myFileIndexFacade);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void preregisterServices() {
|
protected void preregisterServices() {
|
||||||
@@ -81,7 +81,7 @@ public class CoreProjectEnvironment {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected FileIndexFacade createFileIndexFacade() {
|
protected FileIndexFacade createFileIndexFacade() {
|
||||||
return new MockFileIndexFacade(myProject);
|
return new MockFileIndexFacade(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -91,13 +91,13 @@ public class CoreProjectEnvironment {
|
|||||||
|
|
||||||
public <T> void addProjectExtension(@NotNull ExtensionPointName<T> name, @NotNull final T extension) {
|
public <T> void addProjectExtension(@NotNull ExtensionPointName<T> name, @NotNull final T extension) {
|
||||||
//noinspection TestOnlyProblems
|
//noinspection TestOnlyProblems
|
||||||
name.getPoint(myProject).registerExtension(extension, myParentDisposable);
|
name.getPoint(project).registerExtension(extension, myParentDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void registerProjectComponent(@NotNull Class<T> interfaceClass, @NotNull T implementation) {
|
public <T> void registerProjectComponent(@NotNull Class<T> interfaceClass, @NotNull T implementation) {
|
||||||
CoreApplicationEnvironment.registerComponentInstance(myProject.getPicoContainer(), interfaceClass, implementation);
|
CoreApplicationEnvironment.registerComponentInstance(project.getPicoContainer(), interfaceClass, implementation);
|
||||||
if (implementation instanceof Disposable) {
|
if (implementation instanceof Disposable) {
|
||||||
Disposer.register(myProject, (Disposable) implementation);
|
Disposer.register(project, (Disposable) implementation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +113,6 @@ public class CoreProjectEnvironment {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public MockProject getProject() {
|
public MockProject getProject() {
|
||||||
return myProject;
|
return project;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,17 +36,15 @@ public class MockApplication extends MockComponentManager implements Application
|
|||||||
Extensions.setRootArea(getExtensionArea(), parentDisposable);
|
Extensions.setRootArea(getExtensionArea(), parentDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
public static MockApplication setUp(@NotNull Disposable parentDisposable) {
|
public static @NotNull MockApplication setUp(@NotNull Disposable parentDisposable) {
|
||||||
MockApplication app = new MockApplication(parentDisposable);
|
MockApplication app = new MockApplication(parentDisposable);
|
||||||
ApplicationManager.setApplication(app, parentDisposable);
|
ApplicationManager.setApplication(app, parentDisposable);
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public final <T> T getServiceIfCreated(@NotNull Class<T> serviceClass) {
|
public final @Nullable <T> T getServiceIfCreated(@NotNull Class<T> serviceClass) {
|
||||||
return doGetService(serviceClass, false);
|
return doGetService(serviceClass, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,15 +149,13 @@ public class MockApplication extends MockComponentManager implements Application
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public Future<?> executeOnPooledThread(@NotNull Runnable action) {
|
public @NotNull Future<?> executeOnPooledThread(@NotNull Runnable action) {
|
||||||
return AppExecutorUtil.getAppExecutorService().submit(action);
|
return AppExecutorUtil.getAppExecutorService().submit(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Future<T> executeOnPooledThread(@NotNull Callable<T> action) {
|
public @NotNull <T> Future<T> executeOnPooledThread(@NotNull Callable<T> action) {
|
||||||
return AppExecutorUtil.getAppExecutorService().submit(action);
|
return AppExecutorUtil.getAppExecutorService().submit(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,15 +209,13 @@ public class MockApplication extends MockComponentManager implements Application
|
|||||||
return computation.compute();
|
return computation.compute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public AccessToken acquireReadActionLock() {
|
public @NotNull AccessToken acquireReadActionLock() {
|
||||||
return AccessToken.EMPTY_ACCESS_TOKEN;
|
return AccessToken.EMPTY_ACCESS_TOKEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public AccessToken acquireWriteActionLock(@Nullable Class<?> marker) {
|
public @NotNull AccessToken acquireWriteActionLock(@Nullable Class<?> marker) {
|
||||||
return AccessToken.EMPTY_ACCESS_TOKEN;
|
return AccessToken.EMPTY_ACCESS_TOKEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,18 +246,17 @@ public class MockApplication extends MockComponentManager implements Application
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public ModalityState getNoneModalityState() {
|
public @NotNull ModalityState getNoneModalityState() {
|
||||||
return ModalityState.NON_MODAL;
|
return ModalityState.NON_MODAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invokeLater(@NotNull final Runnable runnable, @NotNull final Condition<?> expired) {
|
public void invokeLater(final @NotNull Runnable runnable, final @NotNull Condition<?> expired) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invokeLater(@NotNull final Runnable runnable, @NotNull final ModalityState state, @NotNull final Condition<?> expired) {
|
public void invokeLater(final @NotNull Runnable runnable, final @NotNull ModalityState state, final @NotNull Condition<?> expired) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -276,8 +269,7 @@ public class MockApplication extends MockComponentManager implements Application
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
public @NotNull ModalityInvokator getInvokator() {
|
||||||
public ModalityInvokator getInvokator() {
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,27 +293,23 @@ public class MockApplication extends MockComponentManager implements Application
|
|||||||
invokeAndWait(runnable, getDefaultModalityState());
|
invokeAndWait(runnable, getDefaultModalityState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public ModalityState getCurrentModalityState() {
|
public @NotNull ModalityState getCurrentModalityState() {
|
||||||
return getNoneModalityState();
|
return getNoneModalityState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public ModalityState getAnyModalityState() {
|
public @NotNull ModalityState getAnyModalityState() {
|
||||||
return AnyModalityState.ANY;
|
return AnyModalityState.ANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public ModalityState getModalityStateForComponent(@NotNull Component c) {
|
public @NotNull ModalityState getModalityStateForComponent(@NotNull Component c) {
|
||||||
return getNoneModalityState();
|
return getNoneModalityState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public ModalityState getDefaultModalityState() {
|
public @NotNull ModalityState getDefaultModalityState() {
|
||||||
return getNoneModalityState();
|
return getNoneModalityState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +346,7 @@ public class MockApplication extends MockComponentManager implements Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assertIsDispatchThread(@Nullable final JComponent component) {
|
public void assertIsDispatchThread(final @Nullable JComponent component) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.NonNls;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.picocontainer.ComponentAdapter;
|
import org.picocontainer.ComponentAdapter;
|
||||||
import org.picocontainer.MutablePicoContainer;
|
|
||||||
import org.picocontainer.PicoContainer;
|
import org.picocontainer.PicoContainer;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -32,7 +31,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class MockComponentManager extends UserDataHolderBase implements ComponentManager, MessageBusOwner {
|
public class MockComponentManager extends UserDataHolderBase implements ComponentManager, MessageBusOwner {
|
||||||
private final MessageBus myMessageBus = MessageBusFactoryImpl.createRootBus(this);
|
private final MessageBus myMessageBus = MessageBusFactoryImpl.createRootBus(this);
|
||||||
private final DefaultPicoContainer myPicoContainer;
|
private final DefaultPicoContainer picoContainer;
|
||||||
private final ExtensionsAreaImpl myExtensionArea;
|
private final ExtensionsAreaImpl myExtensionArea;
|
||||||
|
|
||||||
private final Map<Class<?>, Object> myComponents = new HashMap<>();
|
private final Map<Class<?>, Object> myComponents = new HashMap<>();
|
||||||
@@ -40,7 +39,7 @@ public class MockComponentManager extends UserDataHolderBase implements Componen
|
|||||||
private boolean myDisposed;
|
private boolean myDisposed;
|
||||||
|
|
||||||
public MockComponentManager(@Nullable PicoContainer parent, @NotNull Disposable parentDisposable) {
|
public MockComponentManager(@Nullable PicoContainer parent, @NotNull Disposable parentDisposable) {
|
||||||
myPicoContainer = new DefaultPicoContainer((DefaultPicoContainer)parent) {
|
picoContainer = new DefaultPicoContainer((DefaultPicoContainer)parent) {
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Object getComponentInstance(@NotNull Object componentKey) {
|
public @Nullable Object getComponentInstance(@NotNull Object componentKey) {
|
||||||
if (myDisposed) {
|
if (myDisposed) {
|
||||||
@@ -53,11 +52,15 @@ public class MockComponentManager extends UserDataHolderBase implements Componen
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
myPicoContainer.registerComponentInstance(getClass(), this);
|
picoContainer.registerComponentInstance(getClass(), this);
|
||||||
myExtensionArea = new ExtensionsAreaImpl(this);
|
myExtensionArea = new ExtensionsAreaImpl(this);
|
||||||
Disposer.register(parentDisposable, this);
|
Disposer.register(parentDisposable, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DefaultPicoContainer getPicoContainer() {
|
||||||
|
return picoContainer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ExtensionsAreaImpl getExtensionArea() {
|
public @NotNull ExtensionsAreaImpl getExtensionArea() {
|
||||||
return myExtensionArea;
|
return myExtensionArea;
|
||||||
@@ -96,8 +99,8 @@ public class MockComponentManager extends UserDataHolderBase implements Componen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void registerService(@NotNull Class<T> serviceInterface, @NotNull Class<? extends T> serviceImplementation) {
|
public <T> void registerService(@NotNull Class<T> serviceInterface, @NotNull Class<? extends T> serviceImplementation) {
|
||||||
myPicoContainer.unregisterComponent(serviceInterface.getName());
|
picoContainer.unregisterComponent(serviceInterface.getName());
|
||||||
myPicoContainer.registerComponentImplementation(serviceInterface.getName(), serviceImplementation);
|
picoContainer.registerComponentImplementation(serviceInterface.getName(), serviceImplementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void registerService(@NotNull Class<T> serviceImplementation) {
|
public <T> void registerService(@NotNull Class<T> serviceImplementation) {
|
||||||
@@ -105,14 +108,14 @@ public class MockComponentManager extends UserDataHolderBase implements Componen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void registerService(@NotNull Class<T> serviceInterface, @NotNull T serviceImplementation) {
|
public <T> void registerService(@NotNull Class<T> serviceInterface, @NotNull T serviceImplementation) {
|
||||||
myPicoContainer.registerComponentInstance(serviceInterface.getName(), serviceImplementation);
|
picoContainer.registerComponentInstance(serviceInterface.getName(), serviceImplementation);
|
||||||
registerComponentInDisposer(serviceImplementation);
|
registerComponentInDisposer(serviceImplementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void registerService(@NotNull Class<T> serviceInterface, @NotNull T serviceImplementation, @NotNull Disposable parentDisposable) {
|
public <T> void registerService(@NotNull Class<T> serviceInterface, @NotNull T serviceImplementation, @NotNull Disposable parentDisposable) {
|
||||||
String key = serviceInterface.getName();
|
String key = serviceInterface.getName();
|
||||||
registerService(serviceInterface, serviceImplementation);
|
registerService(serviceInterface, serviceImplementation);
|
||||||
Disposer.register(parentDisposable, () -> myPicoContainer.unregisterComponent(key));
|
Disposer.register(parentDisposable, () -> picoContainer.unregisterComponent(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void addComponent(@NotNull Class<T> interfaceClass, @NotNull T instance) {
|
public <T> void addComponent(@NotNull Class<T> interfaceClass, @NotNull T instance) {
|
||||||
@@ -122,25 +125,20 @@ public class MockComponentManager extends UserDataHolderBase implements Componen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable <T> T getComponent(@NotNull Class<T> interfaceClass) {
|
public @Nullable <T> T getComponent(@NotNull Class<T> interfaceClass) {
|
||||||
final Object o = myPicoContainer.getComponentInstance(interfaceClass);
|
final Object o = picoContainer.getComponentInstance(interfaceClass);
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (T)(o != null ? o : myComponents.get(interfaceClass));
|
return (T)(o != null ? o : myComponents.get(interfaceClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T getService(@NotNull Class<T> serviceClass) {
|
public <T> T getService(@NotNull Class<T> serviceClass) {
|
||||||
T result = myPicoContainer.getService(serviceClass);
|
T result = picoContainer.getService(serviceClass);
|
||||||
registerComponentInDisposer(result);
|
registerComponentInDisposer(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final @NotNull MutablePicoContainer getPicoContainer() {
|
|
||||||
return myPicoContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final ComponentAdapter getComponentAdapter(@NotNull Object componentKey) {
|
public final ComponentAdapter getComponentAdapter(@NotNull Object componentKey) {
|
||||||
return myPicoContainer.getComponentAdapter(componentKey);
|
return picoContainer.getComponentAdapter(componentKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
|||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.util.Condition;
|
import com.intellij.openapi.util.Condition;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.util.pico.DefaultPicoContainer;
|
|
||||||
import kotlinx.coroutines.CoroutineScope;
|
import kotlinx.coroutines.CoroutineScope;
|
||||||
import kotlinx.coroutines.GlobalScope;
|
import kotlinx.coroutines.GlobalScope;
|
||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
||||||
@@ -99,8 +98,7 @@ public class MockProject extends MockComponentManager implements Project {
|
|||||||
|
|
||||||
public @NotNull <T> List<T> getComponentInstancesOfType(@NotNull Class<T> componentType) {
|
public @NotNull <T> List<T> getComponentInstancesOfType(@NotNull Class<T> componentType) {
|
||||||
List<T> result = new ArrayList<>();
|
List<T> result = new ArrayList<>();
|
||||||
DefaultPicoContainer container = (DefaultPicoContainer)getPicoContainer();
|
getPicoContainer().getComponentAdapters().forEach(componentAdapter -> {
|
||||||
container.getComponentAdapters().forEach(componentAdapter -> {
|
|
||||||
Class<?> descendant = componentAdapter.getComponentImplementation();
|
Class<?> descendant = componentAdapter.getComponentImplementation();
|
||||||
if (componentType == descendant || componentType.isAssignableFrom(descendant)) {
|
if (componentType == descendant || componentType.isAssignableFrom(descendant)) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import org.jetbrains.annotations.ApiStatus;
|
|||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.picocontainer.PicoContainer;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -48,20 +47,12 @@ public interface ComponentManager extends UserDataHolder, Disposable, AreaInstan
|
|||||||
/**
|
/**
|
||||||
* Checks whether there is a component with the specified interface class.
|
* Checks whether there is a component with the specified interface class.
|
||||||
*
|
*
|
||||||
* @param interfaceClass interface class of component to be checked
|
* @param interfaceClass interface class of a component to be checked
|
||||||
* @return {@code true} if there is a component with the specified interface class;
|
* @return {@code true} if there is a component with the specified interface class;
|
||||||
* {@code false} otherwise
|
* {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
boolean hasComponent(@NotNull Class<?> interfaceClass);
|
boolean hasComponent(@NotNull Class<?> interfaceClass);
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use ComponentManager API
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@ApiStatus.Internal
|
|
||||||
@ApiStatus.ScheduledForRemoval
|
|
||||||
@NotNull PicoContainer getPicoContainer();
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
boolean isInjectionForExtensionSupported();
|
boolean isInjectionForExtensionSupported();
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.picocontainer.PicoContainer;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
@@ -367,11 +366,6 @@ public class ExtensionPointImplTest {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull PicoContainer getPicoContainer() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInjectionForExtensionSupported() {
|
public boolean isInjectionForExtensionSupported() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import org.jetbrains.annotations.NonNls;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.SystemIndependent;
|
import org.jetbrains.annotations.SystemIndependent;
|
||||||
import org.picocontainer.PicoContainer;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -86,11 +85,6 @@ public final class DummyProject extends UserDataHolderBase implements Project {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull PicoContainer getPicoContainer() {
|
|
||||||
throw new UnsupportedOperationException("getPicoContainer is not implement in : " + getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInjectionForExtensionSupported() {
|
public boolean isInjectionForExtensionSupported() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.intellij.serviceContainer.ComponentManagerImpl;
|
|||||||
import com.intellij.util.messages.MessageBus;
|
import com.intellij.util.messages.MessageBus;
|
||||||
import kotlinx.coroutines.CoroutineScope;
|
import kotlinx.coroutines.CoroutineScope;
|
||||||
import org.jetbrains.annotations.*;
|
import org.jetbrains.annotations.*;
|
||||||
import org.picocontainer.PicoContainer;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -230,11 +229,6 @@ final class DefaultProject extends UserDataHolderBase implements Project {
|
|||||||
return getDelegate().getComponent(interfaceClass);
|
return getDelegate().getComponent(interfaceClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull PicoContainer getPicoContainer() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInjectionForExtensionSupported() {
|
public boolean isInjectionForExtensionSupported() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
@file:Suppress("ReplaceNegatedIsEmptyWithIsNotEmpty", "ReplaceGetOrSet", "ReplacePutWithAssignment", "OVERRIDE_DEPRECATION")
|
@file:Suppress("ReplaceNegatedIsEmptyWithIsNotEmpty", "ReplaceGetOrSet", "ReplacePutWithAssignment")
|
||||||
package com.intellij.serviceContainer
|
package com.intellij.serviceContainer
|
||||||
|
|
||||||
import com.intellij.concurrency.resetThreadContext
|
import com.intellij.concurrency.resetThreadContext
|
||||||
@@ -17,6 +17,7 @@ import com.intellij.openapi.components.ServiceDescriptor.PreloadMode
|
|||||||
import com.intellij.openapi.components.impl.stores.IComponentStore
|
import com.intellij.openapi.components.impl.stores.IComponentStore
|
||||||
import com.intellij.openapi.diagnostic.Attachment
|
import com.intellij.openapi.diagnostic.Attachment
|
||||||
import com.intellij.openapi.diagnostic.ControlFlowException
|
import com.intellij.openapi.diagnostic.ControlFlowException
|
||||||
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
import com.intellij.openapi.diagnostic.logger
|
import com.intellij.openapi.diagnostic.logger
|
||||||
import com.intellij.openapi.extensions.*
|
import com.intellij.openapi.extensions.*
|
||||||
import com.intellij.openapi.extensions.impl.ExtensionPointImpl
|
import com.intellij.openapi.extensions.impl.ExtensionPointImpl
|
||||||
@@ -40,7 +41,6 @@ import kotlinx.coroutines.*
|
|||||||
import org.jetbrains.annotations.ApiStatus.Internal
|
import org.jetbrains.annotations.ApiStatus.Internal
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.picocontainer.ComponentAdapter
|
import org.picocontainer.ComponentAdapter
|
||||||
import org.picocontainer.PicoContainer
|
|
||||||
import java.lang.invoke.MethodHandle
|
import java.lang.invoke.MethodHandle
|
||||||
import java.lang.invoke.MethodHandles
|
import java.lang.invoke.MethodHandles
|
||||||
import java.lang.invoke.MethodType
|
import java.lang.invoke.MethodType
|
||||||
@@ -55,7 +55,9 @@ import java.util.concurrent.atomic.AtomicReference
|
|||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.coroutines.EmptyCoroutineContext
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
internal val LOG = logger<ComponentManagerImpl>()
|
internal val LOG: Logger
|
||||||
|
get() = logger<ComponentManagerImpl>()
|
||||||
|
|
||||||
private val constructorParameterResolver = ConstructorParameterResolver()
|
private val constructorParameterResolver = ConstructorParameterResolver()
|
||||||
private val methodLookup = MethodHandles.lookup()
|
private val methodLookup = MethodHandles.lookup()
|
||||||
private val emptyConstructorMethodType = MethodType.methodType(Void.TYPE)
|
private val emptyConstructorMethodType = MethodType.methodType(Void.TYPE)
|
||||||
@@ -148,9 +150,11 @@ abstract class ComponentManagerImpl(
|
|||||||
@Volatile
|
@Volatile
|
||||||
private var isServicePreloadingCancelled = false
|
private var isServicePreloadingCancelled = false
|
||||||
|
|
||||||
private fun debugString(short: Boolean = false): String = "${if (short) javaClass.simpleName else javaClass.name}@${System.identityHashCode(this)}"
|
private fun debugString(short: Boolean = false): String {
|
||||||
|
return "${if (short) javaClass.simpleName else javaClass.name}@${System.identityHashCode(this)}"
|
||||||
|
}
|
||||||
|
|
||||||
internal val serviceParentDisposable = Disposer.newDisposable("services of ${debugString()}")
|
internal val serviceParentDisposable: Disposable = Disposer.newDisposable("services of ${debugString()}")
|
||||||
|
|
||||||
protected open val isLightServiceSupported = parent?.parent == null
|
protected open val isLightServiceSupported = parent?.parent == null
|
||||||
protected open val isMessageBusSupported = parent?.parent == null
|
protected open val isMessageBusSupported = parent?.parent == null
|
||||||
@@ -191,16 +195,6 @@ abstract class ComponentManagerImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val picoContainerAdapter: PicoContainer = object : PicoContainer {
|
|
||||||
override fun getComponentInstance(componentKey: Any): Any? {
|
|
||||||
return this@ComponentManagerImpl.getComponentInstance(componentKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getComponentInstanceOfType(componentType: Class<*>): Any? {
|
|
||||||
throw UnsupportedOperationException("Do not use getComponentInstanceOfType()")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun getComponentInstance(componentKey: Any): Any? {
|
internal fun getComponentInstance(componentKey: Any): Any? {
|
||||||
assertComponentsSupported()
|
assertComponentsSupported()
|
||||||
|
|
||||||
@@ -209,12 +203,6 @@ abstract class ComponentManagerImpl(
|
|||||||
return if (adapter == null) parent?.getComponentInstance(componentKey) else adapter.componentInstance
|
return if (adapter == null) parent?.getComponentInstance(componentKey) else adapter.componentInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use ComponentManager API", level = DeprecationLevel.ERROR)
|
|
||||||
final override fun getPicoContainer(): PicoContainer {
|
|
||||||
checkState()
|
|
||||||
return picoContainerAdapter
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun registerAdapter(componentAdapter: ComponentAdapter, pluginDescriptor: PluginDescriptor?) {
|
private fun registerAdapter(componentAdapter: ComponentAdapter, pluginDescriptor: PluginDescriptor?) {
|
||||||
if (componentKeyToAdapter.putIfAbsent(componentAdapter.componentKey, componentAdapter) != null) {
|
if (componentKeyToAdapter.putIfAbsent(componentAdapter.componentKey, componentAdapter) != null) {
|
||||||
val error = "Key ${componentAdapter.componentKey} duplicated"
|
val error = "Key ${componentAdapter.componentKey} duplicated"
|
||||||
@@ -292,8 +280,8 @@ abstract class ComponentManagerImpl(
|
|||||||
|
|
||||||
var activity = activityNamePrefix?.let { StartUpMeasurer.startActivity("${it}service and ep registration") }
|
var activity = activityNamePrefix?.let { StartUpMeasurer.startActivity("${it}service and ep registration") }
|
||||||
|
|
||||||
// register services before registering extensions because plugins can access services in their
|
// register services before registering extensions because plugins can access services in their extensions,
|
||||||
// extensions which can be invoked right away if the plugin is loaded dynamically
|
// which can be invoked right away if the plugin is loaded dynamically
|
||||||
val extensionPoints = if (precomputedExtensionModel == null) HashMap(extensionArea.extensionPoints) else null
|
val extensionPoints = if (precomputedExtensionModel == null) HashMap(extensionArea.extensionPoints) else null
|
||||||
for (rootModule in modules) {
|
for (rootModule in modules) {
|
||||||
executeRegisterTask(rootModule) { module ->
|
executeRegisterTask(rootModule) { module ->
|
||||||
@@ -1488,7 +1476,7 @@ abstract class ComponentManagerImpl(
|
|||||||
* Key: plugin coroutine scope.
|
* Key: plugin coroutine scope.
|
||||||
* Value: intersection of this container scope and plugin coroutine scope.
|
* Value: intersection of this container scope and plugin coroutine scope.
|
||||||
*/
|
*/
|
||||||
private val pluginScopes: AtomicReference<PersistentMap<CoroutineScope, CoroutineScope>> = AtomicReference(persistentHashMapOf())
|
private val pluginScopes = AtomicReference<PersistentMap<CoroutineScope, CoroutineScope>>(persistentHashMapOf())
|
||||||
|
|
||||||
internal fun instanceCoroutineScope(pluginClass: Class<*>): CoroutineScope {
|
internal fun instanceCoroutineScope(pluginClass: Class<*>): CoroutineScope {
|
||||||
val pluginClassloader = pluginClass.classLoader
|
val pluginClassloader = pluginClass.classLoader
|
||||||
@@ -1498,10 +1486,11 @@ abstract class ComponentManagerImpl(
|
|||||||
?: pluginScope
|
?: pluginScope
|
||||||
intersectionCoroutineScope(parentScope)
|
intersectionCoroutineScope(parentScope)
|
||||||
}
|
}
|
||||||
else { // non-unloadable
|
else {
|
||||||
|
// non-unloadable
|
||||||
getCoroutineScope()
|
getCoroutineScope()
|
||||||
}
|
}
|
||||||
// The parent scope should become cancelled only when the container is disposed, or the plugin is unloaded.
|
// The parent scope should become canceled only when the container is disposed, or the plugin is unloaded.
|
||||||
// Leaking the parent scope might lead to premature cancellation.
|
// Leaking the parent scope might lead to premature cancellation.
|
||||||
// Fool proofing: a fresh child scope is created per instance to avoid leaking the parent to clients.
|
// Fool proofing: a fresh child scope is created per instance to avoid leaking the parent to clients.
|
||||||
return intersectionScope.namedChildScope(pluginClass.name)
|
return intersectionScope.namedChildScope(pluginClass.name)
|
||||||
@@ -1540,7 +1529,7 @@ abstract class ComponentManagerImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun removePluginScope(pluginScope: CoroutineScope) {
|
private fun removePluginScope(pluginScope: CoroutineScope) {
|
||||||
pluginScopes.updateAndGet { scopes: PersistentMap<CoroutineScope, CoroutineScope> ->
|
pluginScopes.updateAndGet { scopes ->
|
||||||
scopes.remove(pluginScope)
|
scopes.remove(pluginScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class MockModule extends MockComponentManager implements Module {
|
|||||||
this(null, parentDisposable);
|
this(null, parentDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockModule(@Nullable final Project project, @NotNull Disposable parentDisposable) {
|
public MockModule(@Nullable MockProject project, @NotNull Disposable parentDisposable) {
|
||||||
super(project == null ? null : project.getPicoContainer(), parentDisposable);
|
super(project == null ? null : project.getPicoContainer(), parentDisposable);
|
||||||
myProject = project;
|
myProject = project;
|
||||||
}
|
}
|
||||||
@@ -31,14 +31,12 @@ public class MockModule extends MockComponentManager implements Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
public @NotNull Path getModuleNioFile() {
|
||||||
public Path getModuleNioFile() {
|
|
||||||
return Paths.get("");
|
return Paths.get("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleRuntimeScope(final boolean includeTests) {
|
public @NotNull GlobalSearchScope getModuleRuntimeScope(final boolean includeTests) {
|
||||||
return new MockGlobalSearchScope();
|
return new MockGlobalSearchScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,65 +50,55 @@ public class MockModule extends MockComponentManager implements Module {
|
|||||||
throw new UnsupportedOperationException("Method getModuleTestSourceScope is not yet implemented in " + getClass().getName());
|
throw new UnsupportedOperationException("Method getModuleTestSourceScope is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleScope() {
|
public @NotNull GlobalSearchScope getModuleScope() {
|
||||||
return new MockGlobalSearchScope();
|
return new MockGlobalSearchScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleScope(boolean includeTests) {
|
public @NotNull GlobalSearchScope getModuleScope(boolean includeTests) {
|
||||||
return new MockGlobalSearchScope();
|
return new MockGlobalSearchScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleTestsWithDependentsScope() {
|
public @NotNull GlobalSearchScope getModuleTestsWithDependentsScope() {
|
||||||
return new MockGlobalSearchScope();
|
return new MockGlobalSearchScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleWithDependenciesAndLibrariesScope(final boolean includeTests) {
|
public @NotNull GlobalSearchScope getModuleWithDependenciesAndLibrariesScope(final boolean includeTests) {
|
||||||
return new MockGlobalSearchScope();
|
return new MockGlobalSearchScope();
|
||||||
|
|
||||||
//throw new UnsupportedOperationException( "Method getModuleWithDependenciesAndLibrariesScope is not yet implemented in " + getClass().getName());
|
//throw new UnsupportedOperationException( "Method getModuleWithDependenciesAndLibrariesScope is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleWithDependenciesScope() {
|
public @NotNull GlobalSearchScope getModuleWithDependenciesScope() {
|
||||||
return new MockGlobalSearchScope();
|
return new MockGlobalSearchScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleContentWithDependenciesScope() {
|
public @NotNull GlobalSearchScope getModuleContentWithDependenciesScope() {
|
||||||
throw new UnsupportedOperationException("Method getModuleContentWithDependenciesScope is not yet implemented in " + getClass().getName());
|
throw new UnsupportedOperationException("Method getModuleContentWithDependenciesScope is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleContentScope() {
|
public @NotNull GlobalSearchScope getModuleContentScope() {
|
||||||
throw new UnsupportedOperationException("Method getModuleContentScope is not yet implemented in " + getClass().getName());
|
throw new UnsupportedOperationException("Method getModuleContentScope is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleWithDependentsScope() {
|
public @NotNull GlobalSearchScope getModuleWithDependentsScope() {
|
||||||
throw new UnsupportedOperationException("Method getModuleWithDependentsScope is not yet implemented in " + getClass().getName());
|
throw new UnsupportedOperationException("Method getModuleWithDependentsScope is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalSearchScope getModuleWithLibrariesScope() {
|
public @NotNull GlobalSearchScope getModuleWithLibrariesScope() {
|
||||||
throw new UnsupportedOperationException("Method getModuleWithLibrariesScope is not yet implemented in " + getClass().getName());
|
throw new UnsupportedOperationException("Method getModuleWithLibrariesScope is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
public @NotNull String getName() {
|
||||||
public String getName() {
|
|
||||||
return myName;
|
return myName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,19 +113,17 @@ public class MockModule extends MockComponentManager implements Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable String getOptionValue(@NotNull String optionName) {
|
||||||
public String getOptionValue(@NotNull final String optionName) {
|
|
||||||
throw new UnsupportedOperationException("Method getOptionValue is not yet implemented in " + getClass().getName());
|
throw new UnsupportedOperationException("Method getOptionValue is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
public @NotNull Project getProject() {
|
||||||
public Project getProject() {
|
|
||||||
return myProject;
|
return myProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOption(@NotNull final String optionName, @NotNull final String optionValue) {
|
public void setOption(@NotNull String optionName, @Nullable String optionValue) {
|
||||||
throw new UnsupportedOperationException("Method setOption is not yet implemented in " + getClass().getName());
|
throw new UnsupportedOperationException("Method setOption is not yet implemented in " + getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package com.intellij.mock;
|
|||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.application.Application;
|
import com.intellij.openapi.application.Application;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.components.ComponentManagerEx;
|
|
||||||
import com.intellij.openapi.project.ex.ProjectEx;
|
import com.intellij.openapi.project.ex.ProjectEx;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -17,7 +16,7 @@ public class MockProjectEx extends MockProject implements ProjectEx {
|
|||||||
|
|
||||||
private static @Nullable PicoContainer getParentContainer() {
|
private static @Nullable PicoContainer getParentContainer() {
|
||||||
Application app = ApplicationManager.getApplication();
|
Application app = ApplicationManager.getApplication();
|
||||||
return app == null || app instanceof ComponentManagerEx ? null : app.getPicoContainer();
|
return app instanceof MockApplication ? ((MockApplication)app).getPicoContainer() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ import java.util.*;
|
|||||||
|
|
||||||
/** @noinspection JUnitTestCaseWithNonTrivialConstructors*/
|
/** @noinspection JUnitTestCaseWithNonTrivialConstructors*/
|
||||||
public abstract class ParsingTestCase extends UsefulTestCase {
|
public abstract class ParsingTestCase extends UsefulTestCase {
|
||||||
private PluginDescriptor myPluginDescriptor;
|
private PluginDescriptor pluginDescriptor;
|
||||||
|
|
||||||
private MockApplication myApp;
|
private MockApplication app;
|
||||||
protected MockProjectEx myProject;
|
protected MockProjectEx project;
|
||||||
|
|
||||||
protected String myFilePrefix = "";
|
protected String myFilePrefix = "";
|
||||||
protected String myFileExt;
|
protected String myFileExt;
|
||||||
@@ -91,7 +91,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected MockApplication getApplication() {
|
protected MockApplication getApplication() {
|
||||||
return myApp;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,7 +99,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
MockApplication app = MockApplication.setUp(getTestRootDisposable());
|
MockApplication app = MockApplication.setUp(getTestRootDisposable());
|
||||||
myApp = app;
|
this.app = app;
|
||||||
MutablePicoContainer appContainer = app.getPicoContainer();
|
MutablePicoContainer appContainer = app.getPicoContainer();
|
||||||
ComponentAdapter component = appContainer.getComponentAdapter(ProgressManager.class.getName());
|
ComponentAdapter component = appContainer.getComponentAdapter(ProgressManager.class.getName());
|
||||||
if (component == null) {
|
if (component == null) {
|
||||||
@@ -107,8 +107,8 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool(true);
|
IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool(true);
|
||||||
|
|
||||||
myProject = new MockProjectEx(getTestRootDisposable());
|
project = new MockProjectEx(getTestRootDisposable());
|
||||||
myPsiManager = new MockPsiManager(myProject);
|
myPsiManager = new MockPsiManager(project);
|
||||||
myFileFactory = new PsiFileFactoryImpl(myPsiManager);
|
myFileFactory = new PsiFileFactoryImpl(myPsiManager);
|
||||||
appContainer.registerComponentInstance(MessageBus.class, app.getMessageBus());
|
appContainer.registerComponentInstance(MessageBus.class, app.getMessageBus());
|
||||||
appContainer.registerComponentInstance(SchemeManagerFactory.class, new MockSchemeManagerFactory());
|
appContainer.registerComponentInstance(SchemeManagerFactory.class, new MockSchemeManagerFactory());
|
||||||
@@ -121,11 +121,11 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
app.registerService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
|
app.registerService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
|
||||||
app.registerService(DefaultASTFactory.class, new DefaultASTFactoryImpl());
|
app.registerService(DefaultASTFactory.class, new DefaultASTFactoryImpl());
|
||||||
app.registerService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
|
app.registerService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
|
||||||
myProject.registerService(PsiDocumentManager.class, new MockPsiDocumentManager());
|
project.registerService(PsiDocumentManager.class, new MockPsiDocumentManager());
|
||||||
myProject.registerService(PsiManager.class, myPsiManager);
|
project.registerService(PsiManager.class, myPsiManager);
|
||||||
myProject.registerService(TreeAspect.class, new TreeAspect());
|
project.registerService(TreeAspect.class, new TreeAspect());
|
||||||
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myProject)));
|
project.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(project, new PsiCachedValuesFactory(project)));
|
||||||
myProject.registerService(StartupManager.class, new StartupManagerImpl(myProject, myProject.getCoroutineScope()));
|
project.registerService(StartupManager.class, new StartupManagerImpl(project, project.getCoroutineScope()));
|
||||||
registerExtensionPoint(app.getExtensionArea(), FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class);
|
registerExtensionPoint(app.getExtensionArea(), FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class);
|
||||||
registerExtensionPoint(app.getExtensionArea(), MetaLanguage.EP_NAME, MetaLanguage.class);
|
registerExtensionPoint(app.getExtensionArea(), MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// That's for reparse routines
|
// That's for reparse routines
|
||||||
myProject.registerService(PomModel.class, new PomModelImpl(myProject));
|
project.registerService(PomModel.class, new PomModelImpl(project));
|
||||||
Registry.markAsLoaded();
|
Registry.markAsLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
myLanguage = definition.getFileNodeType().getLanguage();
|
myLanguage = definition.getFileNodeType().getLanguage();
|
||||||
myFileExt = extension;
|
myFileExt = extension;
|
||||||
registerParserDefinition(definition);
|
registerParserDefinition(definition);
|
||||||
myApp.registerService(FileTypeManager.class, new MockFileTypeManager(new MockLanguageFileType(myLanguage, myFileExt)));
|
app.registerService(FileTypeManager.class, new MockFileTypeManager(new MockLanguageFileType(myLanguage, myFileExt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final <T> void registerExtension(@NotNull ExtensionPointName<T> name, @NotNull T extension) {
|
protected final <T> void registerExtension(@NotNull ExtensionPointName<T> name, @NotNull T extension) {
|
||||||
@@ -175,7 +175,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final <T> void registerExtensions(@NotNull ExtensionPointName<T> name, @NotNull Class<T> extensionClass, @NotNull List<? extends T> extensions) {
|
protected final <T> void registerExtensions(@NotNull ExtensionPointName<T> name, @NotNull Class<T> extensionClass, @NotNull List<? extends T> extensions) {
|
||||||
ExtensionsAreaImpl area = myApp.getExtensionArea();
|
ExtensionsAreaImpl area = app.getExtensionArea();
|
||||||
ExtensionPoint<T> point = area.getExtensionPointIfRegistered(name.getName());
|
ExtensionPoint<T> point = area.getExtensionPointIfRegistered(name.getName());
|
||||||
if (point == null) {
|
if (point == null) {
|
||||||
point = registerExtensionPoint(area, name, extensionClass);
|
point = registerExtensionPoint(area, name, extensionClass);
|
||||||
@@ -189,7 +189,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final <T> void addExplicitExtension(@NotNull LanguageExtension<T> collector, @NotNull Language language, @NotNull T object) {
|
protected final <T> void addExplicitExtension(@NotNull LanguageExtension<T> collector, @NotNull Language language, @NotNull T object) {
|
||||||
ExtensionsAreaImpl area = myApp.getExtensionArea();
|
ExtensionsAreaImpl area = app.getExtensionArea();
|
||||||
PluginDescriptor pluginDescriptor = getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = getPluginDescriptor();
|
||||||
if (!area.hasExtensionPoint(collector.getName())) {
|
if (!area.hasExtensionPoint(collector.getName())) {
|
||||||
area.registerFakeBeanPoint(collector.getName(), pluginDescriptor);
|
area.registerFakeBeanPoint(collector.getName(), pluginDescriptor);
|
||||||
@@ -200,7 +200,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final <T> void registerExtensionPoint(@NotNull ExtensionPointName<T> extensionPointName, @NotNull Class<T> aClass) {
|
protected final <T> void registerExtensionPoint(@NotNull ExtensionPointName<T> extensionPointName, @NotNull Class<T> aClass) {
|
||||||
registerExtensionPoint(myApp.getExtensionArea(), extensionPointName, aClass);
|
registerExtensionPoint(app.getExtensionArea(), extensionPointName, aClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> ExtensionPointImpl<T> registerExtensionPoint(@NotNull ExtensionsAreaImpl extensionArea,
|
protected <T> ExtensionPointImpl<T> registerExtensionPoint(@NotNull ExtensionsAreaImpl extensionArea,
|
||||||
@@ -219,17 +219,17 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
@NotNull
|
@NotNull
|
||||||
// easy debug of not disposed extension
|
// easy debug of not disposed extension
|
||||||
private PluginDescriptor getPluginDescriptor() {
|
private PluginDescriptor getPluginDescriptor() {
|
||||||
PluginDescriptor pluginDescriptor = myPluginDescriptor;
|
PluginDescriptor pluginDescriptor = this.pluginDescriptor;
|
||||||
if (pluginDescriptor == null) {
|
if (pluginDescriptor == null) {
|
||||||
pluginDescriptor = new DefaultPluginDescriptor(PluginId.getId(getClass().getName() + "." + getName()), ParsingTestCase.class.getClassLoader());
|
pluginDescriptor = new DefaultPluginDescriptor(PluginId.getId(getClass().getName() + "." + getName()), ParsingTestCase.class.getClassLoader());
|
||||||
myPluginDescriptor = pluginDescriptor;
|
this.pluginDescriptor = pluginDescriptor;
|
||||||
}
|
}
|
||||||
return pluginDescriptor;
|
return pluginDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public MockProjectEx getProject() {
|
public MockProjectEx getProject() {
|
||||||
return myProject;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockPsiManager getPsiManager() {
|
public MockPsiManager getPsiManager() {
|
||||||
@@ -239,7 +239,7 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
myFile = null;
|
myFile = null;
|
||||||
myProject = null;
|
project = null;
|
||||||
myPsiManager = null;
|
myPsiManager = null;
|
||||||
myFileFactory = null;
|
myFileFactory = null;
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
@@ -519,11 +519,11 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerMockInjectedLanguageManager() {
|
public void registerMockInjectedLanguageManager() {
|
||||||
registerExtensionPoint(myProject.getExtensionArea(), MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME, MultiHostInjector.class);
|
registerExtensionPoint(project.getExtensionArea(), MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME, MultiHostInjector.class);
|
||||||
|
|
||||||
registerExtensionPoint(myApp.getExtensionArea(), LanguageInjector.EXTENSION_POINT_NAME, LanguageInjector.class);
|
registerExtensionPoint(app.getExtensionArea(), LanguageInjector.EXTENSION_POINT_NAME, LanguageInjector.class);
|
||||||
myProject.registerService(DumbService.class, new MockDumbService(myProject));
|
project.registerService(DumbService.class, new MockDumbService(project));
|
||||||
getApplication().registerService(EditorWindowTracker.class, new EditorWindowTrackerImpl());
|
getApplication().registerService(EditorWindowTracker.class, new EditorWindowTrackerImpl());
|
||||||
myProject.registerService(InjectedLanguageManager.class, new InjectedLanguageManagerImpl(myProject));
|
project.registerService(InjectedLanguageManager.class, new InjectedLanguageManagerImpl(project));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.test.testFramework
|
package org.jetbrains.kotlin.idea.test.testFramework
|
||||||
|
|
||||||
|
import com.intellij.mock.MockApplication
|
||||||
import com.intellij.mock.MockProject
|
import com.intellij.mock.MockProject
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
@@ -13,7 +14,7 @@ interface ProjectEx : Project {
|
|||||||
fun setProjectName(name: String)
|
fun setProjectName(name: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockProjectEx(parentDisposable: Disposable) : MockProject(if (ApplicationManager.getApplication() != null) ApplicationManager.getApplication().picoContainer else null, parentDisposable), ProjectEx {
|
class MockProjectEx(parentDisposable: Disposable) : MockProject(if (ApplicationManager.getApplication() is MockApplication) (ApplicationManager.getApplication() as MockApplication).picoContainer else null, parentDisposable), ProjectEx {
|
||||||
override fun setProjectName(name: String) {
|
override fun setProjectName(name: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user