org.eclipse.xtext.ISetup Java Examples

The following examples show how to use org.eclipse.xtext.ISetup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentAssistCustomizingTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public ISetup doGetSetup() {
	return new ContentAssistCustomizingTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(
					new ContentAssistCustomizingTestLanguageRuntimeModule(),
					new ContentAssistCustomizingTestLanguageUiModule(TestsActivator.getInstance()) {
						@Override
						public Class<? extends IContentProposalProvider> bindIContentProposalProvider() {
							return TestableProposalProvider.class;
						}
						@SuppressWarnings("unused")
						public ContentAssistCustomizingTest bindTestClass() {
							return ContentAssistCustomizingTest.this;
						}
						@Override
						public Class<? extends ITemplateProposalProvider> bindITemplateProposalProvider() {
							return TestableTemplateProposalProvider.class;
						}
					}, new SharedStateModule()));
		}
	};
}
 
Example #2
Source File: LazyLinkingResourceTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected ISetup lazyLinkingTestLangaugeSetup() {
	return new LazyLinkingTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(new org.eclipse.xtext.linking.lazy.LazyLinkingTestLanguageRuntimeModule() {
				@Override
				public void configureIResourceDescriptions(Binder binder) {
					binder.bind(org.eclipse.xtext.resource.IResourceDescriptions.class).to(
							ProxyfyingResourceDecriptions.class);
				}

				@Override
				public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
					return org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.class;
				}
			});
		}
	};
}
 
Example #3
Source File: ResourceServiceProviderServiceLoader.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private Registry loadRegistry() {
	ResourceServiceProviderRegistryImpl registry = new ResourceServiceProviderRegistryImpl();
	for (ISetup cp : setupLoader) {
		Injector injector = cp.createInjectorAndDoEMFRegistration();
		IResourceServiceProvider resourceServiceProvider = injector.getInstance(IResourceServiceProvider.class);
		FileExtensionProvider extensionProvider = injector.getInstance(FileExtensionProvider.class);
		String primaryFileExtension = extensionProvider.getPrimaryFileExtension();
		for (String ext : extensionProvider.getFileExtensions()) {
			if (registry.getExtensionToFactoryMap().containsKey(ext)) {
				if (primaryFileExtension.equals(ext))
					registry.getExtensionToFactoryMap().put(ext, resourceServiceProvider);
			} else {
				registry.getExtensionToFactoryMap().put(ext, resourceServiceProvider);
			}
		}
	}
	return registry;
}
 
Example #4
Source File: AbstractContentAssistProcessorTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected ISetup getSetup() {
	if (!useStaticInjector) {
		return doGetSetup();
	}
	return new ISetup() {
		@Override
		public Injector createInjectorAndDoEMFRegistration() {
			if (staticSetup == null) {
				staticSetup = new SetupExtension(doGetSetup());
				staticInjector = staticSetup.createInjectorAndDoEMFRegistration();
				return staticInjector;
			}
			staticSetup.register(staticInjector);
			return staticInjector;
		}
	};
}
 
Example #5
Source File: ContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public ISetup doGetSetup() {
	return new ContentAssistTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(
					new ContentAssistTestLanguageRuntimeModule(),
					new ContentAssistTestLanguageUiModule(TestsActivator.getInstance()) {
						@Override
						public Class<? extends IJavaProjectProvider> bindIJavaProjectProvider() {
							return MockJavaProjectProvider.class;
						}
					}, 
					new SharedStateModule()));
		}
	};
}
 
Example #6
Source File: AbstractBug326948Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public ISetup doGetSetup() {
	return new BeeLangTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(
					Modules2.mixin(
							new BeeLangTestLanguageRuntimeModule(), 
							new BeeLangTestLanguageUiModule(TestsActivator.getInstance()) {
								@Override
								public Class<? extends IContentProposalProvider> bindIContentProposalProvider() {
									return ProposalProvider.class;
								}
								
								@SuppressWarnings("unused")
								public AbstractBug326948Test bindTest() {
									return AbstractBug326948Test.this;
								}
							},
							new SharedStateModule()));
		}
	};
}
 
