Search in sources :

Example 1 with ResourceServiceProviderRegistryImpl

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

the class ImportedNamespaceAwareLocalScopeProviderTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    with(new IndexTestLanguageStandaloneSetup());
    globalScopeProvider = new ResourceSetGlobalScopeProvider();
    nameProvider = new DefaultDeclarativeQualifiedNameProvider();
    nameConverter = new IQualifiedNameConverter.DefaultImpl();
    final DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
    strategy.setQualifiedNameProvider(nameProvider);
    final DefaultResourceDescriptionManager resourceDescMnr = new DefaultResourceDescriptionManager() {

        @Override
        public IResourceDescription getResourceDescription(Resource resource) {
            DefaultResourceDescription resourceDescription = new DefaultResourceDescription(resource, strategy);
            return resourceDescription;
        }
    };
    final DefaultResourceServiceProvider provider = new DefaultResourceServiceProvider() {

        @Override
        public Manager getResourceDescriptionManager() {
            return resourceDescMnr;
        }
    };
    globalScopeProvider.setGlobalResourceDecriptionProvider(new GlobalResourceDescriptionProvider(new ResourceServiceProviderRegistryImpl() {

        @Override
        public IResourceServiceProvider getResourceServiceProvider(URI uri, String contentType) {
            return provider;
        }
    }));
    CaseInsensitivityHelper caseInsensitivityHelper = new CaseInsensitivityHelper();
    globalScopeProvider.setCaseInsensitivityHelper(caseInsensitivityHelper);
    scopeProvider = new ImportedNamespaceAwareLocalScopeProvider(globalScopeProvider, nameProvider, nameConverter, caseInsensitivityHelper);
}
Also used : DefaultResourceServiceProvider(org.eclipse.xtext.resource.impl.DefaultResourceServiceProvider) DefaultDeclarativeQualifiedNameProvider(org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider) DefaultResourceDescription(org.eclipse.xtext.resource.impl.DefaultResourceDescription) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) IQualifiedNameConverter(org.eclipse.xtext.naming.IQualifiedNameConverter) DefaultResourceDescriptionManager(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) URI(org.eclipse.emf.common.util.URI) DefaultResourceDescriptionStrategy(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy) ResourceServiceProviderRegistryImpl(org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl)

Example 2 with ResourceServiceProviderRegistryImpl

use of org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl in project xtext-eclipse by eclipse.

the class DirtyStateEditorSupportTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    document = this;
    resourceSet = new ResourceSetImpl();
    resourceURI = URI.createURI("scheme://foo");
    resource = new XtextResource(resourceURI);
    resource.setLanguageName("FooLanguage");
    final DefaultResourceServiceProvider resourceServiceProvider = new DefaultResourceServiceProvider() {

        @Override
        public org.eclipse.xtext.resource.IResourceDescription.Manager getResourceDescriptionManager() {
            return DirtyStateEditorSupportTest.this;
        }

        @SuppressWarnings("unchecked")
        @Override
        public <T> T get(Class<T> t) {
            if (DirtyStateResourceDescription.Manager.class.isAssignableFrom(t))
                return (T) new DirtyStateResourceDescription.Manager(DirtyStateEditorSupportTest.this);
            if (LanguageInfo.class.isAssignableFrom(t))
                return (T) new LanguageInfo("FooLanguage");
            return super.get(t);
        }
    };
    ResourceServiceProviderRegistryImpl registry = new ResourceServiceProviderRegistryImpl() {

        @Override
        public IResourceServiceProvider getResourceServiceProvider(URI uri) {
            return resourceServiceProvider;
        }
    };
    resource.setResourceServiceProvider(resourceServiceProvider);
    resourceSet.getResources().add(resource);
    dirtyStateSupport = new DirtyStateEditorSupport();
    dirtyStateSupport.setConcurrentEditingWarningDialog(this);
    dirtyStateSupport.setResourceDescriptions(this);
    dirtyStateManager = new DirtyStateManager();
    stateChangeEventBroker = new StateChangeEventBroker();
    dirtyStateManager.addListener(stateChangeEventBroker);
    dirtyStateSupport.setDirtyStateManager(dirtyStateManager);
    dirtyStateSupport.setStateChangeEventBroker(stateChangeEventBroker);
    dirtyResource = new DocumentBasedDirtyResource();
    dirtyStateSupport.setDirtyResource(dirtyResource);
    dirtyStateSupport.setResourceServiceProviderRegistry(registry);
    ignoreConcurrentEditing = Lists.newLinkedList();
    exportedObjects = Collections.emptyList();
}
Also used : DefaultResourceServiceProvider(org.eclipse.xtext.resource.impl.DefaultResourceServiceProvider) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) DirtyStateResourceDescription(org.eclipse.xtext.ui.editor.DirtyStateResourceDescription) XtextResource(org.eclipse.xtext.resource.XtextResource) Manager(org.eclipse.xtext.resource.IContainer.Manager) DirtyStateManager(org.eclipse.xtext.ui.editor.DirtyStateManager) URI(org.eclipse.emf.common.util.URI) LanguageInfo(org.eclipse.xtext.LanguageInfo) DirtyStateManager(org.eclipse.xtext.ui.editor.DirtyStateManager) StateChangeEventBroker(org.eclipse.xtext.ui.notification.StateChangeEventBroker) EClass(org.eclipse.emf.ecore.EClass) ResourceServiceProviderRegistryImpl(org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl) DocumentBasedDirtyResource(org.eclipse.xtext.ui.editor.DocumentBasedDirtyResource) DirtyStateEditorSupport(org.eclipse.xtext.ui.editor.DirtyStateEditorSupport)

