use of org.eclipse.xtext.XtextStandaloneSetup in project xtext-core by eclipse.
the class MultiGenMMTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(new XtextStandaloneSetup());
with(new MultiGenMMTestLanguageStandaloneSetup());
}
use of org.eclipse.xtext.XtextStandaloneSetup in project xtext-core by eclipse.
the class UriBasedReaderTest method testIssuesInOtherResource.
@Test
public void testIssuesInOtherResource() throws Exception {
UriBasedReader reader = new UriBasedReader() {
{
getValidator().setStopOnError(false);
}
};
reader.setClasspathURIContext(getClass());
reader.addRegister(new XtextStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(new org.eclipse.xtext.XtextRuntimeModule() {
@Override
public void configureFileExtensions(Binder binder) {
binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("xtexterror");
}
});
}
@Override
public void register(Injector injector) {
EPackage.Registry.INSTANCE.put(XtextPackage.eINSTANCE.getNsURI(), XtextPackage.eINSTANCE);
IResourceFactory resourceFactory = injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xtexterror", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("xtexterror", serviceProvider);
}
});
final String errorURI = (getClass().getName() + "ResourceWithError").replace('.', '/') + ".xtexterror";
final String loadingURI = "classpath:/" + (getClass().getName() + "LoadingResourceWithError").replace('.', '/') + ".xtexterror";
reader.addUri(loadingURI);
SlotEntry slotEntry = new SlotEntry();
slotEntry.setType("Grammar");
slotEntry.setFirstOnly(true);
reader.addLoad(slotEntry);
WorkflowContextDefaultImpl ctx = new WorkflowContextDefaultImpl();
IssuesImpl issues = new IssuesImpl();
reader.checkConfiguration(issues);
assertFalse(issues.toString(), issues.hasErrors());
reader.invoke(ctx, new NullProgressMonitor(), issues);
assertTrue(ctx.get(slotEntry.getSlot()) instanceof Grammar);
assertEquals(1, issues.getErrors().length);
final String errorString = issues.getErrors()[0].toString();
assertFalse(errorString, errorString.contains(loadingURI));
assertTrue(errorString, errorString.contains(errorURI));
}
use of org.eclipse.xtext.XtextStandaloneSetup in project xtext-core by eclipse.
the class UriBasedReaderTest method testMissingUri.
@Test
public void testMissingUri() throws Exception {
UriBasedReader reader = new UriBasedReader();
reader.setClasspathURIContext(getClass());
reader.addRegister(new XtextStandaloneSetup());
// reader.setUri("classpath:/"+getClass().getName().replace('.', '/')+".xtext");
IssuesImpl issues = new IssuesImpl();
reader.checkConfiguration(issues);
assertTrue(issues.hasErrors());
}
use of org.eclipse.xtext.XtextStandaloneSetup in project xtext-core by eclipse.
the class DeclarativeValueConverterServiceTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(new XtextStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(new org.eclipse.xtext.XtextRuntimeModule() {
@SuppressWarnings("unused")
public DeclarativeValueConverterServiceTest bindTest() {
return DeclarativeValueConverterServiceTest.this;
}
});
}
});
}
use of org.eclipse.xtext.XtextStandaloneSetup in project xtext-core by eclipse.
the class ReducedXtextResourceValidatorTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
XtextStandaloneSetup _xtextStandaloneSetup = new XtextStandaloneSetup();
this.with(_xtextStandaloneSetup);
this.resourceValidator = this.<ReducedXtextResourceValidator>get(ReducedXtextResourceValidator.class);
}
Aggregations