Example #7
Source File: TwoContextsContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @return
 */
private ISetup getGrammarSetup() {
	return new TwoContextsTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(
					new TwoContextsTestLanguageRuntimeModule(),
					new TwoContextsTestLanguageUiModule(TestsActivator.getInstance()){
				@Override
				public Class<? extends IContentProposalProvider> bindIContentProposalProvider() {
					return TwoContextsTestLanguageTestProposals.class;
				}
			},
			new SharedStateModule()));
		}
	};
}
 
Example #8
Source File: Bug297909Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public ISetup doGetSetup() {
	return new ContentAssistTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(new ContentAssistTestLanguageRuntimeModule(), new ContentAssistTestLanguageUiModule(TestsActivator
					.getInstance()), new SharedStateModule()));
		}
		
		@Override
		public void register(Injector injector) {
			super.register(injector);
			// simulate a EPackage that was not registered
			EPackage.Registry.INSTANCE.remove("http://www.eclipse.org/2008/xtext/ui/common/tests/ContentAssist");
			Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove("contentassisttestlanguage");
		}
	};
}
 
Example #9
Source File: CurrentModelBugTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private ISetup getSetup() {
	return new DomainModelTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(new DomainModelTestLanguageRuntimeModule(), new DomainModelTestLanguageUiModule(TestsActivator.getInstance()){

				@Override
				public Class<? extends IContentProposalProvider> bindIContentProposalProvider() {
					return MockedProposals.class;
				}
				
				@SuppressWarnings("unused")
				public CurrentModelBugTest bindCurrentModelBugTest() {
					return CurrentModelBugTest.this;
				}
			}, new SharedStateModule()));
		}
	};
}
 
Example #10
Source File: OutlineFilterAndSorterTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	final Injector injector = TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.outline.OutlineTestLanguage");
	with(new ISetup() {
		@Override
		public Injector createInjectorAndDoEMFRegistration() {
			return injector;
		}
	});
	Model model = OutlineTestFactory.eINSTANCE.createModel();
	nodes = Lists.newArrayList();
	nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "one", true));
	nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "two", true));
	nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "three", true));
	filterAndSorter = new OutlineFilterAndSorter();
}
 
Example #11
Source File: OutlineNodeComparerTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	final Injector injector = TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.outline.OutlineTestLanguage");
	with(new ISetup() {
		@Override
		public Injector createInjectorAndDoEMFRegistration() {
			return injector;
		}
	});
	comparer = new IOutlineNodeComparer.Default();
	image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
	image2 = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
	eObject = OutlineTestFactory.eINSTANCE.createModel();

}
 
Example #12
Source File: OutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	final Injector injector = TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.outline.OutlineTestLanguage");
	with(new ISetup() {
		@Override
		public Injector createInjectorAndDoEMFRegistration() {
			return injector;
		}
	});
	treeProvider = new DefaultOutlineTreeProvider(new DefaultEObjectLabelProvider(),
			new DefaultLocationInFileProvider());
}
 
Example #13
Source File: OutlineNodeTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	final Injector injector = TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.outline.OutlineTestLanguage");
	with(new ISetup() {
		@Override
		public Injector createInjectorAndDoEMFRegistration() {
			return injector;
		}
	});
	resource = getResource("parent { child0 {} }", "test.outlinetestlanguage");
	parentElement = ((Model) resource.getContents().get(0)).getElements().get(0);
	child0Element = parentElement.getChildren().get(0);
}
 
Example #14
Source File: DefaultEObjectHoverProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public ISetup getTestLanguageSetup(final IEObjectDocumentationProvider ieObjectDocumentationProvider) {
	return new KeywordsUiTestLanguageStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(
					new TestLanguageRuntimeModule(),
					new TestModule(TestsActivator.getInstance(),ieObjectDocumentationProvider),
					new SharedStateModule()));
		}
	};
}
 