Example 3 with ResourceServiceProviderRegistryImpl

use of org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl in project smarthome by eclipse.

the class RegistryProvider method createRegistry.

private Registry createRegistry() {
    registerDefaultFactories();
    IResourceServiceProvider.Registry registry = new ResourceServiceProviderRegistryImpl();
    register(registry, new ItemsIdeSetup().createInjector());
    register(registry, new PersistenceIdeSetup().createInjector());
    register(registry, new RulesIdeSetup().setScriptServiceUtil(scriptServiceUtil).setScriptEngine(scriptEngine).createInjector());
    register(registry, new ScriptIdeSetup().setScriptServiceUtil(scriptServiceUtil).setScriptEngine(scriptEngine).createInjector());
    register(registry, new SitemapIdeSetup().createInjector());
    register(registry, new ThingIdeSetup().createInjector());
    return registry;
}
Also used : RulesIdeSetup(org.eclipse.smarthome.model.rule.ide.RulesIdeSetup) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) ItemsIdeSetup(org.eclipse.smarthome.model.ide.ItemsIdeSetup) PersistenceIdeSetup(org.eclipse.smarthome.model.persistence.ide.PersistenceIdeSetup) Registry(org.eclipse.xtext.resource.IResourceServiceProvider.Registry) ResourceServiceProviderRegistryImpl(org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl) SitemapIdeSetup(org.eclipse.smarthome.model.ide.SitemapIdeSetup) ThingIdeSetup(org.eclipse.smarthome.model.thing.ide.ThingIdeSetup) ScriptIdeSetup(org.eclipse.smarthome.model.script.ide.ScriptIdeSetup)

Example 4 with ResourceServiceProviderRegistryImpl

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

the class ResourceServiceProviderServiceLoader method loadRegistry.

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;
}
Also used : Injector(com.google.inject.Injector) ISetup(org.eclipse.xtext.ISetup) ResourceServiceProviderRegistryImpl(org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl)

Aggregations

ResourceServiceProviderRegistryImpl (org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl)4 URI (org.eclipse.emf.common.util.URI)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 DefaultResourceServiceProvider (org.eclipse.xtext.resource.impl.DefaultResourceServiceProvider)2 Injector (com.google.inject.Injector)1 EClass (org.eclipse.emf.ecore.EClass)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 ItemsIdeSetup (org.eclipse.smarthome.model.ide.ItemsIdeSetup)1 SitemapIdeSetup (org.eclipse.smarthome.model.ide.SitemapIdeSetup)1 PersistenceIdeSetup (org.eclipse.smarthome.model.persistence.ide.PersistenceIdeSetup)1 RulesIdeSetup (org.eclipse.smarthome.model.rule.ide.RulesIdeSetup)1 ScriptIdeSetup (org.eclipse.smarthome.model.script.ide.ScriptIdeSetup)1 ThingIdeSetup (org.eclipse.smarthome.model.thing.ide.ThingIdeSetup)1 ISetup (org.eclipse.xtext.ISetup)1 LanguageInfo (org.eclipse.xtext.LanguageInfo)1 IndexTestLanguageStandaloneSetup (org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup)1 DefaultDeclarativeQualifiedNameProvider (org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider)1 IQualifiedNameConverter (org.eclipse.xtext.naming.IQualifiedNameConverter)1 Manager (org.eclipse.xtext.resource.IContainer.Manager)1