Search in sources :

Example 26 with MutablePicoContainer

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());
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) DefaultPicoContainer(org.picocontainer.defaults.DefaultPicoContainer) List(java.util.List) Test(org.junit.Test)

Example 27 with MutablePicoContainer

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);
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) MockFileDocumentManagerImpl(com.intellij.mock.MockFileDocumentManagerImpl) TreeAspect(com.intellij.pom.tree.TreeAspect) CachedValuesManagerImpl(com.intellij.util.CachedValuesManagerImpl) CoreASTFactory(com.intellij.core.CoreASTFactory) PsiBuilderFactoryImpl(com.intellij.lang.impl.PsiBuilderFactoryImpl) Function(com.intellij.util.Function) PsiCachedValuesFactory(com.intellij.psi.impl.PsiCachedValuesFactory) ProgressManager(com.intellij.openapi.progress.ProgressManager) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) ReferenceProvidersRegistryImpl(com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl) PsiFileFactoryImpl(com.intellij.psi.impl.PsiFileFactoryImpl) PomModelImpl(com.intellij.pom.core.impl.PomModelImpl) ComponentAdapter(org.picocontainer.ComponentAdapter)

Example 28 with MutablePicoContainer

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);
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) AppEngineAssetProvider(com.google.cloud.tools.intellij.appengine.project.AppEngineAssetProvider)

Example 29 with MutablePicoContainer

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);
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) CloudSdkInternals(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkInternals) CloudSdkService(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService)

Example 30 with MutablePicoContainer

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;
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer)

Aggregations

MutablePicoContainer (org.picocontainer.MutablePicoContainer)35 Test (org.junit.Test)6 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)3 NotNull (org.jetbrains.annotations.NotNull)3 CloudSdkInternals (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkInternals)2 CloudSdkService (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService)2 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 TemplateDataLanguageMappings (com.intellij.psi.templateLanguages.TemplateDataLanguageMappings)2 TemplateDataLanguagePatterns (com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns)2 CandidateSteps (org.jbehave.core.steps.CandidateSteps)2 Before (org.junit.Before)2 DefaultPicoContainer (org.picocontainer.defaults.DefaultPicoContainer)2 PropertiesComponentStub (com.dmarcotte.handlebars.config.PropertiesComponentStub)1 AppEngineStandardMavenLibrary (com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardMavenLibrary)1 AppEngineSupportConfigurable (com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardSupportProvider.AppEngineSupportConfigurable)1 MavenRepositoryLibraryDownloader (com.google.cloud.tools.intellij.appengine.facet.standard.MavenRepositoryLibraryDownloader)1 AppEngineAssetProvider (com.google.cloud.tools.intellij.appengine.project.AppEngineAssetProvider)1 CloudSdkServiceManager (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkServiceManager)1 WorkspacePathResolverProvider (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverProvider)1 CoreASTFactory (com.intellij.core.CoreASTFactory)1