Example #15
Source File: XtextContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public ISetup doGetSetup() {
	return new XtextStandaloneSetup() {
		@Override
		public Injector createInjector() {
			return Guice.createInjector(Modules2.mixin(new XtextRuntimeModule(),new XtextUIModuleInternal(Activator.getDefault()) {
				@Override
				public void configureContentProposalLabelProvider(com.google.inject.Binder binder) {
					binder.bind(ILabelProvider.class).annotatedWith(ContentProposalLabelProvider.class).to(DefaultEObjectLabelProvider.class);
				}
			}, new SharedStateModule()));
		}
	};
}
 
Example #16
Source File: AbstractXtextTests.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public void with(ISetup setup) throws Exception {
	assertTrue("super.setUp() has to be called before any injector is instantiated", canCreateInjector);
	setInjector(setup.createInjectorAndDoEMFRegistration());
}
 
Example #17
Source File: CachedSetup.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @return the delegate
 */
public ISetup getDelegate() {
	return delegate;
}
 
Example #18
Source File: AbstractXtextTests.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void with(ISetup setup) throws Exception {
	assertTrue("super.setUp() has to be called before any injector is instantiated", canCreateInjector);
	setInjector(setup.createInjectorAndDoEMFRegistration());
}
 
Example #19
Source File: AbstractXtextTests.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected void with(Class<? extends ISetup> setupClazz) throws Exception {
	assertTrue("super.setUp() has to be called before any injector is instantiated", canCreateInjector);
	ISetup instance = setupClazz.getDeclaredConstructor().newInstance();
	setInjector(instance.createInjectorAndDoEMFRegistration());
}
 
Example #20
Source File: AbstractReader.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Register a language setup. Only the first registered setup is used to inject the resource set.
 */
public void addRegister(ISetup setup) {
	injectors.add(setup.createInjectorAndDoEMFRegistration());
}
 
Example #21
Source File: CachedSetup.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param delegate the delegate to set
 */
@Mandatory
public void setDelegate(ISetup delegate) {
	this.delegate = delegate;
}
 
Example #22
Source File: AbstractXtextTests.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void with(ISetup setup) throws Exception {
	assertTrue("super.setUp() has to be called before any injector is instantiated", canCreateInjector);
	setInjector(setup.createInjectorAndDoEMFRegistration());
}
 
Example #23
Source File: AbstractXtextTests.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void with(Class<? extends ISetup> setupClazz) throws Exception {
	assertTrue("super.setUp() has to be called before any injector is instantiated", canCreateInjector);
	ISetup instance = setupClazz.getDeclaredConstructor().newInstance();
	setInjector(instance.createInjectorAndDoEMFRegistration());
}
 
Example #24
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public ContentAssistProcessorTestBuilder(ISetup setupClazz, AbstractXtextTests tests) throws Exception {
	tests.with(setupClazz);
	injector = tests.getInjector();
	this.injector.injectMembers(this);
	this.loadHelper = tests;
}
 
Example #25
Source File: AbstractXtextTests.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected void with(Class<? extends ISetup> setupClazz) throws Exception {
	assertTrue("super.setUp() has to be called before any injector is instantiated", canCreateInjector);
	ISetup instance = setupClazz.getDeclaredConstructor().newInstance();
	setInjector(instance.createInjectorAndDoEMFRegistration());
}
 
Example #26
Source File: AbstractContentAssistProcessorTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected ContentAssistProcessorTestBuilder newBuilder(ISetup setup) throws Exception {
	return new ContentAssistProcessorTestBuilder(setup, this);
}
 
Example #27
Source File: AbstractContentAssistProcessorTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public SetupExtension(ISetup plainSetup) {
	this.plainSetup = plainSetup;
}
 
Example #28
Source File: ContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected ISetup getSetup() {
	return doGetSetup();
}
 
Example #29
Source File: XtextContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected ISetup getSetup() {
	return doGetSetup();
}
 
Example #30
Source File: XcoreReader.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Registers a language initializer.
 */
public void addRegister(ISetup setup) {
	injectors.add(setup.createInjectorAndDoEMFRegistration());
}