Search in sources :

Example 1 with SharedStateContributionRegistryImpl

use of org.eclipse.xtext.ui.shared.internal.SharedStateContributionRegistryImpl in project xtext-eclipse by eclipse.

the class SharedStateContributionRegistryImplTest method testCreateContributingInjector.

@Test
public void testCreateContributingInjector() {
    SharedStateContributionRegistryImpl registry = new SharedStateContributionRegistryImpl(injector);
    Injector myInjector = registry.createInjectorWithoutJITBindings(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(CharSequenceClient.class).to(CharSequenceClientImpl.class);
        }
    });
    Assert.assertEquals("fromParentInjector", myInjector.getInstance(CharSequenceClient.class).getSeq());
    Assert.assertNotNull(myInjector.getExistingBinding(Key.get(CharSequenceClientImpl.class)));
    Assert.assertNotNull(myInjector.getExistingBinding(Key.get(CharSequenceClient.class)));
    Assert.assertNotNull(myInjector.getExistingBinding(Key.get(CharSequence.class)));
    Assert.assertNotNull(myInjector.getExistingBinding(Key.get(String.class)));
    Assert.assertNull(injector.getExistingBinding(Key.get(CharSequenceClientImpl.class)));
    Assert.assertNull(injector.getExistingBinding(Key.get(CharSequenceClient.class)));
    Assert.assertNotNull(injector.getExistingBinding(Key.get(CharSequence.class)));
    Assert.assertNotNull(injector.getExistingBinding(Key.get(String.class)));
}
Also used : Binder(com.google.inject.Binder) SharedStateContributionRegistryImpl(org.eclipse.xtext.ui.shared.internal.SharedStateContributionRegistryImpl) Injector(com.google.inject.Injector) Module(com.google.inject.Module) Test(org.junit.Test)

Example 2 with SharedStateContributionRegistryImpl

use of org.eclipse.xtext.ui.shared.internal.SharedStateContributionRegistryImpl in project xtext-eclipse by eclipse.

the class SharedStateContributionRegistryImplTest method testCreateContribution.

@Test
public void testCreateContribution() {
    SharedStateContributionRegistryImpl registry = new SharedStateContributionRegistryImpl(injector);
    SharedStateContribution contribution = registry.createContribution(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(CharSequenceClient.class).to(CharSequenceClientImpl.class);
        }
    });
    Assert.assertTrue(contribution.isContributionSupported(CharSequenceClient.class));
    Assert.assertFalse(contribution.isContributionSupported(IXtextDocument.class));
    Assert.assertEquals("fromParentInjector", contribution.getContribution(CharSequenceClient.class).getSeq());
}
Also used : Binder(com.google.inject.Binder) SharedStateContributionRegistryImpl(org.eclipse.xtext.ui.shared.internal.SharedStateContributionRegistryImpl) Module(com.google.inject.Module) SharedStateContribution(org.eclipse.xtext.ui.shared.contribution.SharedStateContribution) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Test(org.junit.Test)

Aggregations

Binder (com.google.inject.Binder)2 Module (com.google.inject.Module)2 SharedStateContributionRegistryImpl (org.eclipse.xtext.ui.shared.internal.SharedStateContributionRegistryImpl)2 Test (org.junit.Test)2 Injector (com.google.inject.Injector)1 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)1 SharedStateContribution (org.eclipse.xtext.ui.shared.contribution.SharedStateContribution)1