use of org.picocontainer.MutablePicoContainer in project intellij-community by JetBrains.
the class ExtensionsAreaTest method testGetComponentAdapterDoesntDuplicateAdapters.
@Test
public void testGetComponentAdapterDoesntDuplicateAdapters() throws Exception {
MutablePicoContainer picoContainer = new ExtensionsAreaImpl("foo", null, new DefaultPicoContainer(), new Extensions.SimpleLogProvider()).getPicoContainer();
picoContainer.registerComponentImplementation("runnable", ExtensionsAreaTest.class);
List adapters = picoContainer.getComponentAdaptersOfType(ExtensionsAreaTest.class);
assertEquals(1, adapters.size());
}
use of org.picocontainer.MutablePicoContainer in project kotlin by JetBrains.
the class KtParsingTestCase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
initApplication();
ComponentAdapter component = getApplication().getPicoContainer().getComponentAdapter(ProgressManager.class.getName());
Extensions.registerAreaClass("IDEA_PROJECT", null);
myProject = new MockProjectEx(getTestRootDisposable());
myPsiManager = new MockPsiManager(myProject);
myFileFactory = new PsiFileFactoryImpl(myPsiManager);
MutablePicoContainer appContainer = getApplication().getPicoContainer();
registerComponentInstance(appContainer, MessageBus.class, MessageBusFactory.newMessageBus(getApplication()));
registerComponentInstance(appContainer, SchemesManagerFactory.class, new MockSchemesManagerFactory());
final MockEditorFactory editorFactory = new MockEditorFactory();
registerComponentInstance(appContainer, EditorFactory.class, editorFactory);
registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function<CharSequence, Document>() {
@Override
public Document fun(CharSequence charSequence) {
return editorFactory.createDocument(charSequence);
}
}, HARD_REF_TO_DOCUMENT_KEY));
registerComponentInstance(appContainer, PsiDocumentManager.class, new MockPsiDocumentManager());
registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
registerApplicationService(DefaultASTFactory.class, new CoreASTFactory());
registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
registerApplicationService(ProgressManager.class, new CoreProgressManager());
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
myProject.registerService(PsiManager.class, myPsiManager);
this.registerExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class);
for (ParserDefinition definition : myDefinitions) {
addExplicitExtension(LanguageParserDefinitions.INSTANCE, definition.getFileNodeType().getLanguage(), definition);
}
if (myDefinitions.length > 0) {
configureFromParserDefinition(myDefinitions[0], myFileExt);
}
// That's for reparse routines
final PomModelImpl pomModel = new PomModelImpl(myProject);
myProject.registerService(PomModel.class, pomModel);
new TreeAspect(pomModel);
}
use of org.picocontainer.MutablePicoContainer in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineServerConfigurationTypeTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
MutablePicoContainer applicationContainer = (MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer();
assetProvider = mock(AppEngineAssetProvider.class);
applicationContainer.unregisterComponent(AppEngineAssetProvider.class.getName());
applicationContainer.registerComponentInstance(AppEngineAssetProvider.class.getName(), assetProvider);
}
use of org.picocontainer.MutablePicoContainer in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineCodeInsightTestCase method addAppEngineSupport.
private void addAppEngineSupport(Module module) {
CloudSdkService sdkService = mock(CloudSdkService.class);
CloudSdkInternals mockSdkInternals = mock(CloudSdkInternals.class);
when(mockSdkInternals.getWebSchemeFile()).thenReturn(getWebSchemeFile());
CloudSdkInternals.setInstance(mockSdkInternals);
MutablePicoContainer applicationContainer = (MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer();
applicationContainer.unregisterComponent(CloudSdkService.class.getName());
applicationContainer.registerComponentInstance(CloudSdkService.class.getName(), sdkService);
FacetManager.getInstance(module).addFacet(AppEngineStandardFacet.getFacetType(), "AppEngine", null);
}
use of org.picocontainer.MutablePicoContainer in project google-cloud-intellij by GoogleCloudPlatform.
the class PicoContainerTestUtil method setService.
/**
* Replaces the service binding in the {@link MutablePicoContainer} with the given instance and
* returns the original service instance.
*
* @param clazz the class of the registered service
* @param newInstance the new instance to register
*/
private static Object setService(Class<?> clazz, Object newInstance) {
MutablePicoContainer applicationContainer = (MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer();
Object originalInstance = applicationContainer.getComponentInstanceOfType(clazz);
applicationContainer.unregisterComponent(clazz.getName());
applicationContainer.registerComponentInstance(clazz.getName(), newInstance);
return originalInstance;
}
Aggregations