Search in sources :

Example 51 with IResourceFactory

use of org.eclipse.xtext.resource.IResourceFactory in project xtext-core by eclipse.

the class MultiValueFeatureTestLanguageStandaloneSetupGenerated method register.

public void register(Injector injector) {
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("multivaluefeaturetestlanguage", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("multivaluefeaturetestlanguage", serviceProvider);
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2008/xtext/MultiValueFeatureTestLanguage")) {
        EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2008/xtext/MultiValueFeatureTestLanguage", MultiValueFeatureTestLanguagePackage.eINSTANCE);
    }
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Example 52 with IResourceFactory

use of org.eclipse.xtext.resource.IResourceFactory in project xtext-core by eclipse.

the class UnorderedGroupsSplitter method transform.

public String transform() {
    Injector injector = new SimpleExpressionsStandaloneSetup().createInjectorAndDoEMFRegistration();
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    return transformContent(resourceFactory);
}
Also used : Injector(com.google.inject.Injector) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Example 53 with IResourceFactory

use of org.eclipse.xtext.resource.IResourceFactory 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));
}
Also used : NullProgressMonitor(org.eclipse.emf.mwe.core.monitor.NullProgressMonitor) WorkflowContextDefaultImpl(org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl) Grammar(org.eclipse.xtext.Grammar) Binder(com.google.inject.Binder) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) Injector(com.google.inject.Injector) IssuesImpl(org.eclipse.emf.mwe.core.issues.IssuesImpl) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory) XtextStandaloneSetup(org.eclipse.xtext.XtextStandaloneSetup) Test(org.junit.Test)

Example 54 with IResourceFactory

use of org.eclipse.xtext.resource.IResourceFactory in project xtext-core by eclipse.

the class IndentationAwareTestLanguageStandaloneSetupGenerated method register.

public void register(Injector injector) {
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("indentationawaretestlanguage", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("indentationawaretestlanguage", serviceProvider);
    if (!EPackage.Registry.INSTANCE.containsKey("http://example.xtext.org/IndentationAwareTestLanguage")) {
        EPackage.Registry.INSTANCE.put("http://example.xtext.org/IndentationAwareTestLanguage", IndentLangPackage.eINSTANCE);
    }
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Example 55 with IResourceFactory

use of org.eclipse.xtext.resource.IResourceFactory in project xtext-core by eclipse.

the class UnassignedTextTestLanguageStandaloneSetupGenerated method register.

public void register(Injector injector) {
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("unassignedtexttestlanguage", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("unassignedtexttestlanguage", serviceProvider);
    if (!EPackage.Registry.INSTANCE.containsKey("http://simple/unassignedtext")) {
        EPackage.Registry.INSTANCE.put("http://simple/unassignedtext", UnassignedtextPackage.eINSTANCE);
    }
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Aggregations

IResourceFactory (org.eclipse.xtext.resource.IResourceFactory)121 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)119 Injector (com.google.inject.Injector)2 Binder (com.google.inject.Binder)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 WorkflowContextDefaultImpl (org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl)1 IssuesImpl (org.eclipse.emf.mwe.core.issues.IssuesImpl)1 NullProgressMonitor (org.eclipse.emf.mwe.core.monitor.NullProgressMonitor)1 Grammar (org.eclipse.xtext.Grammar)1 XtextStandaloneSetup (org.eclipse.xtext.XtextStandaloneSetup)1 FileExtensionProvider (org.eclipse.xtext.resource.FileExtensionProvider)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 Test (org.junit.Test)1